| 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 COMPONENTS_SYNC_ENGINE_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 6 #define COMPONENTS_SYNC_ENGINE_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "components/sync/engine/attachments/attachment_store_backend.h" | 14 #include "components/sync/engine/attachments/attachment_store_backend.h" |
| 15 #include "components/sync/model/attachments/attachment.h" | 15 #include "components/sync/model/attachments/attachment.h" |
| 16 #include "components/sync/model/attachments/attachment_id.h" | 16 #include "components/sync/model/attachments/attachment_id.h" |
| 17 #include "components/sync/model/attachments/attachment_store.h" | 17 #include "components/sync/model/attachments/attachment_store.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 21 } // namespace base | 21 } // namespace base |
| 22 | 22 |
| 23 namespace syncer { | 23 namespace syncer { |
| 24 | 24 |
| 25 // An in-memory implementation of AttachmentStore used for testing. | 25 // An in-memory implementation of AttachmentStore used for testing. |
| 26 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and | 26 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and |
| 27 // posts callbacks with results on |callback_task_runner|. | 27 // posts callbacks with results on |callback_task_runner|. |
| 28 class InMemoryAttachmentStore : public AttachmentStoreBackend, | 28 class InMemoryAttachmentStore : public AttachmentStoreBackend { |
| 29 public base::NonThreadSafe { | |
| 30 public: | 29 public: |
| 31 InMemoryAttachmentStore( | 30 InMemoryAttachmentStore( |
| 32 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner); | 31 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner); |
| 33 ~InMemoryAttachmentStore() override; | 32 ~InMemoryAttachmentStore() override; |
| 34 | 33 |
| 35 // AttachmentStoreBackend implementation. | 34 // AttachmentStoreBackend implementation. |
| 36 void Init(const AttachmentStore::InitCallback& callback) override; | 35 void Init(const AttachmentStore::InitCallback& callback) override; |
| 37 void Read(AttachmentStore::Component component, | 36 void Read(AttachmentStore::Component component, |
| 38 const AttachmentIdList& ids, | 37 const AttachmentIdList& ids, |
| 39 const AttachmentStore::ReadCallback& callback) override; | 38 const AttachmentStore::ReadCallback& callback) override; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 AttachmentEntry(const AttachmentEntry& other); | 59 AttachmentEntry(const AttachmentEntry& other); |
| 61 ~AttachmentEntry(); | 60 ~AttachmentEntry(); |
| 62 | 61 |
| 63 Attachment attachment; | 62 Attachment attachment; |
| 64 std::set<AttachmentStore::Component> components; | 63 std::set<AttachmentStore::Component> components; |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 using AttachmentEntryMap = std::map<AttachmentId, AttachmentEntry>; | 66 using AttachmentEntryMap = std::map<AttachmentId, AttachmentEntry>; |
| 68 AttachmentEntryMap attachments_; | 67 AttachmentEntryMap attachments_; |
| 69 | 68 |
| 69 SEQUENCE_CHECKER(sequence_checker_); |
| 70 |
| 70 DISALLOW_COPY_AND_ASSIGN(InMemoryAttachmentStore); | 71 DISALLOW_COPY_AND_ASSIGN(InMemoryAttachmentStore); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace syncer | 74 } // namespace syncer |
| 74 | 75 |
| 75 #endif // COMPONENTS_SYNC_ENGINE_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ | 76 #endif // COMPONENTS_SYNC_ENGINE_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_ |
| OLD | NEW |