| OLD | NEW |
| 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 "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 DCHECK(!is_pending_); | 462 DCHECK(!is_pending_); |
| 463 first_party_for_cookies_ = first_party_for_cookies; | 463 first_party_for_cookies_ = first_party_for_cookies; |
| 464 } | 464 } |
| 465 | 465 |
| 466 void URLRequest::set_first_party_url_policy( | 466 void URLRequest::set_first_party_url_policy( |
| 467 FirstPartyURLPolicy first_party_url_policy) { | 467 FirstPartyURLPolicy first_party_url_policy) { |
| 468 DCHECK(!is_pending_); | 468 DCHECK(!is_pending_); |
| 469 first_party_url_policy_ = first_party_url_policy; | 469 first_party_url_policy_ = first_party_url_policy; |
| 470 } | 470 } |
| 471 | 471 |
| 472 void URLRequest::set_insecure_request_policy( |
| 473 InsecureRequestPolicy insecure_request_policy) { |
| 474 DCHECK(!is_pending_); |
| 475 insecure_request_policy_ = insecure_request_policy; |
| 476 } |
| 477 |
| 472 void URLRequest::set_initiator(const base::Optional<url::Origin>& initiator) { | 478 void URLRequest::set_initiator(const base::Optional<url::Origin>& initiator) { |
| 473 DCHECK(!is_pending_); | 479 DCHECK(!is_pending_); |
| 474 DCHECK(!initiator.has_value() || initiator.value().unique() || | 480 DCHECK(!initiator.has_value() || initiator.value().unique() || |
| 475 initiator.value().GetURL().is_valid()); | 481 initiator.value().GetURL().is_valid()); |
| 476 initiator_ = initiator; | 482 initiator_ = initiator; |
| 477 } | 483 } |
| 478 | 484 |
| 479 void URLRequest::set_method(const std::string& method) { | 485 void URLRequest::set_method(const std::string& method) { |
| 480 DCHECK(!is_pending_); | 486 DCHECK(!is_pending_); |
| 481 method_ = method; | 487 method_ = method; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 NetworkDelegate* network_delegate) | 564 NetworkDelegate* network_delegate) |
| 559 : context_(context), | 565 : context_(context), |
| 560 network_delegate_(network_delegate ? network_delegate | 566 network_delegate_(network_delegate ? network_delegate |
| 561 : context->network_delegate()), | 567 : context->network_delegate()), |
| 562 net_log_(NetLogWithSource::Make(context->net_log(), | 568 net_log_(NetLogWithSource::Make(context->net_log(), |
| 563 NetLogSourceType::URL_REQUEST)), | 569 NetLogSourceType::URL_REQUEST)), |
| 564 url_chain_(1, url), | 570 url_chain_(1, url), |
| 565 method_("GET"), | 571 method_("GET"), |
| 566 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | 572 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), |
| 567 first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL), | 573 first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL), |
| 574 insecure_request_policy_(DO_NOT_UPGRADE_INSECURE_REQUESTS), |
| 568 load_flags_(LOAD_NORMAL), | 575 load_flags_(LOAD_NORMAL), |
| 569 delegate_(delegate), | 576 delegate_(delegate), |
| 570 status_(URLRequestStatus::FromError(OK)), | 577 status_(URLRequestStatus::FromError(OK)), |
| 571 is_pending_(false), | 578 is_pending_(false), |
| 572 is_redirecting_(false), | 579 is_redirecting_(false), |
| 573 redirect_limit_(kMaxRedirects), | 580 redirect_limit_(kMaxRedirects), |
| 574 priority_(priority), | 581 priority_(priority), |
| 575 identifier_(GenerateURLRequestIdentifier()), | 582 identifier_(GenerateURLRequestIdentifier()), |
| 576 calling_delegate_(false), | 583 calling_delegate_(false), |
| 577 use_blocked_by_as_load_param_(false), | 584 use_blocked_by_as_load_param_(false), |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 | 913 |
| 907 load_timing_info_ = LoadTimingInfo(); | 914 load_timing_info_ = LoadTimingInfo(); |
| 908 load_timing_info_.request_start_time = response_info_.request_time; | 915 load_timing_info_.request_start_time = response_info_.request_time; |
| 909 load_timing_info_.request_start = base::TimeTicks::Now(); | 916 load_timing_info_.request_start = base::TimeTicks::Now(); |
| 910 | 917 |
| 911 status_ = URLRequestStatus(); | 918 status_ = URLRequestStatus(); |
| 912 is_pending_ = false; | 919 is_pending_ = false; |
| 913 proxy_server_ = ProxyServer(); | 920 proxy_server_ = ProxyServer(); |
| 914 } | 921 } |
| 915 | 922 |
| 923 void URLRequest::RewriteURL(const GURL& url, const std::string& reason) { |
| 924 if (net_log_.IsCapturing()) { |
| 925 net_log_.AddEvent( |
| 926 NetLogEventType::URL_REQUEST_REWRITTEN, |
| 927 NetLog::StringCallback("reason", &reason)); |
| 928 } |
| 929 |
| 930 url_chain_.push_back(url); |
| 931 } |
| 932 |
| 916 int URLRequest::Redirect(const RedirectInfo& redirect_info) { | 933 int URLRequest::Redirect(const RedirectInfo& redirect_info) { |
| 917 // Matches call in NotifyReceivedRedirect. | 934 // Matches call in NotifyReceivedRedirect. |
| 918 OnCallToDelegateComplete(); | 935 OnCallToDelegateComplete(); |
| 919 if (net_log_.IsCapturing()) { | 936 if (net_log_.IsCapturing()) { |
| 920 net_log_.AddEvent( | 937 net_log_.AddEvent( |
| 921 NetLogEventType::URL_REQUEST_REDIRECTED, | 938 NetLogEventType::URL_REQUEST_REDIRECTED, |
| 922 NetLog::StringCallback("location", | 939 NetLog::StringCallback("location", |
| 923 &redirect_info.new_url.possibly_invalid_spec())); | 940 &redirect_info.new_url.possibly_invalid_spec())); |
| 924 } | 941 } |
| 925 | 942 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 out->clear(); | 1231 out->clear(); |
| 1215 } | 1232 } |
| 1216 | 1233 |
| 1217 void URLRequest::set_status(URLRequestStatus status) { | 1234 void URLRequest::set_status(URLRequestStatus status) { |
| 1218 DCHECK(status_.is_io_pending() || status_.is_success() || | 1235 DCHECK(status_.is_io_pending() || status_.is_success() || |
| 1219 (!status.is_success() && !status.is_io_pending())); | 1236 (!status.is_success() && !status.is_io_pending())); |
| 1220 status_ = status; | 1237 status_ = status; |
| 1221 } | 1238 } |
| 1222 | 1239 |
| 1223 } // namespace net | 1240 } // namespace net |
| OLD | NEW |