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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // the next StartProcessing() call. | 162 // the next StartProcessing() call. |
163 bool is_canceled() { | 163 bool is_canceled() { |
164 return is_stopped_; | 164 return is_stopped_; |
165 } | 165 } |
166 | 166 |
167 OfflineEventLogger* GetLogger() { | 167 OfflineEventLogger* GetLogger() { |
168 return &event_logger_; | 168 return &event_logger_; |
169 } | 169 } |
170 | 170 |
171 private: | 171 private: |
| 172 // Immediate start attempt status code for UMA. |
| 173 // For any changes, also update corresponding histogram in histograms.xml. |
| 174 enum OfflinerImmediateStartStatus { |
| 175 // Did start processing request. |
| 176 STARTED = 0, |
| 177 // Already busy processing a request. |
| 178 BUSY = 1, |
| 179 // The Offliner did not accept processing the request. |
| 180 NOT_ACCEPTED = 2, |
| 181 // No current network connection. |
| 182 NO_CONNECTION = 3, |
| 183 // Weak network connection (worse than 2G speed) |
| 184 // according to network quality estimator. |
| 185 WEAK_CONNECTION = 4, |
| 186 // Did not start because this is svelte device. |
| 187 NOT_STARTED_ON_SVELTE = 5, |
| 188 // NOTE: insert new values above this line and update histogram enum too. |
| 189 STATUS_COUNT = 6, |
| 190 }; |
| 191 |
172 // Receives the results of a get from the request queue, and turns that into | 192 // Receives the results of a get from the request queue, and turns that into |
173 // SavePageRequest objects for the caller of GetQueuedRequests. | 193 // SavePageRequest objects for the caller of GetQueuedRequests. |
174 void GetQueuedRequestsCallback( | 194 void GetQueuedRequestsCallback( |
175 const GetRequestsCallback& callback, | 195 const GetRequestsCallback& callback, |
176 RequestQueue::GetRequestsResult result, | 196 RequestQueue::GetRequestsResult result, |
177 std::vector<std::unique_ptr<SavePageRequest>> requests); | 197 std::vector<std::unique_ptr<SavePageRequest>> requests); |
178 | 198 |
179 // Receives the results of a get from the request queue, and turns that into | 199 // Receives the results of a get from the request queue, and turns that into |
180 // SavePageRequest objects for the caller of GetQueuedRequests. | 200 // SavePageRequest objects for the caller of GetQueuedRequests. |
181 void GetRequestsForSchedulingCallback( | 201 void GetRequestsForSchedulingCallback( |
(...skipping 16 matching lines...) Expand all Loading... |
198 BackgroundSavePageResult status, | 218 BackgroundSavePageResult status, |
199 std::unique_ptr<UpdateRequestsResult> result); | 219 std::unique_ptr<UpdateRequestsResult> result); |
200 | 220 |
201 void HandleRemovedRequests(BackgroundSavePageResult status, | 221 void HandleRemovedRequests(BackgroundSavePageResult status, |
202 std::unique_ptr<UpdateRequestsResult> result); | 222 std::unique_ptr<UpdateRequestsResult> result); |
203 | 223 |
204 // Start processing now if connected (but with conservative assumption | 224 // Start processing now if connected (but with conservative assumption |
205 // as to other device conditions). | 225 // as to other device conditions). |
206 void StartProcessingIfConnected(); | 226 void StartProcessingIfConnected(); |
207 | 227 |
| 228 OfflinerImmediateStartStatus TryImmediateStart(); |
| 229 |
208 // Check the request queue, and schedule a task corresponding | 230 // Check the request queue, and schedule a task corresponding |
209 // to the least restrictive type of request in the queue. | 231 // to the least restrictive type of request in the queue. |
210 void ScheduleAsNeeded(); | 232 void ScheduleAsNeeded(); |
211 | 233 |
212 // Callback from the request picker when it has chosen our next request. | 234 // Callback from the request picker when it has chosen our next request. |
213 void RequestPicked(const SavePageRequest& request); | 235 void RequestPicked(const SavePageRequest& request); |
214 | 236 |
215 // Callback from the request picker when no more requests are in the queue. | 237 // Callback from the request picker when no more requests are in the queue. |
216 // The parameter is a signal for what (if any) conditions to schedule future | 238 // The parameter is a signal for what (if any) conditions to schedule future |
217 // processing for. | 239 // processing for. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 base::TimeDelta offliner_timeout_; | 341 base::TimeDelta offliner_timeout_; |
320 // Allows us to pass a weak pointer to callbacks. | 342 // Allows us to pass a weak pointer to callbacks. |
321 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 343 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
322 | 344 |
323 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 345 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
324 }; | 346 }; |
325 | 347 |
326 } // namespace offline_pages | 348 } // namespace offline_pages |
327 | 349 |
328 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 350 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
OLD | NEW |