| OLD | NEW |
| 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 Loading... |
| 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 RemoveRequestsByClientId(const std::vector<ClientId>& client_ids, |
| 42 const RemoveCallback& callback) override; |
| 41 void Reset(const ResetCallback& callback) override; | 43 void Reset(const ResetCallback& callback) override; |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 // Synchronous implementations, these are run on the background thread | 46 // Synchronous implementations, these are run on the background thread |
| 45 // and actually do the work to access SQL. The implementations above | 47 // and actually do the work to access SQL. The implementations above |
| 46 // simply dispatch to the corresponding *Sync method on the background thread. | 48 // simply dispatch to the corresponding *Sync method on the background thread. |
| 47 // 'runner' is where to run the callback. | 49 // 'runner' is where to run the callback. |
| 48 static void GetRequestsSync( | 50 static void GetRequestsSync( |
| 49 sql::Connection* db, | 51 sql::Connection* db, |
| 50 scoped_refptr<base::SingleThreadTaskRunner> runner, | 52 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 51 const GetRequestsCallback& callback); | 53 const GetRequestsCallback& callback); |
| 52 static void AddOrUpdateRequestSync( | 54 static void AddOrUpdateRequestSync( |
| 53 sql::Connection* db, | 55 sql::Connection* db, |
| 54 scoped_refptr<base::SingleThreadTaskRunner> runner, | 56 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 55 const SavePageRequest& offline_page, | 57 const SavePageRequest& offline_page, |
| 56 const UpdateCallback& callback); | 58 const UpdateCallback& callback); |
| 57 static void RemoveRequestsSync( | 59 static void RemoveRequestsSync( |
| 58 sql::Connection* db, | 60 sql::Connection* db, |
| 59 scoped_refptr<base::SingleThreadTaskRunner> runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 60 const std::vector<int64_t>& request_ids, | 62 const std::vector<int64_t>& request_ids, |
| 61 const RemoveCallback& callback); | 63 const RemoveCallback& callback); |
| 64 static void RemoveRequestsByClientIdSync( |
| 65 sql::Connection* db, |
| 66 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 67 const std::vector<ClientId>& client_ids, |
| 68 const RemoveCallback& callback); |
| 62 static void ResetSync(sql::Connection* db, | 69 static void ResetSync(sql::Connection* db, |
| 63 const base::FilePath& db_file_path, | 70 const base::FilePath& db_file_path, |
| 64 scoped_refptr<base::SingleThreadTaskRunner> runner, | 71 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 65 const ResetCallback& callback); | 72 const ResetCallback& callback); |
| 66 | 73 |
| 67 // Used to initialize DB connection. | 74 // Used to initialize DB connection. |
| 68 static void OpenConnectionSync( | 75 static void OpenConnectionSync( |
| 69 sql::Connection* db, | 76 sql::Connection* db, |
| 70 scoped_refptr<base::SingleThreadTaskRunner> runner, | 77 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 71 const base::FilePath& path, | 78 const base::FilePath& path, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 85 // Database connection. | 92 // Database connection. |
| 86 std::unique_ptr<sql::Connection> db_; | 93 std::unique_ptr<sql::Connection> db_; |
| 87 | 94 |
| 88 base::WeakPtrFactory<RequestQueueStoreSQL> weak_ptr_factory_; | 95 base::WeakPtrFactory<RequestQueueStoreSQL> weak_ptr_factory_; |
| 89 DISALLOW_COPY_AND_ASSIGN(RequestQueueStoreSQL); | 96 DISALLOW_COPY_AND_ASSIGN(RequestQueueStoreSQL); |
| 90 }; | 97 }; |
| 91 | 98 |
| 92 } // namespace offline_pages | 99 } // namespace offline_pages |
| 93 | 100 |
| 94 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ | 101 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ |
| OLD | NEW |