Chromium Code Reviews| 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/base/sync_export.h" | 14 #include "sync/base/sync_export.h" |
| 15 | 15 |
| 16 namespace attachment_store_pb { | |
| 17 class AttachmentStoreMetadata; | |
| 18 } // namespace attachment_store_pb | |
| 19 | |
| 16 namespace base { | 20 namespace base { |
| 17 class SequencedTaskRunner; | 21 class SequencedTaskRunner; |
| 18 } // namespace base | 22 } // namespace base |
| 19 | 23 |
| 20 namespace leveldb { | 24 namespace leveldb { |
| 21 class DB; | 25 class DB; |
| 26 class Status; | |
| 22 } // namespace leveldb | 27 } // namespace leveldb |
| 23 | 28 |
| 24 namespace syncer { | 29 namespace syncer { |
| 25 | 30 |
| 26 // On-disk implementation of AttachmentStore. Stores attachments in leveldb | 31 // On-disk implementation of AttachmentStore. Stores attachments in leveldb |
| 27 // database in |path| directory. | 32 // database in |path| directory. |
| 28 class SYNC_EXPORT OnDiskAttachmentStore : public AttachmentStoreBase, | 33 class SYNC_EXPORT OnDiskAttachmentStore : public AttachmentStoreBase, |
| 29 public base::NonThreadSafe { | 34 public base::NonThreadSafe { |
| 30 public: | 35 public: |
| 31 // Constructs attachment store. | 36 // Constructs attachment store. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 42 virtual void Write(const AttachmentList& attachments, | 47 virtual void Write(const AttachmentList& attachments, |
| 43 const WriteCallback& callback) override; | 48 const WriteCallback& callback) override; |
| 44 virtual void Drop(const AttachmentIdList& ids, | 49 virtual void Drop(const AttachmentIdList& ids, |
| 45 const DropCallback& callback) override; | 50 const DropCallback& callback) override; |
| 46 | 51 |
| 47 // Opens leveldb database at |path|. It will create directory and database if | 52 // Opens leveldb database at |path|. It will create directory and database if |
| 48 // it doesn't exist. | 53 // it doesn't exist. |
| 49 Result OpenOrCreate(const base::FilePath& path); | 54 Result OpenOrCreate(const base::FilePath& path); |
| 50 | 55 |
| 51 private: | 56 private: |
| 52 std::string CreateDataKeyFromAttachmentId(const AttachmentId& attachment_id); | 57 static leveldb::Status ReadStoreMetadata( |
|
maniscalco
2014/10/21 21:41:03
Light suggestion: unless you need them to be part
pavely
2014/10/24 20:42:55
Done.
| |
| 58 leveldb::DB* db, | |
| 59 attachment_store_pb::AttachmentStoreMetadata* metadata); | |
| 60 static leveldb::Status UpdateStoreMetadata( | |
| 61 leveldb::DB* db, | |
| 62 const attachment_store_pb::AttachmentStoreMetadata& metadata); | |
| 63 std::string MakeDataKeyFromAttachmentId(const AttachmentId& attachment_id); | |
| 53 | 64 |
| 54 scoped_refptr<base::SequencedTaskRunner> callback_task_runner_; | 65 scoped_refptr<base::SequencedTaskRunner> callback_task_runner_; |
| 55 scoped_ptr<leveldb::DB> db_; | 66 scoped_ptr<leveldb::DB> db_; |
| 56 }; | 67 }; |
| 57 | 68 |
| 58 } // namespace syncer | 69 } // namespace syncer |
| 59 | 70 |
| 60 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ | 71 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ |
| OLD | NEW |