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_COORDINATOR_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 std::unique_ptr<RequestQueue> queue, | 58 std::unique_ptr<RequestQueue> queue, |
59 std::unique_ptr<Scheduler> scheduler); | 59 std::unique_ptr<Scheduler> scheduler); |
60 | 60 |
61 ~RequestCoordinator() override; | 61 ~RequestCoordinator() override; |
62 | 62 |
63 // Queues |request| to later load and save when system conditions allow. | 63 // Queues |request| to later load and save when system conditions allow. |
64 // Returns true if the page could be queued successfully. | 64 // Returns true if the page could be queued successfully. |
65 bool SavePageLater( | 65 bool SavePageLater( |
66 const GURL& url, const ClientId& client_id, bool user_reqeusted); | 66 const GURL& url, const ClientId& client_id, bool user_reqeusted); |
67 | 67 |
| 68 // Callback specifying which request IDs were actually removed. |
| 69 typedef base::Callback<void(const std::vector<SavePageRequest>&)> |
| 70 RemoveRequestsCallback; |
| 71 |
68 // Remove a list of requests by |request_id|. This removes requests from the | 72 // Remove a list of requests by |request_id|. This removes requests from the |
69 // request queue, but does not cancel an in-progress pre-render. | 73 // request queue, but does not cancel an in-progress pre-render. |
70 // TODO(petewil): Add code to cancel an in-progress pre-render. | 74 // TODO(petewil): Add code to cancel an in-progress pre-render. |
71 void RemoveRequests(const std::vector<int64_t>& request_ids); | 75 void RemoveRequests(const std::vector<int64_t>& request_ids, |
| 76 const RemoveRequestsCallback& callback); |
72 | 77 |
73 // Pause a list of requests by |request_id|. This will change the state | 78 // Pause a list of requests by |request_id|. This will change the state |
74 // in the request queue so the request cannot be started. | 79 // in the request queue so the request cannot be started. |
75 // TODO(petewil): Add code to cancel an in-progress pre-render. | 80 // TODO(petewil): Add code to cancel an in-progress pre-render. |
76 void PauseRequests(const std::vector<int64_t>& request_ids); | 81 void PauseRequests(const std::vector<int64_t>& request_ids); |
77 | 82 |
78 // Resume a list of previously paused requests, making them available. | 83 // Resume a list of previously paused requests, making them available. |
79 void ResumeRequests(const std::vector<int64_t>& request_ids); | 84 void ResumeRequests(const std::vector<int64_t>& request_ids); |
80 | 85 |
81 // Callback that receives the response for GetAllRequests. Client must | 86 // Callback that receives the response for GetAllRequests. Client must |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 const SavePageRequest& request); | 162 const SavePageRequest& request); |
158 | 163 |
159 // Receives the result of update and delete requests to the request queue. | 164 // Receives the result of update and delete requests to the request queue. |
160 void UpdateRequestCallback(const ClientId& client_id, | 165 void UpdateRequestCallback(const ClientId& client_id, |
161 RequestQueue::UpdateRequestResult result); | 166 RequestQueue::UpdateRequestResult result); |
162 | 167 |
163 void UpdateMultipleRequestsCallback( | 168 void UpdateMultipleRequestsCallback( |
164 const RequestQueue::UpdateMultipleRequestResults& result, | 169 const RequestQueue::UpdateMultipleRequestResults& result, |
165 const std::vector<SavePageRequest>& requests); | 170 const std::vector<SavePageRequest>& requests); |
166 | 171 |
167 void RemoveRequestsCallback( | 172 void HandleRemovedRequestsAndCallback( |
| 173 const RemoveRequestsCallback& callback, |
168 const RequestQueue::UpdateMultipleRequestResults& results, | 174 const RequestQueue::UpdateMultipleRequestResults& results, |
169 const std::vector<SavePageRequest>& requests); | 175 const std::vector<SavePageRequest>& requests); |
170 | 176 |
| 177 void HandleRemovedRequests( |
| 178 const RequestQueue::UpdateMultipleRequestResults& results, |
| 179 const std::vector<SavePageRequest>& requests); |
| 180 |
171 // Callback from the request picker when it has chosen our next request. | 181 // Callback from the request picker when it has chosen our next request. |
172 void RequestPicked(const SavePageRequest& request); | 182 void RequestPicked(const SavePageRequest& request); |
173 | 183 |
174 // Callback from the request picker when no more requests are in the queue. | 184 // Callback from the request picker when no more requests are in the queue. |
175 void RequestQueueEmpty(); | 185 void RequestQueueEmpty(); |
176 | 186 |
177 void SendRequestToOffliner(const SavePageRequest& request); | 187 void SendRequestToOffliner(const SavePageRequest& request); |
178 | 188 |
179 // Called by the offliner when an offlining request is completed. (and by | 189 // Called by the offliner when an offlining request is completed. (and by |
180 // tests). | 190 // tests). |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 base::TimeDelta offliner_timeout_; | 244 base::TimeDelta offliner_timeout_; |
235 // Allows us to pass a weak pointer to callbacks. | 245 // Allows us to pass a weak pointer to callbacks. |
236 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 246 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
237 | 247 |
238 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 248 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
239 }; | 249 }; |
240 | 250 |
241 } // namespace offline_pages | 251 } // namespace offline_pages |
242 | 252 |
243 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 253 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
OLD | NEW |