| 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 // TODO(petewil) - UpdateMultiple looks exactly like Remove, consider | 32 // TODO(petewil) - UpdateMultiple looks exactly like Remove, consider |
| 33 // merging them into a single callback. | 33 // merging them into a single callback. |
| 34 typedef base::Callback<void( | 34 typedef base::Callback<void( |
| 35 const RequestQueue::UpdateMultipleRequestResults& /* statuses*/, | 35 const RequestQueue::UpdateMultipleRequestResults& /* statuses*/, |
| 36 const std::vector<SavePageRequest>& /* requests */)> | 36 std::vector<std::unique_ptr<SavePageRequest>> /* requests */)> |
| 37 UpdateMultipleRequestsCallback; | 37 UpdateMultipleRequestsCallback; |
| 38 typedef base::Callback<void( | 38 typedef base::Callback<void( |
| 39 const RequestQueue::UpdateMultipleRequestResults& /* statuses */, | 39 const RequestQueue::UpdateMultipleRequestResults& /* statuses */, |
| 40 const std::vector<SavePageRequest>& /* requests */)> | 40 std::vector<std::unique_ptr<SavePageRequest>> /* requests */)> |
| 41 RemoveCallback; | 41 RemoveCallback; |
| 42 typedef base::Callback<void(bool /* success */)> ResetCallback; | 42 typedef base::Callback<void(bool /* success */)> ResetCallback; |
| 43 | 43 |
| 44 virtual ~RequestQueueStore(){}; | 44 virtual ~RequestQueueStore(){}; |
| 45 | 45 |
| 46 // Gets all of the requests from the store. | 46 // Gets all of the requests from the store. |
| 47 virtual void GetRequests(const GetRequestsCallback& callback) = 0; | 47 virtual void GetRequests(const GetRequestsCallback& callback) = 0; |
| 48 | 48 |
| 49 // Asynchronously adds or updates request in store. | 49 // Asynchronously adds or updates request in store. |
| 50 // Result of the update is passed in the callback. | 50 // Result of the update is passed in the callback. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 66 const SavePageRequest::RequestState new_state, | 66 const SavePageRequest::RequestState new_state, |
| 67 const UpdateMultipleRequestsCallback& callback) = 0; | 67 const UpdateMultipleRequestsCallback& callback) = 0; |
| 68 | 68 |
| 69 // Resets the store. | 69 // Resets the store. |
| 70 virtual void Reset(const ResetCallback& callback) = 0; | 70 virtual void Reset(const ResetCallback& callback) = 0; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace offline_pages | 73 } // namespace offline_pages |
| 74 | 74 |
| 75 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ | 75 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ |
| OLD | NEW |