| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const AttachmentStore::ReadMetadataCallback& callback) override; | 64 const AttachmentStore::ReadMetadataCallback& callback) override; |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 friend class OnDiskAttachmentStoreSpecificTest; | 67 friend class OnDiskAttachmentStoreSpecificTest; |
| 68 | 68 |
| 69 // Opens leveldb database at |path|, creating it if needed. In the future | 69 // Opens leveldb database at |path|, creating it if needed. In the future |
| 70 // upgrade code will be invoked from OpenOrCreate as well. If open fails | 70 // upgrade code will be invoked from OpenOrCreate as well. If open fails |
| 71 // result is UNSPECIFIED_ERROR. | 71 // result is UNSPECIFIED_ERROR. |
| 72 AttachmentStore::Result OpenOrCreate(const base::FilePath& path); | 72 AttachmentStore::Result OpenOrCreate(const base::FilePath& path); |
| 73 // Reads single attachment from store. Returns nullptr in case of errors. | 73 // Reads single attachment from store. Returns nullptr in case of errors. |
| 74 scoped_ptr<Attachment> ReadSingleAttachment( | 74 std::unique_ptr<Attachment> ReadSingleAttachment( |
| 75 const AttachmentId& attachment_id, | 75 const AttachmentId& attachment_id, |
| 76 AttachmentStore::Component component); | 76 AttachmentStore::Component component); |
| 77 // Writes single attachment to store. Returns false in case of errors. | 77 // Writes single attachment to store. Returns false in case of errors. |
| 78 bool WriteSingleAttachment(const Attachment& attachment, | 78 bool WriteSingleAttachment(const Attachment& attachment, |
| 79 AttachmentStore::Component component); | 79 AttachmentStore::Component component); |
| 80 // Reads single attachment_store_pb::RecordMetadata from levelDB into the | 80 // Reads single attachment_store_pb::RecordMetadata from levelDB into the |
| 81 // provided buffer. Returns false in case of an error. | 81 // provided buffer. Returns false in case of an error. |
| 82 bool ReadSingleRecordMetadata( | 82 bool ReadSingleRecordMetadata( |
| 83 const AttachmentId& attachment_id, | 83 const AttachmentId& attachment_id, |
| 84 attachment_store_pb::RecordMetadata* record_metadata); | 84 attachment_store_pb::RecordMetadata* record_metadata); |
| 85 // Writes single attachment_store_pb::RecordMetadata to levelDB. Returns false | 85 // Writes single attachment_store_pb::RecordMetadata to levelDB. Returns false |
| 86 // in case of an error. | 86 // in case of an error. |
| 87 bool WriteSingleRecordMetadata( | 87 bool WriteSingleRecordMetadata( |
| 88 const AttachmentId& attachment_id, | 88 const AttachmentId& attachment_id, |
| 89 const attachment_store_pb::RecordMetadata& record_metadata); | 89 const attachment_store_pb::RecordMetadata& record_metadata); |
| 90 | 90 |
| 91 static std::string MakeDataKeyFromAttachmentId( | 91 static std::string MakeDataKeyFromAttachmentId( |
| 92 const AttachmentId& attachment_id); | 92 const AttachmentId& attachment_id); |
| 93 static std::string MakeMetadataKeyFromAttachmentId( | 93 static std::string MakeMetadataKeyFromAttachmentId( |
| 94 const AttachmentId& attachment_id); | 94 const AttachmentId& attachment_id); |
| 95 static AttachmentMetadata MakeAttachmentMetadata( | 95 static AttachmentMetadata MakeAttachmentMetadata( |
| 96 const AttachmentId& attachment_id, | 96 const AttachmentId& attachment_id, |
| 97 const attachment_store_pb::RecordMetadata& record_metadata); | 97 const attachment_store_pb::RecordMetadata& record_metadata); |
| 98 | 98 |
| 99 const base::FilePath path_; | 99 const base::FilePath path_; |
| 100 scoped_ptr<leveldb::DB> db_; | 100 std::unique_ptr<leveldb::DB> db_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(OnDiskAttachmentStore); | 102 DISALLOW_COPY_AND_ASSIGN(OnDiskAttachmentStore); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace syncer | 105 } // namespace syncer |
| 106 | 106 |
| 107 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ | 107 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ |
| OLD | NEW |