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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
11 #include "sync/api/attachments/attachment.h" | 11 #include "sync/api/attachments/attachment.h" |
12 #include "sync/api/attachments/attachment_id.h" | 12 #include "sync/api/attachments/attachment_id.h" |
13 #include "sync/api/attachments/attachment_store.h" | 13 #include "sync/api/attachments/attachment_store.h" |
14 #include "sync/base/sync_export.h" | 14 #include "sync/base/sync_export.h" |
15 | 15 |
16 namespace syncer { | 16 namespace syncer { |
17 | 17 |
18 // An in-memory implementation of AttachmentStore used for testing. | 18 // An in-memory implementation of AttachmentStore used for testing. |
19 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and | 19 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and |
20 // posts callbacks with results on |callback_task_runner|. | 20 // posts callbacks with results on |callback_task_runner|. |
21 class SYNC_EXPORT InMemoryAttachmentStore : public AttachmentStoreBase, | 21 class SYNC_EXPORT InMemoryAttachmentStore : public AttachmentStoreBase, |
22 public base::NonThreadSafe { | 22 public base::NonThreadSafe { |
23 public: | 23 public: |
24 InMemoryAttachmentStore( | 24 InMemoryAttachmentStore( |
25 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner); | 25 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner); |
26 virtual ~InMemoryAttachmentStore(); | 26 ~InMemoryAttachmentStore() override; |
27 | 27 |
28 // AttachmentStoreBase implementation. | 28 // AttachmentStoreBase implementation. |
29 virtual void Read(const AttachmentIdList& ids, | 29 void Read(const AttachmentIdList& ids, const ReadCallback& callback) override; |
30 const ReadCallback& callback) override; | 30 void Write(const AttachmentList& attachments, |
31 virtual void Write(const AttachmentList& attachments, | 31 const WriteCallback& callback) override; |
32 const WriteCallback& callback) override; | 32 void Drop(const AttachmentIdList& ids, const DropCallback& callback) override; |
33 virtual void Drop(const AttachmentIdList& ids, | |
34 const DropCallback& callback) override; | |
35 | 33 |
36 private: | 34 private: |
37 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; | 35 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; |
38 AttachmentMap attachments_; | 36 AttachmentMap attachments_; |
39 }; | 37 }; |
40 | 38 |
41 } // namespace syncer | 39 } // namespace syncer |
42 | 40 |
43 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 41 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
OLD | NEW |