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

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

Issue 2342443006: [Offline pages] Use the new policy bits (Closed)
Patch Set: i think i got it! Made sure it compiles 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // Last known conditions for network, battery 294 // Last known conditions for network, battery
292 std::unique_ptr<DeviceConditions> current_conditions_; 295 std::unique_ptr<DeviceConditions> current_conditions_;
293 // RequestCoordinator takes over ownership of the policy 296 // RequestCoordinator takes over ownership of the policy
294 std::unique_ptr<OfflinerPolicy> policy_; 297 std::unique_ptr<OfflinerPolicy> policy_;
295 // OfflinerFactory. Used to create offline pages. Owned. 298 // OfflinerFactory. Used to create offline pages. Owned.
296 std::unique_ptr<OfflinerFactory> factory_; 299 std::unique_ptr<OfflinerFactory> factory_;
297 // RequestQueue. Used to store incoming requests. Owned. 300 // RequestQueue. Used to store incoming requests. Owned.
298 std::unique_ptr<RequestQueue> queue_; 301 std::unique_ptr<RequestQueue> queue_;
299 // Scheduler. Used to request a callback when network is available. Owned. 302 // Scheduler. Used to request a callback when network is available. Owned.
300 std::unique_ptr<Scheduler> scheduler_; 303 std::unique_ptr<Scheduler> scheduler_;
304 // Controller of client policies. Owned.
305 std::unique_ptr<ClientPolicyController> policy_controller_;
301 // Unowned pointer to the Network Quality Estimator. 306 // Unowned pointer to the Network Quality Estimator.
302 net::NetworkQualityEstimator::NetworkQualityProvider* 307 net::NetworkQualityEstimator::NetworkQualityProvider*
303 network_quality_estimator_; 308 network_quality_estimator_;
304 // Holds copy of the active request, if any. 309 // Holds copy of the active request, if any.
305 std::unique_ptr<SavePageRequest> active_request_; 310 std::unique_ptr<SavePageRequest> active_request_;
306 // Status of the most recent offlining. 311 // Status of the most recent offlining.
307 Offliner::RequestStatus last_offlining_status_; 312 Offliner::RequestStatus last_offlining_status_;
308 // Class to choose which request to schedule next 313 // Class to choose which request to schedule next
309 std::unique_ptr<RequestPicker> picker_; 314 std::unique_ptr<RequestPicker> picker_;
310 // Calling this returns to the scheduler across the JNI bridge. 315 // Calling this returns to the scheduler across the JNI bridge.
311 base::Callback<void(bool)> scheduler_callback_; 316 base::Callback<void(bool)> scheduler_callback_;
312 // Logger to record events. 317 // Logger to record events.
313 RequestCoordinatorEventLogger event_logger_; 318 RequestCoordinatorEventLogger event_logger_;
314 // Timer to watch for pre-render attempts running too long. 319 // Timer to watch for pre-render attempts running too long.
315 base::OneShotTimer watchdog_timer_; 320 base::OneShotTimer watchdog_timer_;
316 // How long to wait for an offliner request before giving up. 321 // How long to wait for an offliner request before giving up.
317 base::TimeDelta offliner_timeout_; 322 base::TimeDelta offliner_timeout_;
318 // Allows us to pass a weak pointer to callbacks. 323 // Allows us to pass a weak pointer to callbacks.
319 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 324 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
320 325
321 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 326 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
322 }; 327 };
323 328
324 } // namespace offline_pages 329 } // namespace offline_pages
325 330
326 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 331 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698