Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: components/offline_pages/background/request_coordinator.h

Issue 2556613003: [OfflinePages] Restarts immediate processing if stopped due to no net (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/supports_user_data.h" 17 #include "base/supports_user_data.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
20 #include "components/keyed_service/core/keyed_service.h" 20 #include "components/keyed_service/core/keyed_service.h"
21 #include "components/offline_pages/background/connection_notifier.h"
21 #include "components/offline_pages/background/device_conditions.h" 22 #include "components/offline_pages/background/device_conditions.h"
22 #include "components/offline_pages/background/offliner.h" 23 #include "components/offline_pages/background/offliner.h"
23 #include "components/offline_pages/background/request_coordinator_event_logger.h " 24 #include "components/offline_pages/background/request_coordinator_event_logger.h "
24 #include "components/offline_pages/background/request_notifier.h" 25 #include "components/offline_pages/background/request_notifier.h"
25 #include "components/offline_pages/background/request_queue.h" 26 #include "components/offline_pages/background/request_queue.h"
26 #include "components/offline_pages/background/scheduler.h" 27 #include "components/offline_pages/background/scheduler.h"
27 #include "net/nqe/network_quality_estimator.h" 28 #include "net/nqe/network_quality_estimator.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
29 30
30 namespace offline_pages { 31 namespace offline_pages {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 bool StartProcessingInternal(const ProcessingWindowState processing_state, 250 bool StartProcessingInternal(const ProcessingWindowState processing_state,
250 const DeviceConditions& device_conditions, 251 const DeviceConditions& device_conditions,
251 const base::Callback<void(bool)>& callback); 252 const base::Callback<void(bool)>& callback);
252 253
253 // Start processing now if connected (but with conservative assumption 254 // Start processing now if connected (but with conservative assumption
254 // as to other device conditions). 255 // as to other device conditions).
255 void StartImmediatelyIfConnected(); 256 void StartImmediatelyIfConnected();
256 257
257 OfflinerImmediateStartStatus TryImmediateStart(); 258 OfflinerImmediateStartStatus TryImmediateStart();
258 259
260 // Requests a callback upon the next network connection to start processing.
261 void RequestConnectedEventForStarting();
262
263 // Clears the request for connected event if it was set.
264 void ClearConnectedEventRequest();
265
266 // Handles receiving a connection event. Will start immediate processing.
267 void HandleConnectedEventForStarting();
268
259 // Check the request queue, and schedule a task corresponding 269 // Check the request queue, and schedule a task corresponding
260 // to the least restrictive type of request in the queue. 270 // to the least restrictive type of request in the queue.
261 void ScheduleAsNeeded(); 271 void ScheduleAsNeeded();
262 272
263 // Callback from the request picker when it has chosen our next request. 273 // Callback from the request picker when it has chosen our next request.
264 void RequestPicked(const SavePageRequest& request); 274 void RequestPicked(const SavePageRequest& request);
265 275
266 // Callback from the request picker when no more requests are in the queue. 276 // Callback from the request picker when no more requests are in the queue.
267 // The parameter is a signal for what (if any) conditions to schedule future 277 // The parameter is a signal for what (if any) conditions to schedule future
268 // processing for. 278 // processing for.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // done with them. 408 // done with them.
399 std::set<int64_t> disabled_requests_; 409 std::set<int64_t> disabled_requests_;
400 // Calling this returns to the scheduler across the JNI bridge. 410 // Calling this returns to the scheduler across the JNI bridge.
401 base::Callback<void(bool)> scheduler_callback_; 411 base::Callback<void(bool)> scheduler_callback_;
402 // Logger to record events. 412 // Logger to record events.
403 RequestCoordinatorEventLogger event_logger_; 413 RequestCoordinatorEventLogger event_logger_;
404 // Timer to watch for pre-render attempts running too long. 414 // Timer to watch for pre-render attempts running too long.
405 base::OneShotTimer watchdog_timer_; 415 base::OneShotTimer watchdog_timer_;
406 // Callback invoked when an immediate request is done (default empty). 416 // Callback invoked when an immediate request is done (default empty).
407 base::Callback<void(bool)> immediate_schedule_callback_; 417 base::Callback<void(bool)> immediate_schedule_callback_;
418 // Used for potential immediate processing when we get network connection.
419 std::unique_ptr<ConnectionNotifier> connection_notifier_;
408 // Allows us to pass a weak pointer to callbacks. 420 // Allows us to pass a weak pointer to callbacks.
409 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 421 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
410 422
411 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 423 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
412 }; 424 };
413 425
414 } // namespace offline_pages 426 } // namespace offline_pages
415 427
416 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 428 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/connection_notifier.cc ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698