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_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const base::WeakPtr<syncer::AttachmentService>& wrapped); | 51 const base::WeakPtr<syncer::AttachmentService>& wrapped); |
52 | 52 |
53 virtual ~AttachmentServiceProxy(); | 53 virtual ~AttachmentServiceProxy(); |
54 | 54 |
55 // AttachmentService implementation. | 55 // AttachmentService implementation. |
56 virtual void GetOrDownloadAttachments( | 56 virtual void GetOrDownloadAttachments( |
57 const AttachmentIdList& attachment_ids, | 57 const AttachmentIdList& attachment_ids, |
58 const GetOrDownloadCallback& callback) OVERRIDE; | 58 const GetOrDownloadCallback& callback) OVERRIDE; |
59 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 59 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
60 const DropCallback& callback) OVERRIDE; | 60 const DropCallback& callback) OVERRIDE; |
61 virtual void OnSyncDataAdd(const SyncData& sync_data) OVERRIDE; | 61 virtual void StoreAttachments(const AttachmentList& attachment, |
| 62 const StoreCallback& callback) OVERRIDE; |
62 virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE; | 63 virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE; |
63 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | 64 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
64 const SyncData& updated_sync_data) OVERRIDE; | 65 const SyncData& updated_sync_data) OVERRIDE; |
65 | 66 |
66 protected: | 67 protected: |
67 // Core does the work of proxying calls to AttachmentService methods from one | 68 // Core does the work of proxying calls to AttachmentService methods from one |
68 // thread to another so AttachmentServiceProxy can be an easy-to-use, | 69 // thread to another so AttachmentServiceProxy can be an easy-to-use, |
69 // non-ref-counted A ref-counted class. | 70 // non-ref-counted A ref-counted class. |
70 // | 71 // |
71 // Callback from AttachmentService are proxied back using free functions | 72 // Callback from AttachmentService are proxied back using free functions |
(...skipping 10 matching lines...) Expand all Loading... |
82 public: | 83 public: |
83 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|. | 84 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|. |
84 Core(const base::WeakPtr<syncer::AttachmentService>& wrapped); | 85 Core(const base::WeakPtr<syncer::AttachmentService>& wrapped); |
85 | 86 |
86 // AttachmentService implementation. | 87 // AttachmentService implementation. |
87 virtual void GetOrDownloadAttachments( | 88 virtual void GetOrDownloadAttachments( |
88 const AttachmentIdList& attachment_ids, | 89 const AttachmentIdList& attachment_ids, |
89 const GetOrDownloadCallback& callback) OVERRIDE; | 90 const GetOrDownloadCallback& callback) OVERRIDE; |
90 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 91 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
91 const DropCallback& callback) OVERRIDE; | 92 const DropCallback& callback) OVERRIDE; |
92 virtual void OnSyncDataAdd(const SyncData& sync_data) OVERRIDE; | 93 virtual void StoreAttachments(const AttachmentList& attachment, |
| 94 const StoreCallback& callback) OVERRIDE; |
93 virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE; | 95 virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE; |
94 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | 96 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
95 const SyncData& updated_sync_data) OVERRIDE; | 97 const SyncData& updated_sync_data) OVERRIDE; |
96 | 98 |
97 protected: | 99 protected: |
98 friend class base::RefCountedThreadSafe<Core>; | 100 friend class base::RefCountedThreadSafe<Core>; |
99 virtual ~Core(); | 101 virtual ~Core(); |
100 | 102 |
101 private: | 103 private: |
102 base::WeakPtr<AttachmentService> wrapped_; | 104 base::WeakPtr<AttachmentService> wrapped_; |
103 | 105 |
104 DISALLOW_COPY_AND_ASSIGN(Core); | 106 DISALLOW_COPY_AND_ASSIGN(Core); |
105 }; | 107 }; |
106 | 108 |
107 // Used in tests to create an AttachmentServiceProxy with a custom Core. | 109 // Used in tests to create an AttachmentServiceProxy with a custom Core. |
108 AttachmentServiceProxy( | 110 AttachmentServiceProxy( |
109 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 111 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
110 const scoped_refptr<Core>& core); | 112 const scoped_refptr<Core>& core); |
111 | 113 |
112 private: | 114 private: |
113 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; | 115 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; |
114 scoped_refptr<Core> core_; | 116 scoped_refptr<Core> core_; |
115 }; | 117 }; |
116 | 118 |
117 } // namespace syncer | 119 } // namespace syncer |
118 | 120 |
119 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 121 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
OLD | NEW |