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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 2230173002: Change WebURLLoaderClient::willFollowRedirect() API to return bool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed jochen's point 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <openssl/ssl.h> 7 #include <openssl/ssl.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 request_.reportRawHeaders()); 633 request_.reportRawHeaders());
634 634
635 WebURLRequest new_request; 635 WebURLRequest new_request;
636 PopulateURLRequestForRedirect( 636 PopulateURLRequestForRedirect(
637 request_, redirect_info, referrer_policy_, 637 request_, redirect_info, referrer_policy_,
638 info.was_fetched_via_service_worker 638 info.was_fetched_via_service_worker
639 ? blink::WebURLRequest::SkipServiceWorker::None 639 ? blink::WebURLRequest::SkipServiceWorker::None
640 : blink::WebURLRequest::SkipServiceWorker::All, 640 : blink::WebURLRequest::SkipServiceWorker::All,
641 &new_request); 641 &new_request);
642 642
643 client_->willFollowRedirect(loader_, new_request, response, 643 bool follow = client_->willFollowRedirect(loader_, new_request, response,
644 info.encoded_data_length); 644 info.encoded_data_length);
645 request_ = new_request; 645 if (follow) {
jochen (gone - plz use gerrit) 2016/09/30 11:11:24 maybe just early exist if !follow here?
tyoshino (SeeGerritForStatus) 2016/10/04 04:02:25 Yeah. Done
646 request_ = new_request;
646 647
647 // Only follow the redirect if WebKit left the URL unmodified.
648 if (redirect_info.new_url == GURL(new_request.url())) {
jochen (gone - plz use gerrit) 2016/09/30 11:11:24 can we DCHECK() that redirect_info.new_url == new_
tyoshino (SeeGerritForStatus) 2016/10/04 04:02:24 Added
649 // First-party cookie logic moved from DocumentLoader in Blink to 648 // First-party cookie logic moved from DocumentLoader in Blink to
650 // net::URLRequest in the browser. Assert that Blink didn't try to change it 649 // net::URLRequest in the browser. Assert that Blink didn't try to change it
651 // to something else. 650 // to something else.
652 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), 651 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
653 request_.firstPartyForCookies().string().utf8()); 652 request_.firstPartyForCookies().string().utf8());
654 return true; 653 return true;
655 } 654 }
656 655
657 // We assume that WebKit only changes the URL to suppress a redirect, and we 656 request_ = WebURLRequest();
658 // assume that it does so by setting it to be invalid. 657
659 DCHECK(!new_request.url().isValid());
660 return false; 658 return false;
661 } 659 }
662 660
663 void WebURLLoaderImpl::Context::OnReceivedResponse( 661 void WebURLLoaderImpl::Context::OnReceivedResponse(
664 const ResourceResponseInfo& initial_info) { 662 const ResourceResponseInfo& initial_info) {
665 if (!client_) 663 if (!client_)
666 return; 664 return;
667 665
668 TRACE_EVENT_WITH_FLOW0( 666 TRACE_EVENT_WITH_FLOW0(
669 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse", 667 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse",
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 response->clearHTTPHeaderField(webStringName); 1249 response->clearHTTPHeaderField(webStringName);
1252 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1250 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1253 response->addHTTPHeaderField(webStringName, 1251 response->addHTTPHeaderField(webStringName,
1254 WebString::fromLatin1(value)); 1252 WebString::fromLatin1(value));
1255 } 1253 }
1256 } 1254 }
1257 return true; 1255 return true;
1258 } 1256 }
1259 1257
1260 } // namespace content 1258 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698