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 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
10 #include "sync/api/attachments/attachment.h" | 10 #include "sync/api/attachments/attachment.h" |
11 #include "sync/api/attachments/attachment_id.h" | 11 #include "sync/api/attachments/attachment_id.h" |
12 #include "sync/api/attachments/attachment_store.h" | 12 #include "sync/api/attachments/attachment_store.h" |
13 #include "sync/api/attachments/attachment_store_backend.h" | |
14 #include "sync/base/sync_export.h" | 13 #include "sync/base/sync_export.h" |
15 | 14 |
16 namespace base { | 15 namespace base { |
17 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
18 } // namespace base | 17 } // namespace base |
19 | 18 |
20 namespace syncer { | 19 namespace syncer { |
21 | 20 |
22 // An in-memory implementation of AttachmentStore used for testing. | 21 // An in-memory implementation of AttachmentStore used for testing. |
23 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and | 22 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and |
24 // posts callbacks with results on |callback_task_runner|. | 23 // posts callbacks with results on |callback_task_runner|. |
25 class SYNC_EXPORT InMemoryAttachmentStore : public AttachmentStoreBackend, | 24 class SYNC_EXPORT InMemoryAttachmentStore : public AttachmentStoreBackend, |
26 public base::NonThreadSafe { | 25 public base::NonThreadSafe { |
27 public: | 26 public: |
28 InMemoryAttachmentStore( | 27 InMemoryAttachmentStore( |
29 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner); | 28 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner); |
30 ~InMemoryAttachmentStore() override; | 29 ~InMemoryAttachmentStore() override; |
31 | 30 |
32 // AttachmentStoreBackend implementation. | 31 // AttachmentStoreBackend implementation. |
33 void Init(const AttachmentStore::InitCallback& callback) override; | 32 void Init(const AttachmentStore::InitCallback& callback) override; |
34 void Read(const AttachmentIdList& ids, | 33 void Read(const AttachmentIdList& ids, |
35 const AttachmentStore::ReadCallback& callback) override; | 34 const AttachmentStore::ReadCallback& callback) override; |
36 void Write(AttachmentStore::AttachmentReferrer referrer, | 35 void Write(const AttachmentList& attachments, |
37 const AttachmentList& attachments, | |
38 const AttachmentStore::WriteCallback& callback) override; | 36 const AttachmentStore::WriteCallback& callback) override; |
39 void Drop(AttachmentStore::AttachmentReferrer referrer, | 37 void Drop(const AttachmentIdList& ids, |
40 const AttachmentIdList& ids, | |
41 const AttachmentStore::DropCallback& callback) override; | 38 const AttachmentStore::DropCallback& callback) override; |
42 void ReadMetadata( | 39 void ReadMetadata( |
43 const AttachmentIdList& ids, | 40 const AttachmentIdList& ids, |
44 const AttachmentStore::ReadMetadataCallback& callback) override; | 41 const AttachmentStore::ReadMetadataCallback& callback) override; |
45 void ReadAllMetadata( | 42 void ReadAllMetadata( |
46 AttachmentStore::AttachmentReferrer referrer, | |
47 const AttachmentStore::ReadMetadataCallback& callback) override; | 43 const AttachmentStore::ReadMetadataCallback& callback) override; |
48 | 44 |
49 private: | 45 private: |
50 AttachmentMap attachments_; | 46 AttachmentMap attachments_; |
51 | 47 |
52 DISALLOW_COPY_AND_ASSIGN(InMemoryAttachmentStore); | 48 DISALLOW_COPY_AND_ASSIGN(InMemoryAttachmentStore); |
53 }; | 49 }; |
54 | 50 |
55 } // namespace syncer | 51 } // namespace syncer |
56 | 52 |
57 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 53 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
OLD | NEW |