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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/debug/stack_trace.h" | 11 #include "base/debug/stack_trace.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/stats_counters.h" | 15 #include "base/metrics/stats_counters.h" |
16 #include "base/metrics/user_metrics.h" | |
17 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
19 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
20 #include "base/values.h" | 19 #include "base/values.h" |
21 #include "net/base/auth.h" | 20 #include "net/base/auth.h" |
22 #include "net/base/host_port_pair.h" | 21 #include "net/base/host_port_pair.h" |
23 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
24 #include "net/base/load_timing_info.h" | 23 #include "net/base/load_timing_info.h" |
25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
26 #include "net/base/net_log.h" | 25 #include "net/base/net_log.h" |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 is_redirecting_ = false; | 683 is_redirecting_ = false; |
685 | 684 |
686 response_info_.was_cached = false; | 685 response_info_.was_cached = false; |
687 | 686 |
688 // If the referrer is secure, but the requested URL is not, the referrer | 687 // If the referrer is secure, but the requested URL is not, the referrer |
689 // policy should be something non-default. If you hit this, please file a | 688 // policy should be something non-default. If you hit this, please file a |
690 // bug. | 689 // bug. |
691 if (referrer_policy_ == | 690 if (referrer_policy_ == |
692 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE && | 691 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE && |
693 GURL(referrer_).SchemeIsSecure() && !url().SchemeIsSecure()) { | 692 GURL(referrer_).SchemeIsSecure() && !url().SchemeIsSecure()) { |
694 #if !defined(OFFICIAL_BUILD) | 693 if (!network_delegate_ || |
695 LOG(FATAL) << "Trying to send secure referrer for insecure load"; | 694 network_delegate_->CanCorrectInvalidReferrerHeader( |
mmenke
2014/09/16 15:05:42
I think this function name isn't clear. We only c
jochen (gone - plz use gerrit)
2014/09/16 16:27:57
That's not correct. The transition happens here: U
mmenke
2014/09/16 16:37:15
Ahh... I think that's not at all clear from the s
| |
696 #endif | 695 *this, url(), GURL(referrer_))) { |
697 referrer_.clear(); | 696 referrer_.clear(); |
698 base::RecordAction( | 697 } else { |
699 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); | 698 // We need to clear the referrer anyway to avoid an infinite recursion |
699 // when starting the error job. | |
mmenke
2014/09/16 15:05:42
nit: Don't use "we" in comments.
| |
700 referrer_.clear(); | |
701 std::string source("delegate"); | |
702 net_log_.AddEvent(NetLog::TYPE_CANCELLED, | |
703 NetLog::StringCallback("source", &source)); | |
704 RestartWithJob(new URLRequestErrorJob( | |
705 this, network_delegate_, ERR_BLOCKED_BY_CLIENT)); | |
706 return; | |
707 } | |
700 } | 708 } |
701 | 709 |
702 // Don't allow errors to be sent from within Start(). | 710 // Don't allow errors to be sent from within Start(). |
703 // TODO(brettw) this may cause NotifyDone to be sent synchronously, | 711 // TODO(brettw) this may cause NotifyDone to be sent synchronously, |
704 // we probably don't want this: they should be sent asynchronously so | 712 // we probably don't want this: they should be sent asynchronously so |
705 // the caller does not get reentered. | 713 // the caller does not get reentered. |
706 job_->Start(); | 714 job_->Start(); |
707 } | 715 } |
708 | 716 |
709 void URLRequest::Restart() { | 717 void URLRequest::Restart() { |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 new base::debug::StackTrace(NULL, 0); | 1228 new base::debug::StackTrace(NULL, 0); |
1221 *stack_trace_copy = stack_trace; | 1229 *stack_trace_copy = stack_trace; |
1222 stack_trace_.reset(stack_trace_copy); | 1230 stack_trace_.reset(stack_trace_copy); |
1223 } | 1231 } |
1224 | 1232 |
1225 const base::debug::StackTrace* URLRequest::stack_trace() const { | 1233 const base::debug::StackTrace* URLRequest::stack_trace() const { |
1226 return stack_trace_.get(); | 1234 return stack_trace_.get(); |
1227 } | 1235 } |
1228 | 1236 |
1229 } // namespace net | 1237 } // namespace net |
OLD | NEW |