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

Unified Diff: sync/internal_api/public/attachments/in_memory_attachment_store.h

Issue 601553004: Refactor FakeAttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/internal_api/public/attachments/in_memory_attachment_store.h
diff --git a/sync/internal_api/public/attachments/in_memory_attachment_store.h b/sync/internal_api/public/attachments/in_memory_attachment_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..e6b899130b4cf25c5df1acf9b140688230c0088c
--- /dev/null
+++ b/sync/internal_api/public/attachments/in_memory_attachment_store.h
@@ -0,0 +1,43 @@
+// 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_INTERNAL_API_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_
maniscalco 2014/09/29 20:57:52 There should be a PUBLIC_ in here, right?
pavely 2014/09/29 23:27:08 Done.
+#define SYNC_INTERNAL_API_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/non_thread_safe.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 syncer {
+
+// An in-memory implementation of AttachmentStore used for testing.
+// InMemoryAttachmentStore is not threadsafe, it lives on backend thread and
+// posts callbacks with results on |callback_task_runner|.
+class SYNC_EXPORT InMemoryAttachmentStore : public AttachmentStoreBase,
+ public base::NonThreadSafe {
+ public:
+ InMemoryAttachmentStore(
+ const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner);
+ virtual ~InMemoryAttachmentStore();
+
+ // AttachmentStoreBase implementation.
+ virtual void Read(const AttachmentIdList& ids,
+ const ReadCallback& callback) OVERRIDE;
+ virtual void Write(const AttachmentList& attachments,
+ const WriteCallback& callback) OVERRIDE;
+ virtual void Drop(const AttachmentIdList& ids,
+ const DropCallback& callback) OVERRIDE;
+
+ private:
+ scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_;
+ AttachmentMap attachments_;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_

Powered by Google App Engine
This is Rietveld 408576698