| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ATTACHMENT_STORE_FRONTEND_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ | 6 #define COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/sequence_checker.h" |
| 13 #include "components/sync/model/attachments/attachment_store.h" | 13 #include "components/sync/model/attachments/attachment_store.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
| 17 } // namespace base | 17 } // namespace base |
| 18 | 18 |
| 19 namespace syncer { | 19 namespace syncer { |
| 20 | 20 |
| 21 class AttachmentStoreBackend; | 21 class AttachmentStoreBackend; |
| 22 | 22 |
| 23 // AttachmentStoreFrontend is helper to post AttachmentStore calls to backend on | 23 // AttachmentStoreFrontend is helper to post AttachmentStore calls to backend on |
| 24 // different thread. Backend is expected to know on which thread to post | 24 // different thread. Backend is expected to know on which thread to post |
| 25 // callbacks with results. | 25 // callbacks with results. |
| 26 // AttachmentStoreFrontend takes ownership of backend. Backend is deleted on | 26 // AttachmentStoreFrontend takes ownership of backend. Backend is deleted on |
| 27 // backend thread. | 27 // backend thread. |
| 28 // AttachmentStoreFrontend is not thread safe, it should only be accessed from | 28 // AttachmentStoreFrontend is not thread safe, it should only be accessed from |
| 29 // model thread. | 29 // model thread. |
| 30 // Method signatures of AttachmentStoreFrontend match exactly methods of | 30 // Method signatures of AttachmentStoreFrontend match exactly methods of |
| 31 // AttachmentStoreBackend. | 31 // AttachmentStoreBackend. |
| 32 class AttachmentStoreFrontend | 32 class AttachmentStoreFrontend |
| 33 : public base::RefCounted<AttachmentStoreFrontend>, | 33 : public base::RefCounted<AttachmentStoreFrontend> { |
| 34 public base::NonThreadSafe { | |
| 35 public: | 34 public: |
| 36 AttachmentStoreFrontend( | 35 AttachmentStoreFrontend( |
| 37 std::unique_ptr<AttachmentStoreBackend> backend, | 36 std::unique_ptr<AttachmentStoreBackend> backend, |
| 38 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner); | 37 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner); |
| 39 | 38 |
| 40 void Init(const AttachmentStore::InitCallback& callback); | 39 void Init(const AttachmentStore::InitCallback& callback); |
| 41 | 40 |
| 42 void Read(AttachmentStore::Component component, | 41 void Read(AttachmentStore::Component component, |
| 43 const AttachmentIdList& ids, | 42 const AttachmentIdList& ids, |
| 44 const AttachmentStore::ReadCallback& callback); | 43 const AttachmentStore::ReadCallback& callback); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 void ReadMetadata(AttachmentStore::Component component, | 58 void ReadMetadata(AttachmentStore::Component component, |
| 60 const AttachmentStore::ReadMetadataCallback& callback); | 59 const AttachmentStore::ReadMetadataCallback& callback); |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 friend class base::RefCounted<AttachmentStoreFrontend>; | 62 friend class base::RefCounted<AttachmentStoreFrontend>; |
| 64 virtual ~AttachmentStoreFrontend(); | 63 virtual ~AttachmentStoreFrontend(); |
| 65 | 64 |
| 66 std::unique_ptr<AttachmentStoreBackend> backend_; | 65 std::unique_ptr<AttachmentStoreBackend> backend_; |
| 67 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; | 66 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; |
| 68 | 67 |
| 68 SEQUENCE_CHECKER(sequence_checker_); |
| 69 |
| 69 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreFrontend); | 70 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreFrontend); |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 } // namespace syncer | 73 } // namespace syncer |
| 73 | 74 |
| 74 #endif // COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ | 75 #endif // COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ |
| OLD | NEW |