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

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

Issue 187303006: Update sync API to support attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachmentapi
Patch Set: Fix enum related compile errors on mac. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/api/attachments/attachment_service.cc ('k') | sync/api/attachments/attachment_service_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..09f6c8c202b7ef220e86322666a93693ed66a48d
--- /dev/null
+++ b/sync/api/attachments/attachment_service_proxy.h
@@ -0,0 +1,73 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
+#define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/sequenced_task_runner.h"
+#include "base/task_runner.h"
+#include "sync/api/attachments/attachment.h"
+#include "sync/api/attachments/attachment_service.h"
+#include "sync/base/sync_export.h"
+
+namespace syncer {
+
+class SyncData;
+
+// AttachmentServiceProxy wraps an AttachmentService allowing multiple threads
+// to share the wrapped AttachmentService.
+//
+// Callbacks passed to methods on this class will be invoked in the same thread
+// from which the method was called.
+//
+// This class does not own its wrapped AttachmentService object. This class
+// 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).
+//
+// This class is thread-safe.
+class SYNC_EXPORT AttachmentServiceProxy
+ : public AttachmentService,
+ public base::RefCountedThreadSafe<AttachmentServiceProxy> {
tim (not reviewing) 2014/03/27 17:01:44 I still think having a hidden ref-counted core obj
tim (not reviewing) 2014/03/27 17:02:09 Ignore this comment. It was stale from before a f
+ public:
+ // Construct an AttachmentServiceProxy that forwards calls to |wrapped| on the
+ // |wrapped_task_runner| thread.
+ AttachmentServiceProxy(
+ const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
+ 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;
+ virtual base::WeakPtr<AttachmentService> AsWeakPtr() OVERRIDE;
+
+ private:
+ friend class base::RefCountedThreadSafe<AttachmentServiceProxy>;
+
+ scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_;
+ // wrapped_ must only be dereferenced on the wrapped_task_runner_ thread.
+ base::WeakPtr<AttachmentService> wrapped_;
+
+ // Must be last data member.
+ base::WeakPtrFactory<AttachmentService> weak_ptr_factory_;
+
+ virtual ~AttachmentServiceProxy();
+};
+
+} // namespace syncer
+
+#endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_
« no previous file with comments | « sync/api/attachments/attachment_service.cc ('k') | sync/api/attachments/attachment_service_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698