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

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

Issue 2342443006: [Offline pages] Use the new policy bits (Closed)
Patch Set: fix download bridge and ntp suggestions to use correct policy controller Created 4 years, 2 months 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 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 15 matching lines...) Expand all
26 26
27 namespace offline_pages { 27 namespace offline_pages {
28 28
29 struct ClientId; 29 struct ClientId;
30 class OfflinerPolicy; 30 class OfflinerPolicy;
31 class OfflinerFactory; 31 class OfflinerFactory;
32 class Offliner; 32 class Offliner;
33 class RequestPicker; 33 class RequestPicker;
34 class SavePageRequest; 34 class SavePageRequest;
35 class Scheduler; 35 class Scheduler;
36 class ClientPolicyController;
36 37
37 // Coordinates queueing and processing save page later requests. 38 // Coordinates queueing and processing save page later requests.
38 class RequestCoordinator : public KeyedService, 39 class RequestCoordinator : public KeyedService,
39 public RequestNotifier, 40 public RequestNotifier,
40 public base::SupportsUserData { 41 public base::SupportsUserData {
41 public: 42 public:
42 43
43 // Nested observer class. To make sure that no events are missed, the client 44 // Nested observer class. To make sure that no events are missed, the client
44 // code should first register for notifications, then |GetAllRequests|, and 45 // code should first register for notifications, then |GetAllRequests|, and
45 // ignore all events before the return from |GetAllRequests|, and consume 46 // ignore all events before the return from |GetAllRequests|, and consume
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 void NotifyChanged(const SavePageRequest& request) override; 136 void NotifyChanged(const SavePageRequest& request) override;
136 137
137 // Returns the request queue used for requests. Coordinator keeps ownership. 138 // Returns the request queue used for requests. Coordinator keeps ownership.
138 RequestQueue* queue() { return queue_.get(); } 139 RequestQueue* queue() { return queue_.get(); }
139 140
140 // Return an unowned pointer to the Scheduler. 141 // Return an unowned pointer to the Scheduler.
141 Scheduler* scheduler() { return scheduler_.get(); } 142 Scheduler* scheduler() { return scheduler_.get(); }
142 143
143 OfflinerPolicy* policy() { return policy_.get(); } 144 OfflinerPolicy* policy() { return policy_.get(); }
144 145
146 ClientPolicyController* GetPolicyController();
147
145 // Returns the status of the most recent offlining. 148 // Returns the status of the most recent offlining.
146 Offliner::RequestStatus last_offlining_status() { 149 Offliner::RequestStatus last_offlining_status() {
147 return last_offlining_status_; 150 return last_offlining_status_;
148 } 151 }
149 152
150 bool is_busy() { 153 bool is_busy() {
151 return is_busy_; 154 return is_busy_;
152 } 155 }
153 156
154 // Returns whether processing is starting (before it is decided to actually 157 // Returns whether processing is starting (before it is decided to actually
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // Last known conditions for network, battery 297 // Last known conditions for network, battery
295 std::unique_ptr<DeviceConditions> current_conditions_; 298 std::unique_ptr<DeviceConditions> current_conditions_;
296 // RequestCoordinator takes over ownership of the policy 299 // RequestCoordinator takes over ownership of the policy
297 std::unique_ptr<OfflinerPolicy> policy_; 300 std::unique_ptr<OfflinerPolicy> policy_;
298 // OfflinerFactory. Used to create offline pages. Owned. 301 // OfflinerFactory. Used to create offline pages. Owned.
299 std::unique_ptr<OfflinerFactory> factory_; 302 std::unique_ptr<OfflinerFactory> factory_;
300 // RequestQueue. Used to store incoming requests. Owned. 303 // RequestQueue. Used to store incoming requests. Owned.
301 std::unique_ptr<RequestQueue> queue_; 304 std::unique_ptr<RequestQueue> queue_;
302 // Scheduler. Used to request a callback when network is available. Owned. 305 // Scheduler. Used to request a callback when network is available. Owned.
303 std::unique_ptr<Scheduler> scheduler_; 306 std::unique_ptr<Scheduler> scheduler_;
307 // Controller of client policies. Owned.
308 std::unique_ptr<ClientPolicyController> policy_controller_;
304 // Unowned pointer to the Network Quality Estimator. 309 // Unowned pointer to the Network Quality Estimator.
305 net::NetworkQualityEstimator::NetworkQualityProvider* 310 net::NetworkQualityEstimator::NetworkQualityProvider*
306 network_quality_estimator_; 311 network_quality_estimator_;
307 // Holds copy of the active request, if any. 312 // Holds copy of the active request, if any.
308 std::unique_ptr<SavePageRequest> active_request_; 313 std::unique_ptr<SavePageRequest> active_request_;
309 // Status of the most recent offlining. 314 // Status of the most recent offlining.
310 Offliner::RequestStatus last_offlining_status_; 315 Offliner::RequestStatus last_offlining_status_;
311 // Class to choose which request to schedule next 316 // Class to choose which request to schedule next
312 std::unique_ptr<RequestPicker> picker_; 317 std::unique_ptr<RequestPicker> picker_;
313 // Calling this returns to the scheduler across the JNI bridge. 318 // Calling this returns to the scheduler across the JNI bridge.
314 base::Callback<void(bool)> scheduler_callback_; 319 base::Callback<void(bool)> scheduler_callback_;
315 // Logger to record events. 320 // Logger to record events.
316 RequestCoordinatorEventLogger event_logger_; 321 RequestCoordinatorEventLogger event_logger_;
317 // Timer to watch for pre-render attempts running too long. 322 // Timer to watch for pre-render attempts running too long.
318 base::OneShotTimer watchdog_timer_; 323 base::OneShotTimer watchdog_timer_;
319 // How long to wait for an offliner request before giving up. 324 // How long to wait for an offliner request before giving up.
320 base::TimeDelta offliner_timeout_; 325 base::TimeDelta offliner_timeout_;
321 // Allows us to pass a weak pointer to callbacks. 326 // Allows us to pass a weak pointer to callbacks.
322 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 327 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
323 328
324 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 329 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
325 }; 330 };
326 331
327 } // namespace offline_pages 332 } // namespace offline_pages
328 333
329 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 334 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698