1 // Copyright 2015 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_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.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/base/sync_export.h"
16 class SequencedTaskRunner
;
21 // Interface for AttachmentStore backends.
23 // AttachmentStoreBackend provides interface for different backends (on-disk,
24 // in-memory). Factory methods in AttachmentStore create corresponding backend
25 // and pass reference to AttachmentStore.
26 // All functions in AttachmentStoreBackend mirror corresponding functions in
28 // All callbacks and result codes are used directly from AttachmentStore.
29 // AttachmentStoreFrontend only passes callbacks and results without modifying
30 // them, there is no need to declare separate set.
31 class SYNC_EXPORT AttachmentStoreBackend
{
33 explicit AttachmentStoreBackend(
34 const scoped_refptr
<base::SequencedTaskRunner
>& callback_task_runner
);
35 virtual ~AttachmentStoreBackend();
36 virtual void Init(const AttachmentStore::InitCallback
& callback
) = 0;
37 virtual void Read(const AttachmentIdList
& ids
,
38 const AttachmentStore::ReadCallback
& callback
) = 0;
39 virtual void Write(AttachmentStore::Component component
,
40 const AttachmentList
& attachments
,
41 const AttachmentStore::WriteCallback
& callback
) = 0;
42 virtual void SetReference(AttachmentStore::Component component
,
43 const AttachmentIdList
& ids
) = 0;
44 virtual void DropReference(AttachmentStore::Component component
,
45 const AttachmentIdList
& ids
,
46 const AttachmentStore::DropCallback
& callback
) = 0;
47 virtual void ReadMetadata(
48 const AttachmentIdList
& ids
,
49 const AttachmentStore::ReadMetadataCallback
& callback
) = 0;
50 virtual void ReadAllMetadata(
51 AttachmentStore::Component component
,
52 const AttachmentStore::ReadMetadataCallback
& callback
) = 0;
55 // Helper function to post callback on callback_task_runner.
56 void PostCallback(const base::Closure
& callback
);
59 scoped_refptr
<base::SequencedTaskRunner
> callback_task_runner_
;
61 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreBackend
);
66 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_