| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h" | 5 #include "components/sync/core/attachments/in_memory_attachment_store.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace syncer { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void AppendMetadata(AttachmentMetadataList* list, | 18 void AppendMetadata(AttachmentMetadataList* list, |
| 19 const Attachment& attachment) { | 19 const Attachment& attachment) { |
| 20 list->push_back( | 20 list->push_back( |
| 21 AttachmentMetadata(attachment.GetId(), attachment.GetData()->size())); | 21 AttachmentMetadata(attachment.GetId(), attachment.GetData()->size())); |
| 22 } | 22 } |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 InMemoryAttachmentStore::InMemoryAttachmentStore( | 26 InMemoryAttachmentStore::InMemoryAttachmentStore( |
| 27 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner) | 27 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner) |
| 28 : AttachmentStoreBackend(callback_task_runner) { | 28 : AttachmentStoreBackend(callback_task_runner) { |
| 29 // Object is created on one thread but used on another. | 29 // Object is created on one thread but used on another. |
| 30 DetachFromThread(); | 30 DetachFromThread(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 InMemoryAttachmentStore::~InMemoryAttachmentStore() { | 33 InMemoryAttachmentStore::~InMemoryAttachmentStore() {} |
| 34 } | |
| 35 | 34 |
| 36 void InMemoryAttachmentStore::Init( | 35 void InMemoryAttachmentStore::Init( |
| 37 const AttachmentStore::InitCallback& callback) { | 36 const AttachmentStore::InitCallback& callback) { |
| 38 DCHECK(CalledOnValidThread()); | 37 DCHECK(CalledOnValidThread()); |
| 39 PostCallback(base::Bind(callback, AttachmentStore::SUCCESS)); | 38 PostCallback(base::Bind(callback, AttachmentStore::SUCCESS)); |
| 40 } | 39 } |
| 41 | 40 |
| 42 void InMemoryAttachmentStore::Read( | 41 void InMemoryAttachmentStore::Read( |
| 43 AttachmentStore::Component component, | 42 AttachmentStore::Component component, |
| 44 const AttachmentIdList& ids, | 43 const AttachmentIdList& ids, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 InMemoryAttachmentStore::AttachmentEntry::AttachmentEntry( | 153 InMemoryAttachmentStore::AttachmentEntry::AttachmentEntry( |
| 155 const Attachment& attachment, | 154 const Attachment& attachment, |
| 156 AttachmentStore::Component initial_reference_component) | 155 AttachmentStore::Component initial_reference_component) |
| 157 : attachment(attachment) { | 156 : attachment(attachment) { |
| 158 components.insert(initial_reference_component); | 157 components.insert(initial_reference_component); |
| 159 } | 158 } |
| 160 | 159 |
| 161 InMemoryAttachmentStore::AttachmentEntry::AttachmentEntry( | 160 InMemoryAttachmentStore::AttachmentEntry::AttachmentEntry( |
| 162 const AttachmentEntry& other) = default; | 161 const AttachmentEntry& other) = default; |
| 163 | 162 |
| 164 InMemoryAttachmentStore::AttachmentEntry::~AttachmentEntry() { | 163 InMemoryAttachmentStore::AttachmentEntry::~AttachmentEntry() {} |
| 165 } | |
| 166 | 164 |
| 167 } // namespace syncer | 165 } // namespace syncer |
| OLD | NEW |