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

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

Issue 986743004: [Sync] Refactor AttachmentStore classes. Introduce concept of referrer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/api/attachments/attachment_store.cc ('k') | sync/api/attachments/attachment_store_backend.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/attachments/attachment_store_backend.h
diff --git a/sync/api/attachments/attachment_store_backend.h b/sync/api/attachments/attachment_store_backend.h
new file mode 100644
index 0000000000000000000000000000000000000000..74859fe72601e816fddde2764617a2fbcbe9aa1a
--- /dev/null
+++ b/sync/api/attachments/attachment_store_backend.h
@@ -0,0 +1,64 @@
+// Copyright 2015 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_STORE_BACKEND_H_
+#define SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "sync/api/attachments/attachment.h"
+#include "sync/api/attachments/attachment_id.h"
+#include "sync/api/attachments/attachment_store.h"
+#include "sync/base/sync_export.h"
+
+namespace base {
+class SequencedTaskRunner;
+} // namespace base
+
+namespace syncer {
+
+// Interface for AttachmentStore backends.
+//
+// AttachmentStoreBackend provides interface for different backends (on-disk,
+// in-memory). Factory methods in AttachmentStore create corresponding backend
+// and pass reference to AttachmentStore.
+// All functions in AttachmentStoreBackend mirror corresponding functions in
+// AttachmentStore.
+// All callbacks and result codes are used directly from AttachmentStore.
+// AttachmentStoreFrontend only passes callbacks and results without modifying
+// them, there is no need to declare separate set.
+class SYNC_EXPORT AttachmentStoreBackend {
+ public:
+ explicit AttachmentStoreBackend(
+ const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner);
+ virtual ~AttachmentStoreBackend();
+ virtual void Init(const AttachmentStore::InitCallback& callback) = 0;
+ virtual void Read(const AttachmentIdList& ids,
+ const AttachmentStore::ReadCallback& callback) = 0;
+ virtual void Write(AttachmentStore::AttachmentReferrer referrer,
+ const AttachmentList& attachments,
+ const AttachmentStore::WriteCallback& callback) = 0;
+ virtual void Drop(AttachmentStore::AttachmentReferrer referrer,
+ const AttachmentIdList& ids,
+ const AttachmentStore::DropCallback& callback) = 0;
+ virtual void ReadMetadata(
+ const AttachmentIdList& ids,
+ const AttachmentStore::ReadMetadataCallback& callback) = 0;
+ virtual void ReadAllMetadata(
+ AttachmentStore::AttachmentReferrer referrer,
+ const AttachmentStore::ReadMetadataCallback& callback) = 0;
+
+ protected:
+ // Helper function to post callback on callback_task_runner.
+ void PostCallback(const base::Closure& callback);
+
+ private:
+ scoped_refptr<base::SequencedTaskRunner> callback_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(AttachmentStoreBackend);
+};
+
+} // namespace syncer
+
+#endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_
« no previous file with comments | « sync/api/attachments/attachment_store.cc ('k') | sync/api/attachments/attachment_store_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698