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/api/attachments/attachment_store.h" | 5 #include "components/sync/api/attachments/attachment_store.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "sync/internal_api/public/attachments/attachment_store_frontend.h" | 15 #include "components/sync/core/attachments/attachment_store_frontend.h" |
16 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h" | 16 #include "components/sync/core/attachments/in_memory_attachment_store.h" |
17 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" | 17 #include "components/sync/core/attachments/on_disk_attachment_store.h" |
18 | 18 |
19 namespace syncer { | 19 namespace syncer { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 void NoOpDropCallback(const AttachmentStore::Result& result) { | 23 void NoOpDropCallback(const AttachmentStore::Result& result) {} |
24 } | |
25 } | 24 } |
26 | 25 |
27 AttachmentStore::AttachmentStore( | 26 AttachmentStore::AttachmentStore( |
28 const scoped_refptr<AttachmentStoreFrontend>& frontend, | 27 const scoped_refptr<AttachmentStoreFrontend>& frontend, |
29 Component component) | 28 Component component) |
30 : frontend_(frontend), component_(component) { | 29 : frontend_(frontend), component_(component) {} |
31 } | |
32 | 30 |
33 AttachmentStore::~AttachmentStore() { | 31 AttachmentStore::~AttachmentStore() {} |
34 } | |
35 | 32 |
36 void AttachmentStore::Read(const AttachmentIdList& ids, | 33 void AttachmentStore::Read(const AttachmentIdList& ids, |
37 const ReadCallback& callback) { | 34 const ReadCallback& callback) { |
38 frontend_->Read(component_, ids, callback); | 35 frontend_->Read(component_, ids, callback); |
39 } | 36 } |
40 | 37 |
41 void AttachmentStore::Write(const AttachmentList& attachments, | 38 void AttachmentStore::Write(const AttachmentList& attachments, |
42 const WriteCallback& callback) { | 39 const WriteCallback& callback) { |
43 frontend_->Write(component_, attachments, callback); | 40 frontend_->Write(component_, attachments, callback); |
44 } | 41 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 std::unique_ptr<AttachmentStore> attachment_store( | 106 std::unique_ptr<AttachmentStore> attachment_store( |
110 new AttachmentStore(attachment_store_frontend, MODEL_TYPE)); | 107 new AttachmentStore(attachment_store_frontend, MODEL_TYPE)); |
111 return attachment_store; | 108 return attachment_store; |
112 } | 109 } |
113 | 110 |
114 AttachmentStoreForSync::AttachmentStoreForSync( | 111 AttachmentStoreForSync::AttachmentStoreForSync( |
115 const scoped_refptr<AttachmentStoreFrontend>& frontend, | 112 const scoped_refptr<AttachmentStoreFrontend>& frontend, |
116 Component consumer_component, | 113 Component consumer_component, |
117 Component sync_component) | 114 Component sync_component) |
118 : AttachmentStore(frontend, consumer_component), | 115 : AttachmentStore(frontend, consumer_component), |
119 sync_component_(sync_component) { | 116 sync_component_(sync_component) {} |
120 } | |
121 | 117 |
122 AttachmentStoreForSync::~AttachmentStoreForSync() { | 118 AttachmentStoreForSync::~AttachmentStoreForSync() {} |
123 } | |
124 | 119 |
125 void AttachmentStoreForSync::SetSyncReference(const AttachmentIdList& ids) { | 120 void AttachmentStoreForSync::SetSyncReference(const AttachmentIdList& ids) { |
126 frontend()->SetReference(sync_component_, ids); | 121 frontend()->SetReference(sync_component_, ids); |
127 } | 122 } |
128 | 123 |
129 void AttachmentStoreForSync::SetModelTypeReference( | 124 void AttachmentStoreForSync::SetModelTypeReference( |
130 const AttachmentIdList& ids) { | 125 const AttachmentIdList& ids) { |
131 frontend()->SetReference(component(), ids); | 126 frontend()->SetReference(component(), ids); |
132 } | 127 } |
133 | 128 |
134 void AttachmentStoreForSync::DropSyncReference(const AttachmentIdList& ids) { | 129 void AttachmentStoreForSync::DropSyncReference(const AttachmentIdList& ids) { |
135 frontend()->DropReference(sync_component_, ids, | 130 frontend()->DropReference(sync_component_, ids, |
136 base::Bind(&NoOpDropCallback)); | 131 base::Bind(&NoOpDropCallback)); |
137 } | 132 } |
138 | 133 |
139 void AttachmentStoreForSync::ReadMetadataForSync( | 134 void AttachmentStoreForSync::ReadMetadataForSync( |
140 const ReadMetadataCallback& callback) { | 135 const ReadMetadataCallback& callback) { |
141 frontend()->ReadMetadata(sync_component_, callback); | 136 frontend()->ReadMetadata(sync_component_, callback); |
142 } | 137 } |
143 | 138 |
144 } // namespace syncer | 139 } // namespace syncer |
OLD | NEW |