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(AttachmentStore::Component component
,
38 const AttachmentIdList
& ids
,
39 const AttachmentStore::ReadCallback
& callback
) = 0;
40 virtual void Write(AttachmentStore::Component component
,
41 const AttachmentList
& attachments
,
42 const AttachmentStore::WriteCallback
& callback
) = 0;
43 virtual void SetReference(AttachmentStore::Component component
,
44 const AttachmentIdList
& ids
) = 0;
45 virtual void DropReference(AttachmentStore::Component component
,
46 const AttachmentIdList
& ids
,
47 const AttachmentStore::DropCallback
& callback
) = 0;
48 virtual void ReadMetadataById(
49 AttachmentStore::Component component
,
50 const AttachmentIdList
& ids
,
51 const AttachmentStore::ReadMetadataCallback
& callback
) = 0;
52 virtual void ReadMetadata(
53 AttachmentStore::Component component
,
54 const AttachmentStore::ReadMetadataCallback
& callback
) = 0;
57 // Helper function to post callback on callback_task_runner.
58 void PostCallback(const base::Closure
& callback
);
61 scoped_refptr
<base::SequencedTaskRunner
> callback_task_runner_
;
63 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreBackend
);
68 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_