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

Unified Diff: sync/api/attachments/attachment_service_proxy.h

Issue 213003004: Replace calls to 3-arg SyncData::CreateLocalData with 5-arg version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Changes from self-review. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: sync/api/attachments/attachment_service_proxy.h
diff --git a/sync/api/attachments/attachment_service_proxy.h b/sync/api/attachments/attachment_service_proxy.h
index 5bec1b3206ab8007e3937d5df00c364a6473b83b..6fe0b6e82f2f4da9d6cf875118bc08f61ba2baeb 100644
--- a/sync/api/attachments/attachment_service_proxy.h
+++ b/sync/api/attachments/attachment_service_proxy.h
@@ -20,7 +20,8 @@ namespace syncer {
class SyncData;
// AttachmentServiceProxy wraps an AttachmentService allowing multiple threads
-// to share the wrapped AttachmentService.
+// to share the wrapped AttachmentService and invoke its methods in the
+// appropriate thread.
//
// Callbacks passed to methods on this class will be invoked in the same thread
// from which the method was called.
@@ -29,8 +30,8 @@ class SyncData;
// holds a WeakPtr to the wrapped object. Once the the wrapped object is
// destroyed, method calls on this object will be no-ops.
//
-// Users of this class should take care to destroy the wrapped object on the
-// correct thread (wrapped_task_runner).
+// Users of this class should take care to destroy the wrapped object on the
+// correct thread (wrapped_task_runner).
//
// This class is thread-safe.
class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService {
@@ -42,9 +43,12 @@ class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService {
// Construct an AttachmentServiceProxy that forwards calls to |wrapped| on the
// |wrapped_task_runner| thread.
+ //
+ // Note, this object does not own |wrapped|. When |wrapped| is destroyed,
+ // calls to this object become no-ops.
AttachmentServiceProxy(
const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
- base::WeakPtr<syncer::AttachmentService> wrapped);
+ const base::WeakPtr<syncer::AttachmentService>& wrapped);
virtual ~AttachmentServiceProxy();
@@ -59,10 +63,52 @@ class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService {
virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids,
const SyncData& updated_sync_data) OVERRIDE;
+ protected:
+ // A ref-counted AttachmentService that forwards to a wrapped
+ // AttachmentService.
+ //
+ // This class is ref-counted because we want to allow AttachmentServiceProxy
+ // to be copy-constructable while allowing for different implementations of
+ // ForwardingCore (e.g. one type of core might own the wrapped
+ // AttachmentService).
+ //
+ // Calls to objects of this class become no-ops once its wrapped object is
+ // destroyed.
+ class SYNC_EXPORT ForwardingCore
tim (not reviewing) 2014/04/10 18:21:41 nit - I'd rather just call this Core. Also, I thi
maniscalco 2014/04/10 20:00:44 Rename ForwardingCore to Core: Done. Opening comm
+ : public AttachmentService,
+ public base::RefCountedThreadSafe<ForwardingCore> {
+ public:
+ // Construct an AttachmentServiceProxyCore that forwards calls to |wrapped|.
+ ForwardingCore(const base::WeakPtr<syncer::AttachmentService>& wrapped);
+
+ // AttachmentService implementation.
+ virtual void GetOrDownloadAttachments(
+ const AttachmentIdList& attachment_ids,
+ const GetOrDownloadCallback& callback) OVERRIDE;
+ virtual void DropAttachments(const AttachmentIdList& attachment_ids,
+ const DropCallback& callback) OVERRIDE;
+ virtual void OnSyncDataAdd(const SyncData& sync_data) OVERRIDE;
+ virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE;
+ virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids,
+ const SyncData& updated_sync_data) OVERRIDE;
+
+ protected:
+ friend class base::RefCountedThreadSafe<ForwardingCore>;
+ virtual ~ForwardingCore();
+
+ private:
+ base::WeakPtr<AttachmentService> wrapped_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForwardingCore);
+ };
+
tim (not reviewing) 2014/04/10 18:21:41 comment this is for tests.
maniscalco 2014/04/10 20:00:44 Done.
+ AttachmentServiceProxy(
+ const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
+ const scoped_refptr<ForwardingCore>& core);
+
private:
scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_;
- // wrapped_ must only be dereferenced on the wrapped_task_runner_ thread.
- base::WeakPtr<AttachmentService> wrapped_;
+ scoped_refptr<ForwardingCore> core_;
};
} // namespace syncer
« no previous file with comments | « components/dom_distiller/core/dom_distiller_store_unittest.cc ('k') | sync/api/attachments/attachment_service_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698