| 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_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // calls to this object become no-ops. | 46 // calls to this object become no-ops. |
| 47 AttachmentServiceProxy( | 47 AttachmentServiceProxy( |
| 48 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 48 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
| 49 const base::WeakPtr<syncer::AttachmentService>& wrapped); | 49 const base::WeakPtr<syncer::AttachmentService>& wrapped); |
| 50 | 50 |
| 51 virtual ~AttachmentServiceProxy(); | 51 virtual ~AttachmentServiceProxy(); |
| 52 | 52 |
| 53 // AttachmentService implementation. | 53 // AttachmentService implementation. |
| 54 // | 54 // |
| 55 // GetStore always returns NULL. | 55 // GetStore always returns NULL. |
| 56 virtual AttachmentStore* GetStore() OVERRIDE; | 56 virtual AttachmentStore* GetStore() override; |
| 57 virtual void GetOrDownloadAttachments( | 57 virtual void GetOrDownloadAttachments( |
| 58 const AttachmentIdList& attachment_ids, | 58 const AttachmentIdList& attachment_ids, |
| 59 const GetOrDownloadCallback& callback) OVERRIDE; | 59 const GetOrDownloadCallback& callback) override; |
| 60 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 60 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
| 61 const DropCallback& callback) OVERRIDE; | 61 const DropCallback& callback) override; |
| 62 virtual void UploadAttachments( | 62 virtual void UploadAttachments( |
| 63 const AttachmentIdSet& attachment_ids) OVERRIDE; | 63 const AttachmentIdSet& attachment_ids) override; |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 // Core does the work of proxying calls to AttachmentService methods from one | 66 // Core does the work of proxying calls to AttachmentService methods from one |
| 67 // thread to another so AttachmentServiceProxy can be an easy-to-use, | 67 // thread to another so AttachmentServiceProxy can be an easy-to-use, |
| 68 // non-ref-counted A ref-counted class. | 68 // non-ref-counted A ref-counted class. |
| 69 // | 69 // |
| 70 // Callback from AttachmentService are proxied back using free functions | 70 // Callback from AttachmentService are proxied back using free functions |
| 71 // defined in the .cc file (ProxyFooCallback functions). | 71 // defined in the .cc file (ProxyFooCallback functions). |
| 72 // | 72 // |
| 73 // Core is ref-counted because we want to allow AttachmentServiceProxy to be | 73 // Core is ref-counted because we want to allow AttachmentServiceProxy to be |
| 74 // copy-constructable while allowing for different implementations of Core | 74 // copy-constructable while allowing for different implementations of Core |
| 75 // (e.g. one type of core might own the wrapped AttachmentService). | 75 // (e.g. one type of core might own the wrapped AttachmentService). |
| 76 // | 76 // |
| 77 // Calls to objects of this class become no-ops once its wrapped object is | 77 // Calls to objects of this class become no-ops once its wrapped object is |
| 78 // destroyed. | 78 // destroyed. |
| 79 class SYNC_EXPORT Core : public AttachmentService, | 79 class SYNC_EXPORT Core : public AttachmentService, |
| 80 public base::RefCountedThreadSafe<Core> { | 80 public base::RefCountedThreadSafe<Core> { |
| 81 public: | 81 public: |
| 82 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|. | 82 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|. |
| 83 Core(const base::WeakPtr<syncer::AttachmentService>& wrapped); | 83 Core(const base::WeakPtr<syncer::AttachmentService>& wrapped); |
| 84 | 84 |
| 85 // AttachmentService implementation. | 85 // AttachmentService implementation. |
| 86 virtual AttachmentStore* GetStore() OVERRIDE; | 86 virtual AttachmentStore* GetStore() override; |
| 87 virtual void GetOrDownloadAttachments( | 87 virtual void GetOrDownloadAttachments( |
| 88 const AttachmentIdList& attachment_ids, | 88 const AttachmentIdList& attachment_ids, |
| 89 const GetOrDownloadCallback& callback) OVERRIDE; | 89 const GetOrDownloadCallback& callback) override; |
| 90 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 90 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
| 91 const DropCallback& callback) OVERRIDE; | 91 const DropCallback& callback) override; |
| 92 virtual void UploadAttachments( | 92 virtual void UploadAttachments( |
| 93 const AttachmentIdSet& attachment_ids) OVERRIDE; | 93 const AttachmentIdSet& attachment_ids) override; |
| 94 | 94 |
| 95 protected: | 95 protected: |
| 96 friend class base::RefCountedThreadSafe<Core>; | 96 friend class base::RefCountedThreadSafe<Core>; |
| 97 virtual ~Core(); | 97 virtual ~Core(); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 base::WeakPtr<AttachmentService> wrapped_; | 100 base::WeakPtr<AttachmentService> wrapped_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(Core); | 102 DISALLOW_COPY_AND_ASSIGN(Core); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 // Used in tests to create an AttachmentServiceProxy with a custom Core. | 105 // Used in tests to create an AttachmentServiceProxy with a custom Core. |
| 106 AttachmentServiceProxy( | 106 AttachmentServiceProxy( |
| 107 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 107 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
| 108 const scoped_refptr<Core>& core); | 108 const scoped_refptr<Core>& core); |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; | 111 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; |
| 112 scoped_refptr<Core> core_; | 112 scoped_refptr<Core> core_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace syncer | 115 } // namespace syncer |
| 116 | 116 |
| 117 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 117 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
| OLD | NEW |