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