| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace syncer { | 24 namespace syncer { |
| 25 | 25 |
| 26 // On-disk implementation of AttachmentStore. Stores attachments in leveldb | 26 // On-disk implementation of AttachmentStore. Stores attachments in leveldb |
| 27 // database in |path| directory. | 27 // database in |path| directory. |
| 28 class SYNC_EXPORT OnDiskAttachmentStore : public AttachmentStoreBase, | 28 class SYNC_EXPORT OnDiskAttachmentStore : public AttachmentStoreBase, |
| 29 public base::NonThreadSafe { | 29 public base::NonThreadSafe { |
| 30 public: | 30 public: |
| 31 // Constructs attachment store. | 31 // Constructs attachment store. |
| 32 OnDiskAttachmentStore( | 32 OnDiskAttachmentStore( |
| 33 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner); | 33 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner); |
| 34 virtual ~OnDiskAttachmentStore(); | 34 ~OnDiskAttachmentStore() override; |
| 35 | 35 |
| 36 // AttachmentStoreBase implementation. | 36 // AttachmentStoreBase implementation. |
| 37 // Load opens database, creating it if needed. In the future upgrade code will | 37 // Load opens database, creating it if needed. In the future upgrade code will |
| 38 // be invoked from Load as well. If loading fails it posts |callback| with | 38 // be invoked from Load as well. If loading fails it posts |callback| with |
| 39 // UNSPECIFIED_ERROR. | 39 // UNSPECIFIED_ERROR. |
| 40 virtual void Read(const AttachmentIdList& ids, | 40 void Read(const AttachmentIdList& ids, const ReadCallback& callback) override; |
| 41 const ReadCallback& callback) override; | 41 void Write(const AttachmentList& attachments, |
| 42 virtual void Write(const AttachmentList& attachments, | 42 const WriteCallback& callback) override; |
| 43 const WriteCallback& callback) override; | 43 void Drop(const AttachmentIdList& ids, const DropCallback& callback) override; |
| 44 virtual void Drop(const AttachmentIdList& ids, | |
| 45 const DropCallback& callback) override; | |
| 46 | 44 |
| 47 // Opens leveldb database at |path|. It will create directory and database if | 45 // Opens leveldb database at |path|. It will create directory and database if |
| 48 // it doesn't exist. | 46 // it doesn't exist. |
| 49 Result OpenOrCreate(const base::FilePath& path); | 47 Result OpenOrCreate(const base::FilePath& path); |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 std::string CreateDataKeyFromAttachmentId(const AttachmentId& attachment_id); | 50 std::string CreateDataKeyFromAttachmentId(const AttachmentId& attachment_id); |
| 53 | 51 |
| 54 scoped_refptr<base::SequencedTaskRunner> callback_task_runner_; | 52 scoped_refptr<base::SequencedTaskRunner> callback_task_runner_; |
| 55 scoped_ptr<leveldb::DB> db_; | 53 scoped_ptr<leveldb::DB> db_; |
| 56 }; | 54 }; |
| 57 | 55 |
| 58 } // namespace syncer | 56 } // namespace syncer |
| 59 | 57 |
| 60 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ | 58 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ON_DISK_ATTACHMENT_STORE_H_ |
| OLD | NEW |