| 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 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // SQLite implementation of RequestQueueStore. | 26 // SQLite implementation of RequestQueueStore. |
| 27 class RequestQueueStoreSQL : public RequestQueueStore { | 27 class RequestQueueStoreSQL : public RequestQueueStore { |
| 28 public: | 28 public: |
| 29 RequestQueueStoreSQL( | 29 RequestQueueStoreSQL( |
| 30 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | 30 scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
| 31 const base::FilePath& database_dir); | 31 const base::FilePath& database_dir); |
| 32 ~RequestQueueStoreSQL() override; | 32 ~RequestQueueStoreSQL() override; |
| 33 | 33 |
| 34 // RequestQueueStore implementation. | 34 // RequestQueueStore implementation. |
| 35 void GetRequests(const GetRequestsCallback& callback) override; | 35 void GetRequests(const GetRequestsCallback& callback) override; |
| 36 // Note: current implementation of this method makes a SQL query per ID. This |
| 37 // is OK as long as number of IDs stays low, which is a typical case. |
| 38 // Implementation should be revisited in case that presumption changes. |
| 39 void GetRequestsByIds(const std::vector<int64_t>& request_ids, |
| 40 const UpdateCallback& callback) override; |
| 36 void AddRequest(const SavePageRequest& offline_page, | 41 void AddRequest(const SavePageRequest& offline_page, |
| 37 const AddCallback& callback) override; | 42 const AddCallback& callback) override; |
| 38 void UpdateRequests(const std::vector<SavePageRequest>& requests, | 43 void UpdateRequests(const std::vector<SavePageRequest>& requests, |
| 39 const UpdateCallback& callback) override; | 44 const UpdateCallback& callback) override; |
| 40 void RemoveRequests(const std::vector<int64_t>& request_ids, | 45 void RemoveRequests(const std::vector<int64_t>& request_ids, |
| 41 const UpdateCallback& callback) override; | 46 const UpdateCallback& callback) override; |
| 42 void Reset(const ResetCallback& callback) override; | 47 void Reset(const ResetCallback& callback) override; |
| 43 StoreState state() const override; | 48 StoreState state() const override; |
| 44 | 49 |
| 45 private: | 50 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 65 // State of the store. | 70 // State of the store. |
| 66 StoreState state_; | 71 StoreState state_; |
| 67 | 72 |
| 68 base::WeakPtrFactory<RequestQueueStoreSQL> weak_ptr_factory_; | 73 base::WeakPtrFactory<RequestQueueStoreSQL> weak_ptr_factory_; |
| 69 DISALLOW_COPY_AND_ASSIGN(RequestQueueStoreSQL); | 74 DISALLOW_COPY_AND_ASSIGN(RequestQueueStoreSQL); |
| 70 }; | 75 }; |
| 71 | 76 |
| 72 } // namespace offline_pages | 77 } // namespace offline_pages |
| 73 | 78 |
| 74 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ | 79 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_SQL_H_ |
| OLD | NEW |