| 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_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "components/offline_pages/background/request_queue.h" | 12 #include "components/offline_pages/background/request_queue.h" |
| 13 #include "components/offline_pages/background/save_page_request.h" | 13 #include "components/offline_pages/background/save_page_request.h" |
| 14 #include "components/offline_pages/offline_page_item.h" | 14 #include "components/offline_pages/offline_page_item.h" |
| 15 | 15 |
| 16 namespace offline_pages { | 16 namespace offline_pages { |
| 17 | 17 |
| 18 // Interface for classes storing save page requests. | 18 // Interface for classes storing save page requests. |
| 19 class RequestQueueStore { | 19 class RequestQueueStore { |
| 20 public: | 20 public: |
| 21 enum class UpdateStatus { | 21 enum class UpdateStatus { |
| 22 ADDED, // Request was added successfully. | 22 ADDED, // Request was added successfully. |
| 23 UPDATED, // Request was updated successfully. | 23 UPDATED, // Request was updated successfully. |
| 24 FAILED, // Add or update attempt failed. | 24 FAILED, // Add or update attempt failed. |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 typedef base::Callback<void( | 27 typedef base::Callback<void( |
| 28 bool /* success */, | 28 bool /* success */, |
| 29 const std::vector<SavePageRequest>& /* requests */)> | 29 std::vector<std::unique_ptr<SavePageRequest>> /* requests */)> |
| 30 GetRequestsCallback; | 30 GetRequestsCallback; |
| 31 typedef base::Callback<void(UpdateStatus)> UpdateCallback; | 31 typedef base::Callback<void(UpdateStatus)> UpdateCallback; |
| 32 typedef base::Callback<void( | 32 typedef base::Callback<void( |
| 33 const RequestQueue::UpdateMultipleRequestResults& /* statuses*/, | 33 const RequestQueue::UpdateMultipleRequestResults& /* statuses*/, |
| 34 const std::vector<SavePageRequest>& /* requests */)> | 34 std::vector<std::unique_ptr<SavePageRequest>> /* requests */)> |
| 35 UpdateMultipleRequestsCallback; | 35 UpdateMultipleRequestsCallback; |
| 36 typedef base::Callback<void( | 36 typedef base::Callback<void( |
| 37 const RequestQueue::UpdateMultipleRequestResults& /* statuses */, | 37 const RequestQueue::UpdateMultipleRequestResults& /* statuses */, |
| 38 const std::vector<SavePageRequest>& /* requests */)> | 38 std::vector<std::unique_ptr<SavePageRequest>> /* requests */)> |
| 39 RemoveCallback; | 39 RemoveCallback; |
| 40 typedef base::Callback<void(bool /* success */)> ResetCallback; | 40 typedef base::Callback<void(bool /* success */)> ResetCallback; |
| 41 | 41 |
| 42 virtual ~RequestQueueStore(){}; | 42 virtual ~RequestQueueStore(){}; |
| 43 | 43 |
| 44 // Gets all of the requests from the store. | 44 // Gets all of the requests from the store. |
| 45 virtual void GetRequests(const GetRequestsCallback& callback) = 0; | 45 virtual void GetRequests(const GetRequestsCallback& callback) = 0; |
| 46 | 46 |
| 47 // Asynchronously adds or updates request in store. | 47 // Asynchronously adds or updates request in store. |
| 48 // Result of the update is passed in the callback. | 48 // Result of the update is passed in the callback. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 const SavePageRequest::RequestState new_state, | 64 const SavePageRequest::RequestState new_state, |
| 65 const UpdateMultipleRequestsCallback& callback) = 0; | 65 const UpdateMultipleRequestsCallback& callback) = 0; |
| 66 | 66 |
| 67 // Resets the store. | 67 // Resets the store. |
| 68 virtual void Reset(const ResetCallback& callback) = 0; | 68 virtual void Reset(const ResetCallback& callback) = 0; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 } // namespace offline_pages | 71 } // namespace offline_pages |
| 72 | 72 |
| 73 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ | 73 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ |
| OLD | NEW |