| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_ | |
| 6 #define COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "components/sync/api/attachments/attachment.h" | |
| 12 #include "components/sync/api/attachments/attachment_id.h" | |
| 13 #include "components/sync/api/attachments/attachment_store.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class SequencedTaskRunner; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace syncer { | |
| 20 | |
| 21 // Interface for AttachmentStore backends. | |
| 22 // | |
| 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 | |
| 27 // AttachmentStore. | |
| 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 AttachmentStoreBackend { | |
| 32 public: | |
| 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; | |
| 55 | |
| 56 protected: | |
| 57 // Helper function to post callback on callback_task_runner. | |
| 58 void PostCallback(const base::Closure& callback); | |
| 59 | |
| 60 private: | |
| 61 scoped_refptr<base::SequencedTaskRunner> callback_task_runner_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreBackend); | |
| 64 }; | |
| 65 | |
| 66 } // namespace syncer | |
| 67 | |
| 68 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_BACKEND_H_ | |
| OLD | NEW |