Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: components/offline_pages/offline_page_metadata_store_impl.h

Issue 1694863003: Refactor the offline page storage to include client namespace and id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move id generation to C++, add DB migration Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 public: 34 public:
35 OfflinePageMetadataStoreImpl( 35 OfflinePageMetadataStoreImpl(
36 scoped_refptr<base::SequencedTaskRunner> background_task_runner, 36 scoped_refptr<base::SequencedTaskRunner> background_task_runner,
37 const base::FilePath& database_dir); 37 const base::FilePath& database_dir);
38 ~OfflinePageMetadataStoreImpl() override; 38 ~OfflinePageMetadataStoreImpl() override;
39 39
40 // OfflinePageMetadataStore implementation: 40 // OfflinePageMetadataStore implementation:
41 void Load(const LoadCallback& callback) override; 41 void Load(const LoadCallback& callback) override;
42 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page_record, 42 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page_record,
43 const UpdateCallback& callback) override; 43 const UpdateCallback& callback) override;
44 void RemoveOfflinePages(const std::vector<int64_t>& bookmark_ids, 44 void RemoveOfflinePages(const std::vector<int64_t>& offline_ids,
45 const UpdateCallback& callback) override; 45 const UpdateCallback& callback) override;
46 void Reset(const ResetCallback& callback) override; 46 void Reset(const ResetCallback& callback) override;
47 47
48 private: 48 private:
49 void LoadContinuation(const LoadCallback& callback, bool success); 49 void LoadContinuation(const LoadCallback& callback, bool success);
50 void LoadDone(const LoadCallback& callback, 50 void LoadDone(const LoadCallback& callback,
51 bool success, 51 bool success,
52 scoped_ptr<std::vector<OfflinePageEntry>> entries); 52 scoped_ptr<std::vector<OfflinePageEntry>> entries);
53 void NotifyLoadResult(const LoadCallback& callback, 53 void NotifyLoadResult(const LoadCallback& callback,
54 LoadStatus status, 54 LoadStatus status,
55 const std::vector<OfflinePageItem>& result); 55 const std::vector<OfflinePageItem>& result);
56 56
57 // Implements the update. 57 // Implements the update.
58 void UpdateEntries( 58 void UpdateEntries(
59 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> 59 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector>
60 entries_to_save, 60 entries_to_save,
61 scoped_ptr<std::vector<std::string>> keys_to_remove, 61 scoped_ptr<std::vector<std::string>> keys_to_remove,
62 const UpdateCallback& callback); 62 const UpdateCallback& callback);
63 void UpdateDone(const OfflinePageMetadataStore::UpdateCallback& callback, 63 void UpdateDone(const OfflinePageMetadataStore::UpdateCallback& callback,
64 bool success); 64 bool success);
65 65
66 void ResetDone(const ResetCallback& callback, bool success); 66 void ResetDone(const ResetCallback& callback, bool success);
67 67
68 // Called when a database has to be migrated from old bookmark ids
69 // to new offline ids.
70 // TODO: Remove this eventually.
71 void DatabaseUpdateDone(const OfflinePageMetadataStore::LoadCallback& cb,
72 LoadStatus status,
73 const std::vector<OfflinePageItem>& result,
74 bool success);
75
68 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; 76 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
69 base::FilePath database_dir_; 77 base::FilePath database_dir_;
70 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database_; 78 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database_;
71 79
72 base::WeakPtrFactory<OfflinePageMetadataStoreImpl> weak_ptr_factory_; 80 base::WeakPtrFactory<OfflinePageMetadataStoreImpl> weak_ptr_factory_;
73 81
74 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreImpl); 82 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreImpl);
75 }; 83 };
76 84
77 } // namespace offline_pages 85 } // namespace offline_pages
78 86
79 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ 87 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698