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 <stddef.h> |
7 #include <stdlib.h> | 8 #include <stdlib.h> |
8 | 9 |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/debug/alias.h" | 14 #include "base/debug/alias.h" |
14 #include "base/debug/dump_without_crashing.h" | 15 #include "base/debug/dump_without_crashing.h" |
15 #include "base/debug/stack_trace.h" | 16 #include "base/debug/stack_trace.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" |
17 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
18 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
19 #include "base/metrics/sparse_histogram.h" | 21 #include "base/metrics/sparse_histogram.h" |
20 #include "base/metrics/user_metrics.h" | 22 #include "base/metrics/user_metrics.h" |
21 #include "base/path_service.h" | 23 #include "base/path_service.h" |
22 #include "base/prefs/pref_member.h" | 24 #include "base/prefs/pref_member.h" |
23 #include "base/prefs/pref_service.h" | 25 #include "base/prefs/pref_service.h" |
24 #include "base/profiler/scoped_tracker.h" | 26 #include "base/profiler/scoped_tracker.h" |
25 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/string_util.h" | 28 #include "base/strings/string_util.h" |
27 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 30 #include "build/build_config.h" |
28 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
29 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 32 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
30 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 33 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
31 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 34 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
32 #include "chrome/browser/net/chrome_extensions_network_delegate.h" | 35 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
33 #include "chrome/browser/net/connect_interceptor.h" | 36 #include "chrome/browser/net/connect_interceptor.h" |
34 #include "chrome/browser/net/request_source_bandwidth_histograms.h" | 37 #include "chrome/browser/net/request_source_bandwidth_histograms.h" |
35 #include "chrome/browser/net/safe_search_util.h" | 38 #include "chrome/browser/net/safe_search_util.h" |
36 #include "chrome/browser/profiles/profile_manager.h" | 39 #include "chrome/browser/profiles/profile_manager.h" |
37 #include "chrome/browser/task_management/task_manager_interface.h" | 40 #include "chrome/browser/task_management/task_manager_interface.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (rv == net::OK && new_url->is_empty()) | 109 if (rv == net::OK && new_url->is_empty()) |
107 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 110 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
108 callback.Run(rv); | 111 callback.Run(rv); |
109 } | 112 } |
110 | 113 |
111 #if BUILDFLAG(ANDROID_JAVA_UI) | 114 #if BUILDFLAG(ANDROID_JAVA_UI) |
112 void RecordPrecacheStatsOnUIThread(const GURL& url, | 115 void RecordPrecacheStatsOnUIThread(const GURL& url, |
113 const GURL& referrer, | 116 const GURL& referrer, |
114 base::TimeDelta latency, | 117 base::TimeDelta latency, |
115 const base::Time& fetch_time, | 118 const base::Time& fetch_time, |
116 int64 size, | 119 int64_t size, |
117 bool was_cached, | 120 bool was_cached, |
118 void* profile_id) { | 121 void* profile_id) { |
119 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 122 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
120 | 123 |
121 if (!g_browser_process->profile_manager()->IsValidProfile(profile_id)) | 124 if (!g_browser_process->profile_manager()->IsValidProfile(profile_id)) |
122 return; | 125 return; |
123 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 126 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
124 | 127 |
125 precache::PrecacheManager* precache_manager = | 128 precache::PrecacheManager* precache_manager = |
126 precache::PrecacheManagerFactory::GetForBrowserContext(profile); | 129 precache::PrecacheManagerFactory::GetForBrowserContext(profile); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 state = CACHE_STATE_NO_ENTRY; | 269 state = CACHE_STATE_NO_ENTRY; |
267 } | 270 } |
268 | 271 |
269 UMA_HISTOGRAM_ENUMERATION("Net.CacheState.AllRequests", state, | 272 UMA_HISTOGRAM_ENUMERATION("Net.CacheState.AllRequests", state, |
270 CACHE_STATE_MAX); | 273 CACHE_STATE_MAX); |
271 if (CanRequestBeDeltaEncoded(request)) { | 274 if (CanRequestBeDeltaEncoded(request)) { |
272 UMA_HISTOGRAM_ENUMERATION("Net.CacheState.EncodeableRequests", state, | 275 UMA_HISTOGRAM_ENUMERATION("Net.CacheState.EncodeableRequests", state, |
273 CACHE_STATE_MAX); | 276 CACHE_STATE_MAX); |
274 } | 277 } |
275 | 278 |
276 int64 size = request->received_response_content_length(); | 279 int64_t size = request->received_response_content_length(); |
277 if (size >= 0 && state == CACHE_STATE_NO_LONGER_VALID) { | 280 if (size >= 0 && state == CACHE_STATE_NO_LONGER_VALID) { |
278 UMA_HISTOGRAM_COUNTS("Net.CacheState.AllBytes", size); | 281 UMA_HISTOGRAM_COUNTS("Net.CacheState.AllBytes", size); |
279 if (CanRequestBeDeltaEncoded(request)) { | 282 if (CanRequestBeDeltaEncoded(request)) { |
280 UMA_HISTOGRAM_COUNTS("Net.CacheState.EncodeableBytes", size); | 283 UMA_HISTOGRAM_COUNTS("Net.CacheState.EncodeableBytes", size); |
281 } | 284 } |
282 } | 285 } |
283 } | 286 } |
284 | 287 |
285 } // namespace | 288 } // namespace |
286 | 289 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // that RecordCacheStateStats can only be called on requests for which | 528 // that RecordCacheStateStats can only be called on requests for which |
526 // OnResponseStarted was called. | 529 // OnResponseStarted was called. |
527 RecordCacheStateStats(request); | 530 RecordCacheStateStats(request); |
528 } | 531 } |
529 | 532 |
530 if (request->status().status() == net::URLRequestStatus::SUCCESS) { | 533 if (request->status().status() == net::URLRequestStatus::SUCCESS) { |
531 #if BUILDFLAG(ANDROID_JAVA_UI) | 534 #if BUILDFLAG(ANDROID_JAVA_UI) |
532 // For better accuracy, we use the actual bytes read instead of the length | 535 // For better accuracy, we use the actual bytes read instead of the length |
533 // specified with the Content-Length header, which may be inaccurate, | 536 // specified with the Content-Length header, which may be inaccurate, |
534 // or missing, as is the case with chunked encoding. | 537 // or missing, as is the case with chunked encoding. |
535 int64 received_content_length = request->received_response_content_length(); | 538 int64_t received_content_length = |
| 539 request->received_response_content_length(); |
536 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time(); | 540 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time(); |
537 | 541 |
538 // Record precache metrics when a fetch is completed successfully, if | 542 // Record precache metrics when a fetch is completed successfully, if |
539 // precaching is allowed. | 543 // precaching is allowed. |
540 BrowserThread::PostTask( | 544 BrowserThread::PostTask( |
541 BrowserThread::UI, FROM_HERE, | 545 BrowserThread::UI, FROM_HERE, |
542 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), | 546 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), |
543 GURL(request->referrer()), latency, base::Time::Now(), | 547 GURL(request->referrer()), latency, base::Time::Now(), |
544 received_content_length, request->was_cached(), profile_)); | 548 received_content_length, request->was_cached(), profile_)); |
545 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 549 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 if (!data_use_aggregator_) | 752 if (!data_use_aggregator_) |
749 return; | 753 return; |
750 | 754 |
751 if (is_data_usage_off_the_record_) { | 755 if (is_data_usage_off_the_record_) { |
752 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 756 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
753 return; | 757 return; |
754 } | 758 } |
755 | 759 |
756 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 760 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
757 } | 761 } |
OLD | NEW |