• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef SYNC_API_ATTACHMENTS_FAKE_ATTACHMENT_STORE_H_
6 #define SYNC_API_ATTACHMENTS_FAKE_ATTACHMENT_STORE_H_
7 
8 #include <map>
9 
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h"
13 #include "sync/api/attachments/attachment_store.h"
14 #include "sync/base/sync_export.h"
15 
16 namespace base {
17 class SequencedTaskRunner;
18 class SingleThreadTaskRunner;
19 }  // namespace base
20 
21 namespace sync_pb {
22 class AttachmentId;
23 }  // namespace sync_pb
24 
25 namespace syncer {
26 
27 class Attachment;
28 
29 // A in-memory only implementation of AttachmentStore used for testing.
30 //
31 // Requires that the current thread has a MessageLoop.
32 class SYNC_EXPORT FakeAttachmentStore : public AttachmentStore {
33  public:
34   // Construct a FakeAttachmentStore whose "IO" will be performed in
35   // |backend_task_runner|.
36   explicit FakeAttachmentStore(
37       const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner);
38 
39   // AttachmentStore implementation.
40   virtual void Read(const AttachmentIdList& id,
41                     const ReadCallback& callback) OVERRIDE;
42   virtual void Write(const AttachmentList& attachments,
43                      const WriteCallback& callback) OVERRIDE;
44   virtual void Drop(const AttachmentIdList& id,
45                     const DropCallback& callback) OVERRIDE;
46 
47  private:
48   class Backend;
49 
50   virtual ~FakeAttachmentStore();
51 
52   scoped_refptr<Backend> backend_;
53   scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
54 
55   DISALLOW_COPY_AND_ASSIGN(FakeAttachmentStore);
56 };
57 
58 }  // namespace syncer
59 
60 #endif  // SYNC_API_ATTACHMENTS_FAKE_ATTACHMENT_STORE_H_
61