| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // store is already destroyed (callbacks will be called). | 28 // store is already destroyed (callbacks will be called). |
| 29 class OfflinePageMetadataStoreImpl : public OfflinePageMetadataStore { | 29 class OfflinePageMetadataStoreImpl : public OfflinePageMetadataStore { |
| 30 public: | 30 public: |
| 31 OfflinePageMetadataStoreImpl( | 31 OfflinePageMetadataStoreImpl( |
| 32 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database, | 32 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database, |
| 33 const base::FilePath& database_dir); | 33 const base::FilePath& database_dir); |
| 34 ~OfflinePageMetadataStoreImpl() override; | 34 ~OfflinePageMetadataStoreImpl() override; |
| 35 | 35 |
| 36 // OfflinePageMetadataStore implementation: | 36 // OfflinePageMetadataStore implementation: |
| 37 void Load(const LoadCallback& callback) override; | 37 void Load(const LoadCallback& callback) override; |
| 38 void AddOfflinePage(const OfflinePageItem& offline_page_record, | 38 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page_record, |
| 39 const UpdateCallback& callback) override; | 39 const UpdateCallback& callback) override; |
| 40 void RemoveOfflinePages(const std::vector<int64>& bookmark_ids, | 40 void RemoveOfflinePages(const std::vector<int64>& bookmark_ids, |
| 41 const UpdateCallback& callback) override; | 41 const UpdateCallback& callback) override; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // Callback for when initialization of the |database_| is done. | 44 // Callback for when initialization of the |database_| is done. |
| 45 void OnInitDone(bool success); | 45 void OnInitDone(bool success); |
| 46 | 46 |
| 47 // Implements the update. | 47 // Implements the update. |
| 48 void UpdateEntries( | 48 void UpdateEntries( |
| 49 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> | 49 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> |
| 50 entries_to_save, | 50 entries_to_save, |
| 51 scoped_ptr<std::vector<std::string>> keys_to_remove, | 51 scoped_ptr<std::vector<std::string>> keys_to_remove, |
| 52 const UpdateCallback& callback); | 52 const UpdateCallback& callback); |
| 53 | 53 |
| 54 // Resets the database. This is to be used when one of the operations fails | 54 // Resets the database. This is to be used when one of the operations fails |
| 55 // with no good explanation. | 55 // with no good explanation. |
| 56 void ResetDB(); | 56 void ResetDB(); |
| 57 | 57 |
| 58 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database_; | 58 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database_; |
| 59 | 59 |
| 60 base::WeakPtrFactory<OfflinePageMetadataStoreImpl> weak_ptr_factory_; | 60 base::WeakPtrFactory<OfflinePageMetadataStoreImpl> weak_ptr_factory_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreImpl); | 62 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreImpl); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace offline_pages | 65 } // namespace offline_pages |
| 66 | 66 |
| 67 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ | 67 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ |
| OLD | NEW |