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