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

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

Issue 2336773002: [Offline pages] Removing static sync methods from Metadata SQL store's interface (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | components/offline_pages/offline_page_metadata_store_sql.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_SQL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 25 matching lines...) Expand all
36 // Implementation methods. 36 // Implementation methods.
37 void GetOfflinePages(const LoadCallback& callback) override; 37 void GetOfflinePages(const LoadCallback& callback) override;
38 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page, 38 void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page,
39 const UpdateCallback& callback) override; 39 const UpdateCallback& callback) override;
40 void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, 40 void RemoveOfflinePages(const std::vector<int64_t>& offline_ids,
41 const UpdateCallback& callback) override; 41 const UpdateCallback& callback) override;
42 void Reset(const ResetCallback& callback) override; 42 void Reset(const ResetCallback& callback) override;
43 StoreState state() const override; 43 StoreState state() const override;
44 44
45 private: 45 private:
46 // Synchronous implementations, these are run on the background thread
47 // and actually do the work to access SQL. The implementations above
48 // simply dispatch to the corresponding *Sync method on the background thread.
49 // 'runner' is where to run the callback.
50 static void AddOrUpdateOfflinePageSync(
51 const OfflinePageItem& offline_page,
52 sql::Connection* db,
53 scoped_refptr<base::SingleThreadTaskRunner> runner,
54 const UpdateCallback& callback);
55 static void RemoveOfflinePagesSync(
56 const std::vector<int64_t>& offline_ids,
57 sql::Connection* db,
58 scoped_refptr<base::SingleThreadTaskRunner> runner,
59 const UpdateCallback& callback);
60
61 // Used to initialize DB connection. 46 // Used to initialize DB connection.
62 void OpenConnection(); 47 void OpenConnection();
63 void OnOpenConnectionDone(StoreState state); 48 void OnOpenConnectionDone(StoreState state);
64 49
65 // Used to reset DB connection. 50 // Used to reset DB connection.
66 void OnResetDone(const ResetCallback& callback, StoreState state); 51 void OnResetDone(const ResetCallback& callback, StoreState state);
67 52
68 // Helper function that checks whether a valid DB connection is present. 53 // Helper function that checks whether a valid DB connection is present.
69 // Returns true if valid connection is present, otherwise it returns false and 54 // Returns true if valid connection is present, otherwise it returns false and
70 // calls the provided callback as a shortcut. 55 // calls the provided callback as a shortcut.
71 bool CheckDb(const base::Closure& callback); 56 bool CheckDb(const base::Closure& callback);
72 57
73 // Background thread where all SQL access should be run. 58 // Background thread where all SQL access should be run.
74 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; 59 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
75 60
76 // Path to the database on disk. 61 // Path to the database on disk.
77 base::FilePath db_file_path_; 62 base::FilePath db_file_path_;
63
64 // Database connection.
78 std::unique_ptr<sql::Connection> db_; 65 std::unique_ptr<sql::Connection> db_;
79 66
67 // State of the store.
80 StoreState state_; 68 StoreState state_;
69
81 base::WeakPtrFactory<OfflinePageMetadataStoreSQL> weak_ptr_factory_; 70 base::WeakPtrFactory<OfflinePageMetadataStoreSQL> weak_ptr_factory_;
82 71
83 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreSQL); 72 DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreSQL);
84 }; 73 };
85 74
86 } // namespace offline_pages 75 } // namespace offline_pages
87 76
88 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_ 77 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/offline_page_metadata_store_sql.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698