Chromium Code Reviews| 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/save_page_request.h" | |
| 12 #include "components/offline_pages/offline_page_item.h" | 13 #include "components/offline_pages/offline_page_item.h" |
| 13 | 14 |
| 14 namespace offline_pages { | 15 namespace offline_pages { |
| 15 | 16 |
| 16 class SavePageRequest; | |
| 17 | |
| 18 // Interface for classes storing save page requests. | 17 // Interface for classes storing save page requests. |
| 19 class RequestQueueStore { | 18 class RequestQueueStore { |
| 20 public: | 19 public: |
| 21 enum class UpdateStatus { | 20 enum class UpdateStatus { |
| 22 ADDED, // Request was added successfully. | 21 ADDED, // Request was added successfully. |
| 23 UPDATED, // Request was updated successfully. | 22 UPDATED, // Request was updated successfully. |
| 24 FAILED, // Add or update attempt failed. | 23 FAILED, // Add or update attempt failed. |
| 25 }; | 24 }; |
| 25 // TODO(fgorski): What if no items were updated? Maybe this should work more | |
|
Dmitry Titov
2016/08/11 04:25:54
I think this is TODO(petewil) based on changing Ch
Pete Williamson
2016/08/12 00:06:46
Done.
| |
| 26 // like DeleteCallback. | |
| 26 | 27 |
| 27 typedef base::Callback<void( | 28 typedef base::Callback<void( |
| 28 bool /* success */, | 29 bool /* success */, |
| 29 const std::vector<SavePageRequest>& /* requests */)> | 30 const std::vector<SavePageRequest>& /* requests */)> |
| 30 GetRequestsCallback; | 31 GetRequestsCallback; |
| 31 typedef base::Callback<void(UpdateStatus)> UpdateCallback; | 32 typedef base::Callback<void(UpdateStatus)> UpdateCallback; |
| 32 typedef base::Callback<void(bool /* success */, | 33 typedef base::Callback<void(bool /* success */, |
| 33 int /* number of deleted requests */)> | 34 int /* number of deleted requests */)> |
| 34 RemoveCallback; | 35 RemoveCallback; |
| 35 typedef base::Callback<void(bool /* success */)> ResetCallback; | 36 typedef base::Callback<void(bool /* success */)> ResetCallback; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 54 | 55 |
| 55 // Asynchronously removes requests from the store using their ClientIds. | 56 // Asynchronously removes requests from the store using their ClientIds. |
| 56 // Result of the update, and a number of removed pages is passed in the | 57 // Result of the update, and a number of removed pages is passed in the |
| 57 // callback. Result of remove should be false, when one of the provided items | 58 // callback. Result of remove should be false, when one of the provided items |
| 58 // couldn't be deleted, e.g. because it was missing. In case client_ids is | 59 // couldn't be deleted, e.g. because it was missing. In case client_ids is |
| 59 // empty, though this will return true, but the count of deleted pages will be | 60 // empty, though this will return true, but the count of deleted pages will be |
| 60 // 0. | 61 // 0. |
| 61 virtual void RemoveRequestsByClientId(const std::vector<ClientId>& client_ids, | 62 virtual void RemoveRequestsByClientId(const std::vector<ClientId>& client_ids, |
| 62 const RemoveCallback& callback) = 0; | 63 const RemoveCallback& callback) = 0; |
| 63 | 64 |
| 65 // Asynchronously changes the state of requests from the store using their | |
| 66 // request id. | |
| 67 virtual void ChangeRequestsState( | |
| 68 const std::vector<int64_t>& request_ids, | |
| 69 const SavePageRequest::RequestState new_state, | |
| 70 const UpdateCallback& callback) = 0; | |
| 71 | |
| 64 // Resets the store. | 72 // Resets the store. |
| 65 virtual void Reset(const ResetCallback& callback) = 0; | 73 virtual void Reset(const ResetCallback& callback) = 0; |
| 66 }; | 74 }; |
| 67 | 75 |
| 68 } // namespace offline_pages | 76 } // namespace offline_pages |
| 69 | 77 |
| 70 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ | 78 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_STORE_H_ |
| OLD | NEW |