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