OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/threading/non_thread_safe.h" |
| 11 #include "sync/api/attachments/attachment_store.h" |
| 12 |
| 13 namespace base { |
| 14 class SequencedTaskRunner; |
| 15 } // namespace base |
| 16 |
| 17 namespace syncer { |
| 18 |
| 19 class AttachmentStoreBackend; |
| 20 |
| 21 // AttachmentStoreFrontend is helper to post AttachmentStore calls to backend on |
| 22 // different thread. Backend is expected to know on which thread to post |
| 23 // callbacks with results. |
| 24 // AttachmentStoreFrontend takes ownership of backend. Backend is deleted on |
| 25 // backend thread. |
| 26 // AttachmentStoreFrontend is not thread safe, it should only be accessed from |
| 27 // model thread. |
| 28 // Method signatures of AttachmentStoreFrontend match exactly methods of |
| 29 // AttachmentStoreBackend. |
| 30 class SYNC_EXPORT AttachmentStoreFrontend |
| 31 : public base::RefCounted<AttachmentStoreFrontend>, |
| 32 public base::NonThreadSafe { |
| 33 public: |
| 34 AttachmentStoreFrontend( |
| 35 scoped_ptr<AttachmentStoreBackend> backend, |
| 36 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner); |
| 37 |
| 38 void Init(const AttachmentStore::InitCallback& callback); |
| 39 |
| 40 void Read(const AttachmentIdList& ids, |
| 41 const AttachmentStore::ReadCallback& callback); |
| 42 |
| 43 void Write(AttachmentStore::AttachmentReferrer referrer, |
| 44 const AttachmentList& attachments, |
| 45 const AttachmentStore::WriteCallback& callback); |
| 46 |
| 47 void Drop(AttachmentStore::AttachmentReferrer referrer, |
| 48 const AttachmentIdList& ids, |
| 49 const AttachmentStore::DropCallback& callback); |
| 50 |
| 51 void ReadMetadata(const AttachmentIdList& ids, |
| 52 const AttachmentStore::ReadMetadataCallback& callback); |
| 53 |
| 54 void ReadAllMetadata(AttachmentStore::AttachmentReferrer referrer, |
| 55 const AttachmentStore::ReadMetadataCallback& callback); |
| 56 |
| 57 private: |
| 58 friend class base::RefCounted<AttachmentStoreFrontend>; |
| 59 virtual ~AttachmentStoreFrontend(); |
| 60 |
| 61 scoped_ptr<AttachmentStoreBackend> backend_; |
| 62 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreFrontend); |
| 65 }; |
| 66 |
| 67 } // namespace syncer |
| 68 |
| 69 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_STORE_FRONTEND_H_ |
OLD | NEW |