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

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: Fixes tests wrt setting processing state 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 322
321 void SetDeviceConditionsForTest(const DeviceConditions& current_conditions) { 323 void SetDeviceConditionsForTest(const DeviceConditions& current_conditions) {
322 current_conditions_.reset(new DeviceConditions(current_conditions)); 324 current_conditions_.reset(new DeviceConditions(current_conditions));
323 } 325 }
324 326
325 // KeyedService implementation: 327 // KeyedService implementation:
326 void Shutdown() override; 328 void Shutdown() override;
327 329
328 friend class RequestCoordinatorTest; 330 friend class RequestCoordinatorTest;
329 331
332 // Cached value of whether low end device. Overwritable for testing.
333 bool is_low_end_device_;
334
330 // The offliner can only handle one request at a time - if the offliner is 335 // The offliner can only handle one request at a time - if the offliner is
331 // busy, prevent other requests. This flag marks whether the offliner is in 336 // busy, prevent other requests. This flag marks whether the offliner is in
332 // use. 337 // use.
333 bool is_busy_; 338 bool is_busy_;
334 // There is more than one path to start processing so this flag is used 339 // There is more than one path to start processing so this flag is used
335 // to avoid race conditions before is_busy_ is established. 340 // to avoid race conditions before is_busy_ is established.
336 bool is_starting_; 341 bool is_starting_;
337 // Identifies the type of current processing window or if processing stopped. 342 // Identifies the type of current processing window or if processing stopped.
338 ProcessingWindowState processing_state_; 343 ProcessingWindowState processing_state_;
339 // True if we should use the test connection type instead of the actual type. 344 // 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
379 base::Callback<void(bool)> immediate_schedule_callback_; 384 base::Callback<void(bool)> immediate_schedule_callback_;
380 // Allows us to pass a weak pointer to callbacks. 385 // Allows us to pass a weak pointer to callbacks.
381 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 386 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
382 387
383 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 388 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
384 }; 389 };
385 390
386 } // namespace offline_pages 391 } // namespace offline_pages
387 392
388 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 393 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698