Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / sync / internal_api / public / attachments / in_memory_attachment_store.h
blobd0c7643c750cde3838f0f4861bcbdf72a847d343
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.
5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/threading/non_thread_safe.h"
10 #include "sync/api/attachments/attachment.h"
11 #include "sync/api/attachments/attachment_id.h"
12 #include "sync/api/attachments/attachment_store.h"
13 #include "sync/api/attachments/attachment_store_backend.h"
14 #include "sync/base/sync_export.h"
16 namespace base {
17 class SequencedTaskRunner;
18 } // namespace base
20 namespace syncer {
22 // An in-memory implementation of AttachmentStore used for testing.
23 // InMemoryAttachmentStore is not threadsafe, it lives on backend thread and
24 // posts callbacks with results on |callback_task_runner|.
25 class SYNC_EXPORT InMemoryAttachmentStore : public AttachmentStoreBackend,
26 public base::NonThreadSafe {
27 public:
28 InMemoryAttachmentStore(
29 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner);
30 ~InMemoryAttachmentStore() override;
32 // AttachmentStoreBackend implementation.
33 void Init(const AttachmentStore::InitCallback& callback) override;
34 void Read(AttachmentStore::Component component,
35 const AttachmentIdList& ids,
36 const AttachmentStore::ReadCallback& callback) override;
37 void Write(AttachmentStore::Component component,
38 const AttachmentList& attachments,
39 const AttachmentStore::WriteCallback& callback) override;
40 void SetReference(AttachmentStore::Component component,
41 const AttachmentIdList& ids) override;
42 void DropReference(AttachmentStore::Component component,
43 const AttachmentIdList& ids,
44 const AttachmentStore::DropCallback& callback) override;
45 void ReadMetadataById(
46 AttachmentStore::Component component,
47 const AttachmentIdList& ids,
48 const AttachmentStore::ReadMetadataCallback& callback) override;
49 void ReadMetadata(
50 AttachmentStore::Component component,
51 const AttachmentStore::ReadMetadataCallback& callback) override;
53 private:
54 struct AttachmentEntry {
55 AttachmentEntry(const Attachment& attachment,
56 AttachmentStore::Component initial_reference_component);
57 ~AttachmentEntry();
59 Attachment attachment;
60 std::set<AttachmentStore::Component> components;
63 typedef std::map<AttachmentId, AttachmentEntry> AttachmentEntryMap;
64 AttachmentEntryMap attachments_;
66 DISALLOW_COPY_AND_ASSIGN(InMemoryAttachmentStore);
69 } // namespace syncer
71 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_IN_MEMORY_ATTACHMENT_STORE_H_