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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 | 83 |
84 // Pause a list of requests by |request_id|. This will change the state | 84 // Pause a list of requests by |request_id|. This will change the state |
85 // in the request queue so the request cannot be started. | 85 // in the request queue so the request cannot be started. |
86 // TODO(petewil): Add code to cancel an in-progress pre-render. | 86 // TODO(petewil): Add code to cancel an in-progress pre-render. |
87 void PauseRequests(const std::vector<int64_t>& request_ids); | 87 void PauseRequests(const std::vector<int64_t>& request_ids); |
88 | 88 |
89 // Resume a list of previously paused requests, making them available. | 89 // Resume a list of previously paused requests, making them available. |
90 void ResumeRequests(const std::vector<int64_t>& request_ids); | 90 void ResumeRequests(const std::vector<int64_t>& request_ids); |
91 | 91 |
92 // Callback that receives the response for GetAllRequests. Client must | 92 // Callback that receives the response for GetAllRequests. Client must |
93 // copy the result right away, it goes out of scope at the end of the | 93 // copy the result right away, it goes out of scope at the end of the |
Dmitry Titov
2016/08/26 23:39:20
This comment needs updating.
Pete Williamson
2016/08/27 00:11:59
Done.
| |
94 // callback. | 94 // callback. |
95 typedef base::Callback<void(const std::vector<SavePageRequest>&)> | 95 typedef base::Callback<void(std::vector<std::unique_ptr<SavePageRequest>>)> |
96 GetRequestsCallback; | 96 GetRequestsCallback; |
97 | 97 |
98 // Get all save page request items in the callback. | 98 // Get all save page request items in the callback. |
99 void GetAllRequests(const GetRequestsCallback& callback); | 99 void GetAllRequests(const GetRequestsCallback& callback); |
100 | 100 |
101 // Starts processing of one or more queued save page later requests. | 101 // Starts processing of one or more queued save page later requests. |
102 // Returns whether processing was started and that caller should expect | 102 // Returns whether processing was started and that caller should expect |
103 // a callback. If processing was already active, returns false. | 103 // a callback. If processing was already active, returns false. |
104 bool StartProcessing(const DeviceConditions& device_conditions, | 104 bool StartProcessing(const DeviceConditions& device_conditions, |
105 const base::Callback<void(bool)>& callback); | 105 const base::Callback<void(bool)>& callback); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 return is_stopped_; | 152 return is_stopped_; |
153 } | 153 } |
154 | 154 |
155 OfflineEventLogger* GetLogger() { | 155 OfflineEventLogger* GetLogger() { |
156 return &event_logger_; | 156 return &event_logger_; |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 // Receives the results of a get from the request queue, and turns that into | 160 // Receives the results of a get from the request queue, and turns that into |
161 // SavePageRequest objects for the caller of GetQueuedRequests. | 161 // SavePageRequest objects for the caller of GetQueuedRequests. |
162 void GetQueuedRequestsCallback(const GetRequestsCallback& callback, | 162 void GetQueuedRequestsCallback( |
163 RequestQueue::GetRequestsResult result, | 163 const GetRequestsCallback& callback, |
164 const std::vector<SavePageRequest>& requests); | 164 RequestQueue::GetRequestsResult result, |
165 std::vector<std::unique_ptr<SavePageRequest>> requests); | |
165 | 166 |
166 // Receives the result of add requests to the request queue. | 167 // Receives the result of add requests to the request queue. |
167 void AddRequestResultCallback(RequestQueue::AddRequestResult result, | 168 void AddRequestResultCallback(RequestQueue::AddRequestResult result, |
168 const SavePageRequest& request); | 169 const SavePageRequest& request); |
169 | 170 |
170 // Receives the result of update and delete requests to the request queue. | 171 // Receives the result of update and delete requests to the request queue. |
171 void UpdateRequestCallback(const ClientId& client_id, | 172 void UpdateRequestCallback(const ClientId& client_id, |
172 RequestQueue::UpdateRequestResult result); | 173 RequestQueue::UpdateRequestResult result); |
173 | 174 |
174 void UpdateMultipleRequestsCallback( | 175 void UpdateMultipleRequestsCallback( |
175 const RequestQueue::UpdateMultipleRequestResults& result, | 176 const RequestQueue::UpdateMultipleRequestResults& result, |
176 const std::vector<SavePageRequest>& requests); | 177 std::vector<std::unique_ptr<SavePageRequest>> requests); |
177 | 178 |
178 void HandleRemovedRequestsAndCallback( | 179 void HandleRemovedRequestsAndCallback( |
179 const RemoveRequestsCallback& callback, | 180 const RemoveRequestsCallback& callback, |
180 const RequestQueue::UpdateMultipleRequestResults& results, | 181 const RequestQueue::UpdateMultipleRequestResults& results, |
181 const std::vector<SavePageRequest>& requests); | 182 std::vector<std::unique_ptr<SavePageRequest>> requests); |
182 | 183 |
183 void HandleRemovedRequests( | 184 void HandleRemovedRequests( |
184 const RequestQueue::UpdateMultipleRequestResults& results, | 185 const RequestQueue::UpdateMultipleRequestResults& results, |
185 const std::vector<SavePageRequest>& requests); | 186 std::vector<std::unique_ptr<SavePageRequest>> requests); |
186 | 187 |
187 // Callback from the request picker when it has chosen our next request. | 188 // Callback from the request picker when it has chosen our next request. |
188 void RequestPicked(const SavePageRequest& request); | 189 void RequestPicked(const SavePageRequest& request); |
189 | 190 |
190 // Callback from the request picker when no more requests are in the queue. | 191 // Callback from the request picker when no more requests are in the queue. |
191 void RequestQueueEmpty(); | 192 void RequestQueueEmpty(); |
192 | 193 |
193 // Cancels an in progress pre-rendering, and updates state appropriately. | 194 // Cancels an in progress pre-rendering, and updates state appropriately. |
194 void StopPrerendering(); | 195 void StopPrerendering(); |
195 | 196 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 base::TimeDelta offliner_timeout_; | 257 base::TimeDelta offliner_timeout_; |
257 // Allows us to pass a weak pointer to callbacks. | 258 // Allows us to pass a weak pointer to callbacks. |
258 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 259 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
259 | 260 |
260 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 261 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
261 }; | 262 }; |
262 | 263 |
263 } // namespace offline_pages | 264 } // namespace offline_pages |
264 | 265 |
265 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 266 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
OLD | NEW |