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

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

Issue 2493683002: [OfflinePages] Fixes RequestCoordinator bug not clearing state on timeout (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/offline_pages/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 RequestQueue::GetRequestsResult result, 234 RequestQueue::GetRequestsResult result,
235 std::vector<std::unique_ptr<SavePageRequest>> requests) { 235 std::vector<std::unique_ptr<SavePageRequest>> requests) {
236 callback.Run(std::move(requests)); 236 callback.Run(std::move(requests));
237 } 237 }
238 238
239 void RequestCoordinator::StopPrerendering(Offliner::RequestStatus stop_status) { 239 void RequestCoordinator::StopPrerendering(Offliner::RequestStatus stop_status) {
240 if (offliner_ && is_busy_) { 240 if (offliner_ && is_busy_) {
241 DCHECK(active_request_.get()); 241 DCHECK(active_request_.get());
242 offliner_->Cancel(); 242 offliner_->Cancel();
243 243
244 // If we timed out, let the offliner done callback handle it. 244 if (stop_status != Offliner::RequestStatus::REQUEST_COORDINATOR_TIMED_OUT) {
245 if (stop_status == Offliner::RequestStatus::REQUEST_COORDINATOR_TIMED_OUT) 245 // Since not a timeout, consider that the current attempt never had a
246 return; 246 // chance to complete, mark it aborted.
247 247 AbortRequestAttempt(active_request_.get());
Pete Williamson 2016/11/10 01:03:30 When we get a timeout like this, we should get the
dougarnett 2016/11/10 16:38:38 Offliner::Cancel contract is to not call the callb
Pete Williamson 2016/11/10 19:01:29 OK, in that case, it is my misunderstanding of the
248 // Otherwise, this attempt never really had a chance to run, mark it 248 }
249 // aborted.
250 AbortRequestAttempt(active_request_.get());
251 } 249 }
252 250
253 // Stopping offliner means it will not call callback so set last status. 251 // Stopping offliner means it will not call callback so set last status.
254 last_offlining_status_ = stop_status; 252 last_offlining_status_ = stop_status;
255 253
256 if (active_request_) { 254 if (active_request_) {
257 event_logger_.RecordOfflinerResult(active_request_->client_id().name_space, 255 event_logger_.RecordOfflinerResult(active_request_->client_id().name_space,
258 last_offlining_status_, 256 last_offlining_status_,
259 active_request_->request_id()); 257 active_request_->request_id());
260 RecordOfflinerResultUMA(active_request_->client_id(), 258 RecordOfflinerResultUMA(active_request_->client_id(),
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 867
870 ClientPolicyController* RequestCoordinator::GetPolicyController() { 868 ClientPolicyController* RequestCoordinator::GetPolicyController() {
871 return policy_controller_.get(); 869 return policy_controller_.get();
872 } 870 }
873 871
874 void RequestCoordinator::Shutdown() { 872 void RequestCoordinator::Shutdown() {
875 network_quality_estimator_ = nullptr; 873 network_quality_estimator_ = nullptr;
876 } 874 }
877 875
878 } // namespace offline_pages 876 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698