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

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 1271733002: [2/3 chromium] Support redirect option of Request and "opaqueredirect" response type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check deffered Created 5 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/loader/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 !ChildProcessSecurityPolicyImpl::GetInstance()-> 273 !ChildProcessSecurityPolicyImpl::GetInstance()->
274 CanRequestURL(info->GetChildID(), redirect_info.new_url)) { 274 CanRequestURL(info->GetChildID(), redirect_info.new_url)) {
275 DVLOG(1) << "Denied unauthorized request for " 275 DVLOG(1) << "Denied unauthorized request for "
276 << redirect_info.new_url.possibly_invalid_spec(); 276 << redirect_info.new_url.possibly_invalid_spec();
277 277
278 // Tell the renderer that this request was disallowed. 278 // Tell the renderer that this request was disallowed.
279 Cancel(); 279 Cancel();
280 return; 280 return;
281 } 281 }
282 282
283 if (info->fetch_redirect_mode() == FETCH_REDIRECT_MODE_ERROR) {
mmenke 2015/08/10 15:52:02 We're going to need unit tests for both these path
horo 2015/08/11 05:58:20 Added ResourceDispatcherHostTest.FetchRedirectMode
284 Cancel();
285 return;
286 } else if (info->fetch_redirect_mode() == FETCH_REDIRECT_MODE_MANUAL) {
287 // TODO(horo): If we will support upload progress events for Fetch API, we
288 // have to call ReportUploadProgress().
mmenke 2015/08/10 15:52:02 This should actually probably be done unconditiona
mmenke 2015/08/10 15:52:02 nit: Move "will" should before "have".
horo 2015/08/11 05:58:20 Done.
horo 2015/08/11 05:58:20 FETCH_REDIRECT_MODE_MANUAL is supported only by Fe
289 CompleteResponseStarted();
mmenke 2015/08/10 15:52:02 Suggest a blank line after CompleteResponseStarted
horo 2015/08/11 05:58:20 Done.
290 // We don't need to read the response body because there is no way to read
291 // the body of opaque-redirect filtered response's internal response.
mmenke 2015/08/10 15:52:02 nit: Don't use "we" in comments.
horo 2015/08/11 05:58:20 Done.
292 // TODO(horo): When we will support any API which expose the internal body,
mmenke 2015/08/10 15:52:02 Is this "when" or "if"?
mmenke 2015/08/10 15:52:02 nit: Move "will" should before "have".
horo 2015/08/11 05:58:20 Done.
horo 2015/08/11 05:58:20 Done.
293 // we have to read the body before calling ResponseCompleted().
mmenke 2015/08/10 15:52:02 Add warning that Cache changes will be needed befo
horo 2015/08/11 05:58:20 Done.
294 if (is_deferred()) {
mmenke 2015/08/10 15:52:02 I'm not following how this is possible.
horo 2015/08/11 05:58:20 Removed and added "DCHECK(!is_deferred())"
295 // If |deferred_stage_| is set while calling CompleteResponseStarted(),
296 // we reset |deferred_stage_| to call ResponseCompleted when resumed.
mmenke 2015/08/10 15:52:02 nit: Don't use "we" in comments.
horo 2015/08/11 05:58:20 Removed.
297 DCHECK(DEFERRED_READ == deferred_stage_);
mmenke 2015/08/10 15:52:02 I'm really not following how this is possible. We
298 deferred_stage_ = DEFERRED_RESPONSE_COMPLETE;
299 return;
300 }
301 ResponseCompleted();
302 return;
303 }
304
283 delegate_->DidReceiveRedirect(this, redirect_info.new_url); 305 delegate_->DidReceiveRedirect(this, redirect_info.new_url);
284 306
285 if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) { 307 if (delegate_->HandleExternalProtocol(this, redirect_info.new_url)) {
286 // The request is complete so we can remove it. 308 // The request is complete so we can remove it.
287 CancelAndIgnore(); 309 CancelAndIgnore();
288 return; 310 return;
289 } 311 }
290 312
291 scoped_refptr<ResourceResponse> response(new ResourceResponse()); 313 scoped_refptr<ResourceResponse> response(new ResourceResponse());
292 PopulateResourceResponse(info, request_.get(), response.get()); 314 PopulateResourceResponse(info, request_.get(), response.get());
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 case net::URLRequestStatus::FAILED: 786 case net::URLRequestStatus::FAILED:
765 status = STATUS_UNDEFINED; 787 status = STATUS_UNDEFINED;
766 break; 788 break;
767 } 789 }
768 790
769 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 791 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
770 } 792 }
771 } 793 }
772 794
773 } // namespace content 795 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698