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 virtual ~InMemoryAttachmentStore(); |
27 | 27 |
28 // AttachmentStoreBase implementation. | 28 // AttachmentStoreBase implementation. |
29 virtual void Read(const AttachmentIdList& ids, | 29 virtual void Read(const AttachmentIdList& ids, |
30 const ReadCallback& callback) OVERRIDE; | 30 const ReadCallback& callback) override; |
31 virtual void Write(const AttachmentList& attachments, | 31 virtual void Write(const AttachmentList& attachments, |
32 const WriteCallback& callback) OVERRIDE; | 32 const WriteCallback& callback) override; |
33 virtual void Drop(const AttachmentIdList& ids, | 33 virtual void Drop(const AttachmentIdList& ids, |
34 const DropCallback& callback) OVERRIDE; | 34 const DropCallback& callback) override; |
35 | 35 |
36 private: | 36 private: |
37 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; | 37 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; |
38 AttachmentMap attachments_; | 38 AttachmentMap attachments_; |
39 }; | 39 }; |
40 | 40 |
41 } // namespace syncer | 41 } // namespace syncer |
42 | 42 |
43 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 43 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
OLD | NEW |