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

Side by Side Diff: components/sync/core/attachments/attachment_service_proxy.h

Issue 2240613002: [Sync] Convert sync to a static library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try getting rid of sync_core source set. Created 4 years, 4 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 COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ 5 #ifndef COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
6 #define COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ 6 #define COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "base/task_runner.h" 12 #include "base/task_runner.h"
13 #include "components/sync/api/attachments/attachment.h" 13 #include "components/sync/api/attachments/attachment.h"
14 #include "components/sync/base/sync_export.h"
15 #include "components/sync/core/attachments/attachment_service.h" 14 #include "components/sync/core/attachments/attachment_service.h"
16 15
17 namespace syncer { 16 namespace syncer {
18 17
19 // AttachmentServiceProxy wraps an AttachmentService allowing multiple threads 18 // AttachmentServiceProxy wraps an AttachmentService allowing multiple threads
20 // to share the wrapped AttachmentService and invoke its methods in the 19 // to share the wrapped AttachmentService and invoke its methods in the
21 // appropriate thread. 20 // appropriate thread.
22 // 21 //
23 // Callbacks passed to methods on this class will be invoked in the same thread 22 // Callbacks passed to methods on this class will be invoked in the same thread
24 // from which the method was called. 23 // from which the method was called.
25 // 24 //
26 // This class does not own its wrapped AttachmentService object. This class 25 // This class does not own its wrapped AttachmentService object. This class
27 // holds a WeakPtr to the wrapped object. Once the the wrapped object is 26 // holds a WeakPtr to the wrapped object. Once the the wrapped object is
28 // destroyed, method calls on this object will be no-ops. 27 // destroyed, method calls on this object will be no-ops.
29 // 28 //
30 // Users of this class should take care to destroy the wrapped object on the 29 // Users of this class should take care to destroy the wrapped object on the
31 // correct thread (wrapped_task_runner). 30 // correct thread (wrapped_task_runner).
32 // 31 //
33 // This class is thread-safe and is designed to be passed by const-ref. 32 // This class is thread-safe and is designed to be passed by const-ref.
34 class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService { 33 class AttachmentServiceProxy : public AttachmentService {
35 public: 34 public:
36 // Default copy and assignment are welcome. 35 // Default copy and assignment are welcome.
37 36
38 // Construct an invalid AttachmentServiceProxy. 37 // Construct an invalid AttachmentServiceProxy.
39 AttachmentServiceProxy(); 38 AttachmentServiceProxy();
40 39
41 // Construct an AttachmentServiceProxy that forwards calls to |wrapped| on the 40 // Construct an AttachmentServiceProxy that forwards calls to |wrapped| on the
42 // |wrapped_task_runner| thread. 41 // |wrapped_task_runner| thread.
43 // 42 //
44 // Note, this object does not own |wrapped|. When |wrapped| is destroyed, 43 // Note, this object does not own |wrapped|. When |wrapped| is destroyed,
(...skipping 17 matching lines...) Expand all
62 // 61 //
63 // Callback from AttachmentService are proxied back using free functions 62 // Callback from AttachmentService are proxied back using free functions
64 // defined in the .cc file (ProxyFooCallback functions). 63 // defined in the .cc file (ProxyFooCallback functions).
65 // 64 //
66 // 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
67 // copy-constructable while allowing for different implementations of Core 66 // copy-constructable while allowing for different implementations of Core
68 // (e.g. one type of core might own the wrapped AttachmentService). 67 // (e.g. one type of core might own the wrapped AttachmentService).
69 // 68 //
70 // 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
71 // destroyed. 70 // destroyed.
72 class SYNC_EXPORT Core : public AttachmentService, 71 class Core : public AttachmentService,
73 public base::RefCountedThreadSafe<Core> { 72 public base::RefCountedThreadSafe<Core> {
74 public: 73 public:
75 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|. 74 // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|.
76 explicit Core(const base::WeakPtr<syncer::AttachmentService>& wrapped); 75 explicit Core(const base::WeakPtr<syncer::AttachmentService>& wrapped);
77 76
78 // AttachmentService implementation. 77 // AttachmentService implementation.
79 void GetOrDownloadAttachments( 78 void GetOrDownloadAttachments(
80 const AttachmentIdList& attachment_ids, 79 const AttachmentIdList& attachment_ids,
81 const GetOrDownloadCallback& callback) override; 80 const GetOrDownloadCallback& callback) override;
82 void UploadAttachments(const AttachmentIdList& attachment_ids) override; 81 void UploadAttachments(const AttachmentIdList& attachment_ids) override;
83 82
(...skipping 14 matching lines...) Expand all
98 const scoped_refptr<Core>& core); 97 const scoped_refptr<Core>& core);
99 98
100 private: 99 private:
101 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; 100 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_;
102 scoped_refptr<Core> core_; 101 scoped_refptr<Core> core_;
103 }; 102 };
104 103
105 } // namespace syncer 104 } // namespace syncer
106 105
107 #endif // COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ 106 #endif // COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698