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