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

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

Issue 2325563003: [Offline Pages] Close race condition of multiple StartProcessing callers. (Closed)
Patch Set: Created 4 years, 3 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 // Returns the status of the most recent offlining. 140 // Returns the status of the most recent offlining.
141 Offliner::RequestStatus last_offlining_status() { 141 Offliner::RequestStatus last_offlining_status() {
142 return last_offlining_status_; 142 return last_offlining_status_;
143 } 143 }
144 144
145 bool is_busy() { 145 bool is_busy() {
146 return is_busy_; 146 return is_busy_;
147 } 147 }
148 148
149 // Returns whether processing is starting (before it is decided to actually
150 // process a request (is_busy()) at this time or not.
151 bool is_starting() { return is_starting_; }
152
149 // Tracks whether the last offlining attempt got canceled. This is reset by 153 // Tracks whether the last offlining attempt got canceled. This is reset by
150 // the next StartProcessing() call. 154 // the next StartProcessing() call.
151 bool is_canceled() { 155 bool is_canceled() {
152 return is_stopped_; 156 return is_stopped_;
153 } 157 }
154 158
155 OfflineEventLogger* GetLogger() { 159 OfflineEventLogger* GetLogger() {
156 return &event_logger_; 160 return &event_logger_;
157 } 161 }
158 162
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 void SetDeviceConditionsForTest(DeviceConditions& current_conditions) { 245 void SetDeviceConditionsForTest(DeviceConditions& current_conditions) {
242 current_conditions_.reset(new DeviceConditions(current_conditions)); 246 current_conditions_.reset(new DeviceConditions(current_conditions));
243 } 247 }
244 248
245 friend class RequestCoordinatorTest; 249 friend class RequestCoordinatorTest;
246 250
247 // The offliner can only handle one request at a time - if the offliner is 251 // The offliner can only handle one request at a time - if the offliner is
248 // busy, prevent other requests. This flag marks whether the offliner is in 252 // busy, prevent other requests. This flag marks whether the offliner is in
249 // use. 253 // use.
250 bool is_busy_; 254 bool is_busy_;
251 // True if the current request has been canceled. 255 // There is more than one path to start processing so this flag is used
256 // to avoid race conditions before is_busy_ is established.
257 bool is_starting_;
258 // True if the current processing window has been canceled.
252 bool is_stopped_; 259 bool is_stopped_;
253 // True if we should use the test connection type instead of the actual type. 260 // True if we should use the test connection type instead of the actual type.
254 bool use_test_connection_type_; 261 bool use_test_connection_type_;
255 // For use by tests, a fake network connection type 262 // For use by tests, a fake network connection type
256 net::NetworkChangeNotifier::ConnectionType test_connection_type_; 263 net::NetworkChangeNotifier::ConnectionType test_connection_type_;
257 // Unowned pointer to the current offliner, if any. 264 // Unowned pointer to the current offliner, if any.
258 Offliner* offliner_; 265 Offliner* offliner_;
259 base::Time operation_start_time_; 266 base::Time operation_start_time_;
260 // The observers. 267 // The observers.
261 base::ObserverList<Observer> observers_; 268 base::ObserverList<Observer> observers_;
(...skipping 23 matching lines...) Expand all
285 base::TimeDelta offliner_timeout_; 292 base::TimeDelta offliner_timeout_;
286 // Allows us to pass a weak pointer to callbacks. 293 // Allows us to pass a weak pointer to callbacks.
287 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 294 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
288 295
289 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 296 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
290 }; 297 };
291 298
292 } // namespace offline_pages 299 } // namespace offline_pages
293 300
294 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 301 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698