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

Side by Side Diff: content/common/throttling_url_loader.cc

Issue 2982363002: Add support for fallback content for the frame. This includes main and subframes. (Closed)
Patch Set: More cleanup Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/common/throttling_url_loader.h" 5 #include "content/common/throttling_url_loader.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (!url_loader_ && !cancelled_by_throttle_) { 96 if (!url_loader_ && !cancelled_by_throttle_) {
97 DCHECK_EQ(DEFERRED_START, deferred_stage_); 97 DCHECK_EQ(DEFERRED_START, deferred_stage_);
98 priority_info_ = 98 priority_info_ =
99 base::MakeUnique<PriorityInfo>(priority, intra_priority_value); 99 base::MakeUnique<PriorityInfo>(priority, intra_priority_value);
100 return; 100 return;
101 } 101 }
102 102
103 url_loader_->SetPriority(priority, intra_priority_value); 103 url_loader_->SetPriority(priority, intra_priority_value);
104 } 104 }
105 105
106 void ThrottlingURLLoader::DisconnectClient() {
107 client_binding_.Close();
108 url_loader_ = nullptr;
109 }
110
106 ThrottlingURLLoader::ThrottlingURLLoader( 111 ThrottlingURLLoader::ThrottlingURLLoader(
107 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles, 112 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles,
108 mojom::URLLoaderClient* client, 113 mojom::URLLoaderClient* client,
109 const net::NetworkTrafficAnnotationTag& traffic_annotation) 114 const net::NetworkTrafficAnnotationTag& traffic_annotation)
110 : forwarding_client_(client), 115 : forwarding_client_(client),
111 client_binding_(this), 116 client_binding_(this),
112 traffic_annotation_(traffic_annotation) { 117 traffic_annotation_(traffic_annotation) {
113 if (throttles.size() > 0) { 118 if (throttles.size() > 0) {
114 // TODO(yzshen): Implement a URLLoaderThrottle subclass which handles a list 119 // TODO(yzshen): Implement a URLLoaderThrottle subclass which handles a list
115 // of URLLoaderThrottles. 120 // of URLLoaderThrottles.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 if (cancelled_by_throttle_) 293 if (cancelled_by_throttle_)
289 return; 294 return;
290 295
291 cancelled_by_throttle_ = true; 296 cancelled_by_throttle_ = true;
292 297
293 ResourceRequestCompletionStatus request_complete_data; 298 ResourceRequestCompletionStatus request_complete_data;
294 request_complete_data.error_code = error_code; 299 request_complete_data.error_code = error_code;
295 request_complete_data.completion_time = base::TimeTicks::Now(); 300 request_complete_data.completion_time = base::TimeTicks::Now();
296 301
297 deferred_stage_ = DEFERRED_NONE; 302 deferred_stage_ = DEFERRED_NONE;
298 client_binding_.Close(); 303 DisconnectClient();
299 url_loader_ = nullptr;
300
301 forwarding_client_->OnComplete(request_complete_data); 304 forwarding_client_->OnComplete(request_complete_data);
302 } 305 }
303 306
304 void ThrottlingURLLoader::Resume() { 307 void ThrottlingURLLoader::Resume() {
305 if (cancelled_by_throttle_ || deferred_stage_ == DEFERRED_NONE) 308 if (cancelled_by_throttle_ || deferred_stage_ == DEFERRED_NONE)
306 return; 309 return;
307 310
308 switch (deferred_stage_) { 311 switch (deferred_stage_) {
309 case DEFERRED_START: { 312 case DEFERRED_START: {
310 StartNow(start_info_->url_loader_factory, start_info_->routing_id, 313 StartNow(start_info_->url_loader_factory, start_info_->routing_id,
(...skipping 22 matching lines...) Expand all
333 break; 336 break;
334 } 337 }
335 default: 338 default:
336 NOTREACHED(); 339 NOTREACHED();
337 break; 340 break;
338 } 341 }
339 deferred_stage_ = DEFERRED_NONE; 342 deferred_stage_ = DEFERRED_NONE;
340 } 343 }
341 344
342 } // namespace content 345 } // namespace content
OLDNEW
« content/common/throttling_url_loader.h ('K') | « content/common/throttling_url_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698