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

Side by Side Diff: components/offline_pages/background/request_queue_store_sql.h

Issue 2219393004: Adds an observer for the request coordinator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resumeAPI
Patch Set: Fix nits. Created 4 years, 4 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 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_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 20 matching lines...) Expand all
31 scoped_refptr<base::SequencedTaskRunner> background_task_runner, 31 scoped_refptr<base::SequencedTaskRunner> background_task_runner,
32 const base::FilePath& database_dir); 32 const base::FilePath& database_dir);
33 ~RequestQueueStoreSQL() override; 33 ~RequestQueueStoreSQL() override;
34 34
35 // RequestQueueStore implementation. 35 // RequestQueueStore implementation.
36 void GetRequests(const GetRequestsCallback& callback) override; 36 void GetRequests(const GetRequestsCallback& callback) override;
37 void AddOrUpdateRequest(const SavePageRequest& offline_page, 37 void AddOrUpdateRequest(const SavePageRequest& offline_page,
38 const UpdateCallback& callback) override; 38 const UpdateCallback& callback) override;
39 void RemoveRequests(const std::vector<int64_t>& request_ids, 39 void RemoveRequests(const std::vector<int64_t>& request_ids,
40 const RemoveCallback& callback) override; 40 const RemoveCallback& callback) override;
41 void ChangeRequestsState(const std::vector<int64_t>& request_ids, 41 void ChangeRequestsState(
42 const SavePageRequest::RequestState new_state, 42 const std::vector<int64_t>& request_ids,
43 const UpdateCallback& callback) override; 43 const SavePageRequest::RequestState new_state,
44 const UpdateMultipleRequestsCallback& callback) override;
44 void Reset(const ResetCallback& callback) override; 45 void Reset(const ResetCallback& callback) override;
45 46
46 private: 47 private:
47 // Synchronous implementations, these are run on the background thread 48 // Synchronous implementations, these are run on the background thread
48 // and actually do the work to access SQL. The implementations above 49 // and actually do the work to access SQL. The implementations above
49 // simply dispatch to the corresponding *Sync method on the background thread. 50 // simply dispatch to the corresponding *Sync method on the background thread.
50 // 'runner' is where to run the callback. 51 // 'runner' is where to run the callback.
51 static void GetRequestsSync( 52 static void GetRequestsSync(
52 sql::Connection* db, 53 sql::Connection* db,
53 scoped_refptr<base::SingleThreadTaskRunner> runner, 54 scoped_refptr<base::SingleThreadTaskRunner> runner,
54 const GetRequestsCallback& callback); 55 const GetRequestsCallback& callback);
55 static void AddOrUpdateRequestSync( 56 static void AddOrUpdateRequestSync(
56 sql::Connection* db, 57 sql::Connection* db,
57 scoped_refptr<base::SingleThreadTaskRunner> runner, 58 scoped_refptr<base::SingleThreadTaskRunner> runner,
58 const SavePageRequest& offline_page, 59 const SavePageRequest& offline_page,
59 const UpdateCallback& callback); 60 const UpdateCallback& callback);
60 static void RemoveRequestsSync( 61 static void RemoveRequestsSync(
61 sql::Connection* db, 62 sql::Connection* db,
62 scoped_refptr<base::SingleThreadTaskRunner> runner, 63 scoped_refptr<base::SingleThreadTaskRunner> runner,
63 const std::vector<int64_t>& request_ids, 64 const std::vector<int64_t>& request_ids,
64 const RemoveCallback& callback); 65 const RemoveCallback& callback);
65 static void ChangeRequestsStateSync( 66 static void ChangeRequestsStateSync(
66 sql::Connection* db, 67 sql::Connection* db,
67 scoped_refptr<base::SingleThreadTaskRunner> runner, 68 scoped_refptr<base::SingleThreadTaskRunner> runner,
68 const std::vector<int64_t>& request_ids, 69 const std::vector<int64_t>& request_ids,
69 const SavePageRequest::RequestState new_state, 70 const SavePageRequest::RequestState new_state,
70 const UpdateCallback& callback); 71 const UpdateMultipleRequestsCallback& callback);
71 static void ResetSync(sql::Connection* db, 72 static void ResetSync(sql::Connection* db,
72 const base::FilePath& db_file_path, 73 const base::FilePath& db_file_path,
73 scoped_refptr<base::SingleThreadTaskRunner> runner, 74 scoped_refptr<base::SingleThreadTaskRunner> runner,
74 const ResetCallback& callback); 75 const ResetCallback& callback);
75 76
76 // Helper functions to return immediately if no database is found. 77 // Helper functions to return immediately if no database is found.
77 bool CheckDb(const base::Closure& callback); 78 bool CheckDb(const base::Closure& callback);
78 79
79 // Used to initialize DB connection. 80 // Used to initialize DB connection.
80 static void OpenConnectionSync( 81 static void OpenConnectionSync(
(...skipping 16 matching lines...) Expand all
97 // Database connection. 98 // Database connection.
98 std::unique_ptr<sql::Connection> db_; 99 std::unique_ptr<sql::Connection> db_;
99 100
100 base::WeakPtrFactory<RequestQueueStoreSQL> weak_ptr_factory_; 101 base::WeakPtrFactory<RequestQueueStoreSQL> weak_ptr_factory_;
101 DISALLOW_COPY_AND_ASSIGN(RequestQueueStoreSQL); 102 DISALLOW_COPY_AND_ASSIGN(RequestQueueStoreSQL);
102 }; 103 };
103 104
104 } // namespace offline_pages 105 } // namespace offline_pages
105 106
106 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ 107 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698