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