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

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

Issue 2431193003: [Offline Pages] Defines longer processing budget for immediate bg loads. (Closed)
Patch Set: Fix merge issue 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 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 // A way to set the callback which would be called if the request will be 140 // A way to set the callback which would be called if the request will be
141 // scheduled immediately. Used by testing harness to determine if a request 141 // scheduled immediately. Used by testing harness to determine if a request
142 // has been processed. 142 // has been processed.
143 void SetImmediateScheduleCallbackForTest( 143 void SetImmediateScheduleCallbackForTest(
144 const base::Callback<void(bool)> callback) { 144 const base::Callback<void(bool)> callback) {
145 immediate_schedule_callback_ = callback; 145 immediate_schedule_callback_ = callback;
146 } 146 }
147 147
148 void StartImmediatelyForTest() { StartImmediatelyIfConnected(); }
149
148 // Observers implementing the RequestCoordinator::Observer interface can 150 // Observers implementing the RequestCoordinator::Observer interface can
149 // register here to get notifications of changes to request state. This 151 // register here to get notifications of changes to request state. This
150 // pointer is not owned, and it is the callers responsibility to remove the 152 // pointer is not owned, and it is the callers responsibility to remove the
151 // observer before the observer is deleted. 153 // observer before the observer is deleted.
152 void AddObserver(RequestCoordinator::Observer* observer); 154 void AddObserver(RequestCoordinator::Observer* observer);
153 155
154 void RemoveObserver(RequestCoordinator::Observer* observer); 156 void RemoveObserver(RequestCoordinator::Observer* observer);
155 157
156 // Implement RequestNotifier 158 // Implement RequestNotifier
157 void NotifyAdded(const SavePageRequest& request) override; 159 void NotifyAdded(const SavePageRequest& request) override;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 334
333 void SetDeviceConditionsForTest(const DeviceConditions& current_conditions) { 335 void SetDeviceConditionsForTest(const DeviceConditions& current_conditions) {
334 current_conditions_.reset(new DeviceConditions(current_conditions)); 336 current_conditions_.reset(new DeviceConditions(current_conditions));
335 } 337 }
336 338
337 // KeyedService implementation: 339 // KeyedService implementation:
338 void Shutdown() override; 340 void Shutdown() override;
339 341
340 friend class RequestCoordinatorTest; 342 friend class RequestCoordinatorTest;
341 343
344 // Cached value of whether low end device. Overwritable for testing.
345 bool is_low_end_device_;
346
342 // The offliner can only handle one request at a time - if the offliner is 347 // The offliner can only handle one request at a time - if the offliner is
343 // busy, prevent other requests. This flag marks whether the offliner is in 348 // busy, prevent other requests. This flag marks whether the offliner is in
344 // use. 349 // use.
345 bool is_busy_; 350 bool is_busy_;
346 // There is more than one path to start processing so this flag is used 351 // There is more than one path to start processing so this flag is used
347 // to avoid race conditions before is_busy_ is established. 352 // to avoid race conditions before is_busy_ is established.
348 bool is_starting_; 353 bool is_starting_;
349 // Identifies the type of current processing window or if processing stopped. 354 // Identifies the type of current processing window or if processing stopped.
350 ProcessingWindowState processing_state_; 355 ProcessingWindowState processing_state_;
351 // True if we should use the test connection type instead of the actual type. 356 // True if we should use the test connection type instead of the actual type.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 base::Callback<void(bool)> immediate_schedule_callback_; 396 base::Callback<void(bool)> immediate_schedule_callback_;
392 // Allows us to pass a weak pointer to callbacks. 397 // Allows us to pass a weak pointer to callbacks.
393 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 398 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
394 399
395 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 400 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
396 }; 401 };
397 402
398 } // namespace offline_pages 403 } // namespace offline_pages
399 404
400 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 405 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/offliner_policy.h ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698