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

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

Issue 1420003004: Wipe out offline page data on clearing cookie and site data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more feedback Created 5 years, 1 month 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 <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "components/leveldb_proto/proto_database.h" 13 #include "components/leveldb_proto/proto_database.h"
13 #include "components/offline_pages/offline_page_metadata_store.h" 14 #include "components/offline_pages/offline_page_metadata_store.h"
14 15
15 namespace base { 16 namespace base {
16 class FilePath; 17 class SequencedTaskRunner;
17 } 18 }
18 19
19 namespace offline_pages { 20 namespace offline_pages {
20 21
21 class OfflinePageEntry; 22 class OfflinePageEntry;
22 23
23 // Implements OfflinePageMetadataStore using leveldb_proto::ProtoDatabase 24 // Implements OfflinePageMetadataStore using leveldb_proto::ProtoDatabase
24 // component. Stores metadata of offline pages as serialized protobufs in a 25 // component. Stores metadata of offline pages as serialized protobufs in a
25 // LevelDB key/value pairs. 26 // LevelDB key/value pairs.
26 // Underlying implementation guarantees that all of the method calls will be 27 // Underlying implementation guarantees that all of the method calls will be
27 // executed sequentially, and started operations will finish even after the 28 // executed sequentially, and started operations will finish even after the
28 // store is already destroyed (callbacks will be called). 29 // store is already destroyed (callbacks will be called).
29 class OfflinePageMetadataStoreImpl : public OfflinePageMetadataStore { 30 class OfflinePageMetadataStoreImpl : public OfflinePageMetadataStore {
30 public: 31 public:
31 OfflinePageMetadataStoreImpl( 32 OfflinePageMetadataStoreImpl(
32 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database, 33 scoped_refptr<base::SequencedTaskRunner> background_task_runner,
33 const base::FilePath& database_dir); 34 const base::FilePath& database_dir);
34 ~OfflinePageMetadataStoreImpl() override; 35 ~OfflinePageMetadataStoreImpl() override;
35 36
36 // OfflinePageMetadataStore implementation: 37 // OfflinePageMetadataStore implementation:
37 void Load(const LoadCallback& callback) override; 38 void Load(const LoadCallback& callback) override;
38 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page_record, 39 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page_record,
39 const UpdateCallback& callback) override; 40 const UpdateCallback& callback) override;
40 void RemoveOfflinePages(const std::vector<int64>& bookmark_ids, 41 void RemoveOfflinePages(const std::vector<int64>& bookmark_ids,
41 const UpdateCallback& callback) override; 42 const UpdateCallback& callback) override;
43 void Reset(const ResetCallback& callback) override;
42 44
43 private: 45 private:
44 // Callback for when initialization of the |database_| is done. 46 void LoadContinuation(const LoadCallback& callback, bool success);
45 void OnInitDone(bool success); 47 void LoadDone(const LoadCallback& callback,
48 bool success,
49 scoped_ptr<std::vector<OfflinePageEntry>> entries);
50 void NotifyLoadResult(const LoadCallback& callback,
51 LoadStatus status,
52 const std::vector<OfflinePageItem>& result);
46 53
47 // Implements the update. 54 // Implements the update.
48 void UpdateEntries( 55 void UpdateEntries(
49 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector> 56 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>::KeyEntryVector>
50 entries_to_save, 57 entries_to_save,
51 scoped_ptr<std::vector<std::string>> keys_to_remove, 58 scoped_ptr<std::vector<std::string>> keys_to_remove,
52 const UpdateCallback& callback); 59 const UpdateCallback& callback);
60 void UpdateDone(const OfflinePageMetadataStore::UpdateCallback& callback,
61 bool success);
53 62
54 // Resets the database. This is to be used when one of the operations fails 63 void ResetDone(const ResetCallback& callback, bool success);
55 // with no good explanation.
56 void ResetDB();
57 64
65 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
66 base::FilePath database_dir_;
58 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database_; 67 scoped_ptr<leveldb_proto::ProtoDatabase<OfflinePageEntry>> database_;
59 68
60 base::WeakPtrFactory<OfflinePageMetadataStoreImpl> weak_ptr_factory_; 69 base::WeakPtrFactory<OfflinePageMetadataStoreImpl> weak_ptr_factory_;
61 70
62 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreImpl); 71 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreImpl);
63 }; 72 };
64 73
65 } // namespace offline_pages 74 } // namespace offline_pages
66 75
67 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_ 76 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_IMPL_H_
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_metadata_store.h ('k') | components/offline_pages/offline_page_metadata_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698