Chromium Code Reviews| 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.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/metrics/histogram.h" | |
| 15 #include "base/metrics/stats_counters.h" | 16 #include "base/metrics/stats_counters.h" |
| 16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 18 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
| 19 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
| 20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
| 21 #include "net/base/load_timing_info.h" | 22 #include "net/base/load_timing_info.h" |
| 22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 23 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
| 24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 void URLRequest::set_first_party_for_cookies( | 420 void URLRequest::set_first_party_for_cookies( |
| 420 const GURL& first_party_for_cookies) { | 421 const GURL& first_party_for_cookies) { |
| 421 first_party_for_cookies_ = first_party_for_cookies; | 422 first_party_for_cookies_ = first_party_for_cookies; |
| 422 } | 423 } |
| 423 | 424 |
| 424 void URLRequest::set_method(const std::string& method) { | 425 void URLRequest::set_method(const std::string& method) { |
| 425 DCHECK(!is_pending_); | 426 DCHECK(!is_pending_); |
| 426 method_ = method; | 427 method_ = method; |
| 427 } | 428 } |
| 428 | 429 |
| 429 void URLRequest::set_referrer(const std::string& referrer) { | 430 void URLRequest::SetReferrer(const std::string& referrer) { |
| 430 DCHECK(!is_pending_); | 431 DCHECK(!is_pending_); |
| 431 referrer_ = referrer; | 432 referrer_ = referrer; |
| 432 } | 433 // Ensure that we do not send URL fragment, username and password |
| 433 | 434 // fields in the referrer. |
| 434 GURL URLRequest::GetSanitizedReferrer() const { | 435 GURL referrer_url(referrer); |
| 435 GURL ret(referrer()); | 436 UMA_HISTOGRAM_BOOLEAN("Net.URLRequest_SetReferrer_IsValid", |
| 436 | 437 referrer_url.is_valid()); |
|
mmenke
2013/03/19 19:01:09
An empty referrer URL is presumably not a valid GU
mmenke
2013/03/19 19:01:09
What's the motivation for gathering this informati
mef
2013/03/19 21:40:29
Done.
mef
2013/03/19 21:40:29
The idea is to see how often are invalid urls seen
mmenke
2013/03/20 16:33:51
Sounds reasonable to me.
| |
| 437 // Ensure that we do not send username and password fields in the referrer. | 438 if (referrer_url.is_valid() && (referrer_url.has_ref() || |
| 438 if (ret.has_username() || ret.has_password()) { | 439 referrer_url.has_username() || referrer_url.has_password())) { |
| 439 GURL::Replacements referrer_mods; | 440 GURL::Replacements referrer_mods; |
| 441 referrer_mods.ClearRef(); | |
| 440 referrer_mods.ClearUsername(); | 442 referrer_mods.ClearUsername(); |
| 441 referrer_mods.ClearPassword(); | 443 referrer_mods.ClearPassword(); |
| 442 ret = ret.ReplaceComponents(referrer_mods); | 444 referrer_url = referrer_url.ReplaceComponents(referrer_mods); |
| 445 referrer_ = referrer_url.spec(); | |
| 443 } | 446 } |
| 444 | |
| 445 return ret; | |
| 446 } | 447 } |
| 447 | 448 |
| 448 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { | 449 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { |
| 449 DCHECK(!is_pending_); | 450 DCHECK(!is_pending_); |
| 450 referrer_policy_ = referrer_policy; | 451 referrer_policy_ = referrer_policy; |
| 451 } | 452 } |
| 452 | 453 |
| 453 void URLRequest::set_delegate(Delegate* delegate) { | 454 void URLRequest::set_delegate(Delegate* delegate) { |
| 454 delegate_ = delegate; | 455 delegate_ = delegate; |
| 455 } | 456 } |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 new base::debug::StackTrace(NULL, 0); | 999 new base::debug::StackTrace(NULL, 0); |
| 999 *stack_trace_copy = stack_trace; | 1000 *stack_trace_copy = stack_trace; |
| 1000 stack_trace_.reset(stack_trace_copy); | 1001 stack_trace_.reset(stack_trace_copy); |
| 1001 } | 1002 } |
| 1002 | 1003 |
| 1003 const base::debug::StackTrace* URLRequest::stack_trace() const { | 1004 const base::debug::StackTrace* URLRequest::stack_trace() const { |
| 1004 return stack_trace_.get(); | 1005 return stack_trace_.get(); |
| 1005 } | 1006 } |
| 1006 | 1007 |
| 1007 } // namespace net | 1008 } // namespace net |
| OLD | NEW |