Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: sync/internal_api/public/attachments/attachment_service_proxy.h

Issue 1035573002: [Sync] Replace AttachmentIdSet with AttachmentIdList in interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes after Nick's feedback. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids, 53 void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids,
54 const GetOrDownloadCallback& callback) override; 54 const GetOrDownloadCallback& callback) override;
55 void UploadAttachments(const AttachmentIdSet& attachment_ids) override; 55 void UploadAttachments(const AttachmentIdList& attachment_ids) override;
56 56
57 protected: 57 protected:
58 // Core does the work of proxying calls to AttachmentService methods from one 58 // Core does the work of proxying calls to AttachmentService methods from one
59 // thread to another so AttachmentServiceProxy can be an easy-to-use, 59 // thread to another so AttachmentServiceProxy can be an easy-to-use,
60 // non-ref-counted A ref-counted class. 60 // non-ref-counted A ref-counted class.
61 // 61 //
62 // Callback from AttachmentService are proxied back using free functions 62 // Callback from AttachmentService are proxied back using free functions
63 // defined in the .cc file (ProxyFooCallback functions). 63 // defined in the .cc file (ProxyFooCallback functions).
64 // 64 //
65 // Core is ref-counted because we want to allow AttachmentServiceProxy to be 65 // Core is ref-counted because we want to allow AttachmentServiceProxy to be
66 // copy-constructable while allowing for different implementations of Core 66 // copy-constructable while allowing for different implementations of Core
67 // (e.g. one type of core might own the wrapped AttachmentService). 67 // (e.g. one type of core might own the wrapped AttachmentService).
68 // 68 //
69 // Calls to objects of this class become no-ops once its wrapped object is 69 // Calls to objects of this class become no-ops once its wrapped object is
70 // destroyed. 70 // destroyed.
71 class SYNC_EXPORT Core : public AttachmentService, 71 class SYNC_EXPORT Core : public AttachmentService,
72 public base::RefCountedThreadSafe<Core> { 72 public base::RefCountedThreadSafe<Core> {
73 public: 73 public:
74 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|. 74 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|.
75 Core(const base::WeakPtr<syncer::AttachmentService>& wrapped); 75 Core(const base::WeakPtr<syncer::AttachmentService>& wrapped);
76 76
77 // AttachmentService implementation. 77 // AttachmentService implementation.
78 void GetOrDownloadAttachments( 78 void GetOrDownloadAttachments(
79 const AttachmentIdList& attachment_ids, 79 const AttachmentIdList& attachment_ids,
80 const GetOrDownloadCallback& callback) override; 80 const GetOrDownloadCallback& callback) override;
81 void UploadAttachments(const AttachmentIdSet& attachment_ids) override; 81 void UploadAttachments(const AttachmentIdList& attachment_ids) override;
82 82
83 protected: 83 protected:
84 friend class base::RefCountedThreadSafe<Core>; 84 friend class base::RefCountedThreadSafe<Core>;
85 ~Core() override; 85 ~Core() override;
86 86
87 private: 87 private:
88 base::WeakPtr<AttachmentService> wrapped_; 88 base::WeakPtr<AttachmentService> wrapped_;
89 89
90 DISALLOW_COPY_AND_ASSIGN(Core); 90 DISALLOW_COPY_AND_ASSIGN(Core);
91 }; 91 };
92 92
93 // Used in tests to create an AttachmentServiceProxy with a custom Core. 93 // Used in tests to create an AttachmentServiceProxy with a custom Core.
94 AttachmentServiceProxy( 94 AttachmentServiceProxy(
95 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, 95 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
96 const scoped_refptr<Core>& core); 96 const scoped_refptr<Core>& core);
97 97
98 private: 98 private:
99 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; 99 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_;
100 scoped_refptr<Core> core_; 100 scoped_refptr<Core> core_;
101 }; 101 };
102 102
103 } // namespace syncer 103 } // namespace syncer
104 104
105 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ 105 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/attachments/attachment_service_impl.h ('k') | sync/internal_api/public/read_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698