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

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

Issue 2546433004: [OfflinePages] Restarts immediate processing if stopped due to no net (Closed)
Patch Set: New test method: CallConnectionTypeObserver() 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 bool StartProcessingInternal(const ProcessingWindowState processing_state, 249 bool StartProcessingInternal(const ProcessingWindowState processing_state,
249 const DeviceConditions& device_conditions, 250 const DeviceConditions& device_conditions,
250 const base::Callback<void(bool)>& callback); 251 const base::Callback<void(bool)>& callback);
251 252
252 // Start processing now if connected (but with conservative assumption 253 // Start processing now if connected (but with conservative assumption
253 // as to other device conditions). 254 // as to other device conditions).
254 void StartImmediatelyIfConnected(); 255 void StartImmediatelyIfConnected();
255 256
256 OfflinerImmediateStartStatus TryImmediateStart(); 257 OfflinerImmediateStartStatus TryImmediateStart();
257 258
259 // Requests a callback upon the next network connection to start processing.
260 void RequestConnectedEventForStarting();
261
262 // Clears the request for connected event if it was set.
263 void ClearConnectedEventRequest();
264
265 // Handles receiving a connection event. Will start immediate processing.
266 void HandleConnectedEventForStarting();
267
258 // Check the request queue, and schedule a task corresponding 268 // Check the request queue, and schedule a task corresponding
259 // to the least restrictive type of request in the queue. 269 // to the least restrictive type of request in the queue.
260 void ScheduleAsNeeded(); 270 void ScheduleAsNeeded();
261 271
262 // Callback from the request picker when it has chosen our next request. 272 // Callback from the request picker when it has chosen our next request.
263 void RequestPicked(const SavePageRequest& request); 273 void RequestPicked(const SavePageRequest& request);
264 274
265 // Callback from the request picker when no more requests are in the queue. 275 // Callback from the request picker when no more requests are in the queue.
266 // The parameter is a signal for what (if any) conditions to schedule future 276 // The parameter is a signal for what (if any) conditions to schedule future
267 // processing for. 277 // processing for.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // done with them. 407 // done with them.
398 std::set<int64_t> disabled_requests_; 408 std::set<int64_t> disabled_requests_;
399 // Calling this returns to the scheduler across the JNI bridge. 409 // Calling this returns to the scheduler across the JNI bridge.
400 base::Callback<void(bool)> scheduler_callback_; 410 base::Callback<void(bool)> scheduler_callback_;
401 // Logger to record events. 411 // Logger to record events.
402 RequestCoordinatorEventLogger event_logger_; 412 RequestCoordinatorEventLogger event_logger_;
403 // Timer to watch for pre-render attempts running too long. 413 // Timer to watch for pre-render attempts running too long.
404 base::OneShotTimer watchdog_timer_; 414 base::OneShotTimer watchdog_timer_;
405 // Callback invoked when an immediate request is done (default empty). 415 // Callback invoked when an immediate request is done (default empty).
406 base::Callback<void(bool)> immediate_schedule_callback_; 416 base::Callback<void(bool)> immediate_schedule_callback_;
417 // Used for potential immediate processing when we get network connection.
418 std::unique_ptr<ConnectionNotifier> connection_notifier_;
407 // Allows us to pass a weak pointer to callbacks. 419 // Allows us to pass a weak pointer to callbacks.
408 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 420 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
409 421
410 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 422 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
411 }; 423 };
412 424
413 } // namespace offline_pages 425 } // namespace offline_pages
414 426
415 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 427 #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