| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
| 11 #include "sync/api/attachments/attachment.h" | 11 #include "sync/api/attachments/attachment.h" |
| 12 #include "sync/api/attachments/attachment_id.h" | 12 #include "sync/api/attachments/attachment_id.h" |
| 13 #include "sync/api/attachments/attachment_store.h" | 13 #include "sync/api/attachments/attachment_store.h" |
| 14 #include "sync/api/attachments/attachment_store_backend.h" |
| 14 #include "sync/base/sync_export.h" | 15 #include "sync/base/sync_export.h" |
| 15 | 16 |
| 16 namespace attachment_store_pb { | 17 namespace attachment_store_pb { |
| 17 class RecordMetadata; | 18 class RecordMetadata; |
| 18 } // namespace attachment_store_pb | 19 } // namespace attachment_store_pb |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 22 } // namespace base | 23 } // namespace base |
| 23 | 24 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 // Constructs attachment store. | 36 // Constructs attachment store. |
| 36 OnDiskAttachmentStore( | 37 OnDiskAttachmentStore( |
| 37 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner, | 38 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner, |
| 38 const base::FilePath& path); | 39 const base::FilePath& path); |
| 39 ~OnDiskAttachmentStore() override; | 40 ~OnDiskAttachmentStore() override; |
| 40 | 41 |
| 41 // AttachmentStoreBackend implementation. | 42 // AttachmentStoreBackend implementation. |
| 42 void Init(const AttachmentStore::InitCallback& callback) override; | 43 void Init(const AttachmentStore::InitCallback& callback) override; |
| 43 void Read(const AttachmentIdList& ids, | 44 void Read(const AttachmentIdList& ids, |
| 44 const AttachmentStore::ReadCallback& callback) override; | 45 const AttachmentStore::ReadCallback& callback) override; |
| 45 void Write(const AttachmentList& attachments, | 46 void Write(AttachmentStore::AttachmentReferrer referrer, |
| 47 const AttachmentList& attachments, |
| 46 const AttachmentStore::WriteCallback& callback) override; | 48 const AttachmentStore::WriteCallback& callback) override; |
| 47 void Drop(const AttachmentIdList& ids, | 49 void Drop(AttachmentStore::AttachmentReferrer referrer, |
| 50 const AttachmentIdList& ids, |
| 48 const AttachmentStore::DropCallback& callback) override; | 51 const AttachmentStore::DropCallback& callback) override; |
| 49 void ReadMetadata( | 52 void ReadMetadata( |
| 50 const AttachmentIdList& ids, | 53 const AttachmentIdList& ids, |
| 51 const AttachmentStore::ReadMetadataCallback& callback) override; | 54 const AttachmentStore::ReadMetadataCallback& callback) override; |
| 52 void ReadAllMetadata( | 55 void ReadAllMetadata( |
| 56 AttachmentStore::AttachmentReferrer referrer, |
| 53 const AttachmentStore::ReadMetadataCallback& callback) override; | 57 const AttachmentStore::ReadMetadataCallback& callback) override; |
| 54 | 58 |
| 55 private: | 59 private: |
| 56 friend class OnDiskAttachmentStoreSpecificTest; | 60 friend class OnDiskAttachmentStoreSpecificTest; |
| 57 | 61 |
| 58 // Opens leveldb database at |path|, creating it if needed. In the future | 62 // Opens leveldb database at |path|, creating it if needed. In the future |
| 59 // upgrade code will be invoked from OpenOrCreate as well. If open fails | 63 // upgrade code will be invoked from OpenOrCreate as well. If open fails |
| 60 // result is UNSPECIFIED_ERROR. | 64 // result is UNSPECIFIED_ERROR. |
| 61 AttachmentStore::Result OpenOrCreate(const base::FilePath& path); | 65 AttachmentStore::Result OpenOrCreate(const base::FilePath& path); |
| 62 // Reads single attachment from store. Returns nullptr in case of errors. | 66 // Reads single attachment from store. Returns nullptr in case of errors. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 80 | 84 |
| 81 const base::FilePath path_; | 85 const base::FilePath path_; |
| 82 scoped_ptr<leveldb::DB> db_; | 86 scoped_ptr<leveldb::DB> db_; |
| 83 | 87 |
| 84 DISALLOW_COPY_AND_ASSIGN(OnDiskAttachmentStore); | 88 DISALLOW_COPY_AND_ASSIGN(OnDiskAttachmentStore); |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 } // namespace syncer | 91 } // namespace syncer |
| 88 | 92 |
| 89 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ | 93 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ |
| OLD | NEW |