| 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 <stddef.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/net/chrome_extensions_network_delegate.h" | 33 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
| 34 #include "chrome/browser/net/request_source_bandwidth_histograms.h" | 34 #include "chrome/browser/net/request_source_bandwidth_histograms.h" |
| 35 #include "chrome/browser/net/safe_search_util.h" | 35 #include "chrome/browser/net/safe_search_util.h" |
| 36 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
| 37 #include "chrome/browser/task_management/task_manager_interface.h" | 37 #include "chrome/browser/task_management/task_manager_interface.h" |
| 38 #include "chrome/common/chrome_constants.h" | 38 #include "chrome/common/chrome_constants.h" |
| 39 #include "chrome/common/features.h" | 39 #include "chrome/common/features.h" |
| 40 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 41 #include "components/content_settings/core/browser/cookie_settings.h" | 41 #include "components/content_settings/core/browser/cookie_settings.h" |
| 42 #include "components/data_usage/core/data_use_aggregator.h" | 42 #include "components/data_usage/core/data_use_aggregator.h" |
| 43 #include "components/data_use_measurement/content/data_use_measurement.h" |
| 43 #include "components/domain_reliability/monitor.h" | 44 #include "components/domain_reliability/monitor.h" |
| 44 #include "components/policy/core/browser/url_blacklist_manager.h" | 45 #include "components/policy/core/browser/url_blacklist_manager.h" |
| 45 #include "components/prefs/pref_member.h" | 46 #include "components/prefs/pref_member.h" |
| 46 #include "components/prefs/pref_service.h" | 47 #include "components/prefs/pref_service.h" |
| 47 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 48 #include "content/public/browser/render_frame_host.h" | 49 #include "content/public/browser/render_frame_host.h" |
| 49 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
| 50 #include "content/public/browser/resource_request_info.h" | 51 #include "content/public/browser/resource_request_info.h" |
| 51 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
| 52 #include "content/public/common/process_type.h" | 53 #include "content/public/common/process_type.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 const net::CompletionCallback& callback, | 102 const net::CompletionCallback& callback, |
| 102 net::URLRequest* request, | 103 net::URLRequest* request, |
| 103 GURL* new_url, | 104 GURL* new_url, |
| 104 int rv) { | 105 int rv) { |
| 105 if (rv == net::OK && new_url->is_empty()) | 106 if (rv == net::OK && new_url->is_empty()) |
| 106 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 107 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
| 107 callback.Run(rv); | 108 callback.Run(rv); |
| 108 } | 109 } |
| 109 | 110 |
| 110 #if BUILDFLAG(ANDROID_JAVA_UI) | 111 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 111 void RecordPrecacheStatsOnUIThread(const GURL& url, | 112 void UpdatePrecacheMetricsAndStateOnUIThread(const GURL& url, |
| 112 const GURL& referrer, | 113 const GURL& referrer, |
| 113 base::TimeDelta latency, | 114 base::TimeDelta latency, |
| 114 const base::Time& fetch_time, | 115 const base::Time& fetch_time, |
| 115 int64_t size, | 116 int64_t size, |
| 116 bool was_cached, | 117 bool was_cached, |
| 117 void* profile_id) { | 118 bool is_user_traffic, |
| 119 void* profile_id) { |
| 118 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 120 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 119 | 121 |
| 120 if (!g_browser_process->profile_manager()->IsValidProfile(profile_id)) | 122 if (!g_browser_process->profile_manager()->IsValidProfile(profile_id)) |
| 121 return; | 123 return; |
| 122 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 124 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
| 123 | 125 |
| 124 precache::PrecacheManager* precache_manager = | 126 precache::PrecacheManager* precache_manager = |
| 125 precache::PrecacheManagerFactory::GetForBrowserContext(profile); | 127 precache::PrecacheManagerFactory::GetForBrowserContext(profile); |
| 126 // |precache_manager| could be NULL if the profile is off the record. | 128 // |precache_manager| could be NULL if the profile is off the record. |
| 127 if (!precache_manager || !precache_manager->IsPrecachingAllowed()) | 129 if (!precache_manager || !precache_manager->IsPrecachingAllowed()) |
| 128 return; | 130 return; |
| 129 | 131 |
| 130 precache_manager->RecordStatsForFetch(url, referrer, latency, fetch_time, | 132 precache_manager->UpdatePrecacheMetricsAndState( |
| 131 size, was_cached); | 133 url, referrer, latency, fetch_time, size, was_cached, is_user_traffic); |
| 132 } | 134 } |
| 133 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 135 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 134 | 136 |
| 135 void ReportInvalidReferrerSendOnUI() { | 137 void ReportInvalidReferrerSendOnUI() { |
| 136 base::RecordAction( | 138 base::RecordAction( |
| 137 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); | 139 base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer")); |
| 138 } | 140 } |
| 139 | 141 |
| 140 void ReportInvalidReferrerSend(const GURL& target_url, | 142 void ReportInvalidReferrerSend(const GURL& target_url, |
| 141 const GURL& referrer_url) { | 143 const GURL& referrer_url) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // specified with the Content-Length header, which may be inaccurate, | 534 // specified with the Content-Length header, which may be inaccurate, |
| 533 // or missing, as is the case with chunked encoding. | 535 // or missing, as is the case with chunked encoding. |
| 534 int64_t received_content_length = | 536 int64_t received_content_length = |
| 535 request->received_response_content_length(); | 537 request->received_response_content_length(); |
| 536 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time(); | 538 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time(); |
| 537 | 539 |
| 538 // Record precache metrics when a fetch is completed successfully, if | 540 // Record precache metrics when a fetch is completed successfully, if |
| 539 // precaching is allowed. | 541 // precaching is allowed. |
| 540 BrowserThread::PostTask( | 542 BrowserThread::PostTask( |
| 541 BrowserThread::UI, FROM_HERE, | 543 BrowserThread::UI, FROM_HERE, |
| 542 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), | 544 base::Bind( |
| 543 GURL(request->referrer()), latency, base::Time::Now(), | 545 &UpdatePrecacheMetricsAndStateOnUIThread, request->url(), |
| 544 received_content_length, request->was_cached(), profile_)); | 546 GURL(request->referrer()), latency, base::Time::Now(), |
| 547 received_content_length, request->was_cached(), |
| 548 data_use_measurement::DataUseMeasurement::IsUserTraffic(request), |
| 549 profile_)); |
| 545 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 550 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 546 extensions_delegate_->OnCompleted(request, started); | 551 extensions_delegate_->OnCompleted(request, started); |
| 547 } else if (request->status().status() == net::URLRequestStatus::FAILED || | 552 } else if (request->status().status() == net::URLRequestStatus::FAILED || |
| 548 request->status().status() == net::URLRequestStatus::CANCELED) { | 553 request->status().status() == net::URLRequestStatus::CANCELED) { |
| 549 extensions_delegate_->OnCompleted(request, started); | 554 extensions_delegate_->OnCompleted(request, started); |
| 550 } else { | 555 } else { |
| 551 NOTREACHED(); | 556 NOTREACHED(); |
| 552 } | 557 } |
| 553 if (domain_reliability_monitor_) | 558 if (domain_reliability_monitor_) |
| 554 domain_reliability_monitor_->OnCompleted(request, started); | 559 domain_reliability_monitor_->OnCompleted(request, started); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 if (!data_use_aggregator_) | 753 if (!data_use_aggregator_) |
| 749 return; | 754 return; |
| 750 | 755 |
| 751 if (is_data_usage_off_the_record_) { | 756 if (is_data_usage_off_the_record_) { |
| 752 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 757 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 753 return; | 758 return; |
| 754 } | 759 } |
| 755 | 760 |
| 756 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 761 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 757 } | 762 } |
| OLD | NEW |