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 "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
| 12 #include "base/debug/alias.h" | |
| 12 #include "base/debug/dump_without_crashing.h" | 13 #include "base/debug/dump_without_crashing.h" |
| 14 #include "base/debug/stack_trace.h" | |
| 13 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 16 #include "base/metrics/user_metrics.h" | 18 #include "base/metrics/user_metrics.h" |
| 17 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 18 #include "base/prefs/pref_member.h" | 20 #include "base/prefs/pref_member.h" |
| 19 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 22 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 void RecordIOThreadToRequestStartOnUIThread( | 222 void RecordIOThreadToRequestStartOnUIThread( |
| 221 const base::TimeTicks& request_start) { | 223 const base::TimeTicks& request_start) { |
| 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 223 base::TimeDelta request_lag = request_start - | 225 base::TimeDelta request_lag = request_start - |
| 224 g_browser_process->io_thread()->creation_time(); | 226 g_browser_process->io_thread()->creation_time(); |
| 225 UMA_HISTOGRAM_TIMES("Net.IOThreadCreationToHTTPRequestStart", request_lag); | 227 UMA_HISTOGRAM_TIMES("Net.IOThreadCreationToHTTPRequestStart", request_lag); |
| 226 } | 228 } |
| 227 #endif // defined(OS_ANDROID) | 229 #endif // defined(OS_ANDROID) |
| 228 | 230 |
| 229 void ReportInvalidReferrerSend(const GURL& target_url, | 231 void ReportInvalidReferrerSend(const GURL& target_url, |
| 230 const GURL& referrer_url) { | 232 const GURL& referrer_url, |
| 233 const base::debug::StackTrace& callstack) { | |
|
mmenke
2014/11/10 15:14:29
Maybe add a comment with the bug ID?
| |
| 234 base::debug::StackTrace trace = callstack; | |
| 235 base::debug::Alias(&trace); | |
| 236 enum { INVALID_URL, FILE_URL, DATA_URL, HTTP_URL, OTHER } reason = OTHER; | |
| 237 if (!target_url.is_valid()) | |
| 238 reason = INVALID_URL; | |
| 239 else if (target_url.SchemeIsFile()) | |
| 240 reason = FILE_URL; | |
| 241 else if (target_url.SchemeIs(url::kDataScheme)) | |
| 242 reason = DATA_URL; | |
| 243 else if (target_url.SchemeIs(url::kHttpScheme)) | |
| 244 reason = HTTP_URL; | |
| 245 base::debug::Alias(&reason); | |
| 231 base::RecordAction( | 246 base::RecordAction( |
| 232 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); | 247 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); |
| 233 base::debug::DumpWithoutCrashing(); | 248 base::debug::DumpWithoutCrashing(); |
| 234 NOTREACHED(); | 249 NOTREACHED(); |
| 235 } | 250 } |
| 236 | 251 |
| 237 } // namespace | 252 } // namespace |
| 238 | 253 |
| 239 ChromeNetworkDelegate::ChromeNetworkDelegate( | 254 ChromeNetworkDelegate::ChromeNetworkDelegate( |
| 240 extensions::EventRouterForwarder* event_router, | 255 extensions::EventRouterForwarder* event_router, |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed( | 800 bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed( |
| 786 url, first_party_for_cookies); | 801 url, first_party_for_cookies); |
| 787 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed); | 802 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed); |
| 788 return privacy_mode; | 803 return privacy_mode; |
| 789 } | 804 } |
| 790 | 805 |
| 791 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 806 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
| 792 const net::URLRequest& request, | 807 const net::URLRequest& request, |
| 793 const GURL& target_url, | 808 const GURL& target_url, |
| 794 const GURL& referrer_url) const { | 809 const GURL& referrer_url) const { |
| 810 base::debug::StackTrace callstack; | |
| 795 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 811 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 796 base::Bind(&ReportInvalidReferrerSend, target_url, referrer_url)); | 812 base::Bind(&ReportInvalidReferrerSend, target_url, |
| 813 referrer_url, callstack)); | |
| 797 return true; | 814 return true; |
| 798 } | 815 } |
| 799 | 816 |
| 800 void ChromeNetworkDelegate::AccumulateContentLength( | 817 void ChromeNetworkDelegate::AccumulateContentLength( |
| 801 int64 received_content_length, | 818 int64 received_content_length, |
| 802 int64 original_content_length, | 819 int64 original_content_length, |
| 803 data_reduction_proxy::DataReductionProxyRequestType request_type) { | 820 data_reduction_proxy::DataReductionProxyRequestType request_type) { |
| 804 DCHECK_GE(received_content_length, 0); | 821 DCHECK_GE(received_content_length, 0); |
| 805 DCHECK_GE(original_content_length, 0); | 822 DCHECK_GE(original_content_length, 0); |
| 806 if (data_reduction_proxy_statistics_prefs_) { | 823 if (data_reduction_proxy_statistics_prefs_) { |
| 807 StoreAccumulatedContentLength(received_content_length, | 824 StoreAccumulatedContentLength(received_content_length, |
| 808 original_content_length, | 825 original_content_length, |
| 809 request_type, | 826 request_type, |
| 810 reinterpret_cast<Profile*>(profile_), | 827 reinterpret_cast<Profile*>(profile_), |
| 811 data_reduction_proxy_statistics_prefs_); | 828 data_reduction_proxy_statistics_prefs_); |
| 812 } | 829 } |
| 813 received_content_length_ += received_content_length; | 830 received_content_length_ += received_content_length; |
| 814 original_content_length_ += original_content_length; | 831 original_content_length_ += original_content_length; |
| 815 } | 832 } |
| OLD | NEW |