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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 27 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
29 #include "chrome/browser/net/chrome_extensions_network_delegate.h" | 29 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
30 #include "chrome/browser/net/client_hints.h" | 30 #include "chrome/browser/net/client_hints.h" |
31 #include "chrome/browser/net/connect_interceptor.h" | 31 #include "chrome/browser/net/connect_interceptor.h" |
32 #include "chrome/browser/net/safe_search_util.h" | 32 #include "chrome/browser/net/safe_search_util.h" |
33 #include "chrome/browser/prerender/prerender_tracker.h" | 33 #include "chrome/browser/prerender/prerender_tracker.h" |
34 #include "chrome/browser/profiles/profile_manager.h" | 34 #include "chrome/browser/profiles/profile_manager.h" |
35 #include "chrome/browser/task_manager/task_manager.h" | 35 #include "chrome/browser/task_manager/task_manager.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth
_request_handler.h" | |
38 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" | |
39 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | |
40 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usag
e_stats.h" | |
41 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | |
42 #include "components/domain_reliability/monitor.h" | 37 #include "components/domain_reliability/monitor.h" |
43 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/browser/render_frame_host.h" | 39 #include "content/public/browser/render_frame_host.h" |
45 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
46 #include "content/public/browser/resource_request_info.h" | 41 #include "content/public/browser/resource_request_info.h" |
47 #include "net/base/host_port_pair.h" | 42 #include "net/base/host_port_pair.h" |
48 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
49 #include "net/base/net_log.h" | 44 #include "net/base/net_log.h" |
50 #include "net/cookies/canonical_cookie.h" | 45 #include "net/cookies/canonical_cookie.h" |
51 #include "net/cookies/cookie_options.h" | 46 #include "net/cookies/cookie_options.h" |
52 #include "net/http/http_request_headers.h" | 47 #include "net/http/http_request_headers.h" |
53 #include "net/http/http_response_headers.h" | 48 #include "net/http/http_response_headers.h" |
54 #include "net/proxy/proxy_config.h" | |
55 #include "net/proxy/proxy_info.h" | |
56 #include "net/proxy/proxy_retry_info.h" | |
57 #include "net/proxy/proxy_server.h" | |
58 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
59 #include "net/url_request/url_request_context.h" | 50 #include "net/url_request/url_request_context.h" |
60 | 51 |
61 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
62 #include "chrome/browser/io_thread.h" | 53 #include "chrome/browser/io_thread.h" |
63 #include "components/precache/content/precache_manager.h" | 54 #include "components/precache/content/precache_manager.h" |
64 #include "components/precache/content/precache_manager_factory.h" | 55 #include "components/precache/content/precache_manager_factory.h" |
65 #endif | 56 #endif |
66 | 57 |
67 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void ForceGoogleSafeSearchCallbackWrapper( | 99 void ForceGoogleSafeSearchCallbackWrapper( |
109 const net::CompletionCallback& callback, | 100 const net::CompletionCallback& callback, |
110 net::URLRequest* request, | 101 net::URLRequest* request, |
111 GURL* new_url, | 102 GURL* new_url, |
112 int rv) { | 103 int rv) { |
113 if (rv == net::OK && new_url->is_empty()) | 104 if (rv == net::OK && new_url->is_empty()) |
114 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 105 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
115 callback.Run(rv); | 106 callback.Run(rv); |
116 } | 107 } |
117 | 108 |
118 void UpdateContentLengthPrefs( | |
119 int received_content_length, | |
120 int original_content_length, | |
121 data_reduction_proxy::DataReductionProxyRequestType request_type, | |
122 Profile* profile, | |
123 data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs) { | |
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
125 DCHECK_GE(received_content_length, 0); | |
126 DCHECK_GE(original_content_length, 0); | |
127 | |
128 // Can be NULL in a unit test. | |
129 if (!g_browser_process) | |
130 return; | |
131 | |
132 // Ignore off-the-record data. | |
133 if (!g_browser_process->profile_manager()->IsValidProfile(profile) || | |
134 profile->IsOffTheRecord()) { | |
135 return; | |
136 } | |
137 data_reduction_proxy::UpdateContentLengthPrefs( | |
138 received_content_length, | |
139 original_content_length, | |
140 profile->GetPrefs(), | |
141 request_type, statistics_prefs); | |
142 } | |
143 | |
144 void StoreAccumulatedContentLength( | |
145 int received_content_length, | |
146 int original_content_length, | |
147 data_reduction_proxy::DataReductionProxyRequestType request_type, | |
148 Profile* profile, | |
149 data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs) { | |
150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
151 base::Bind(&UpdateContentLengthPrefs, | |
152 received_content_length, | |
153 original_content_length, | |
154 request_type, | |
155 profile, | |
156 statistics_prefs)); | |
157 } | |
158 | |
159 void RecordContentLengthHistograms( | |
160 int64 received_content_length, | |
161 int64 original_content_length, | |
162 const base::TimeDelta& freshness_lifetime) { | |
163 // Add the current resource to these histograms only when a valid | |
164 // X-Original-Content-Length header is present. | |
165 if (original_content_length >= 0) { | |
166 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthWithValidOCL", | |
167 received_content_length); | |
168 UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLengthWithValidOCL", | |
169 original_content_length); | |
170 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifferenceWithValidOCL", | |
171 original_content_length - received_content_length); | |
172 } else { | |
173 // Presume the original content length is the same as the received content | |
174 // length if the X-Original-Content-Header is not present. | |
175 original_content_length = received_content_length; | |
176 } | |
177 UMA_HISTOGRAM_COUNTS("Net.HttpContentLength", received_content_length); | |
178 UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLength", | |
179 original_content_length); | |
180 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifference", | |
181 original_content_length - received_content_length); | |
182 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.HttpContentFreshnessLifetime", | |
183 freshness_lifetime.InSeconds(), | |
184 base::TimeDelta::FromHours(1).InSeconds(), | |
185 base::TimeDelta::FromDays(30).InSeconds(), | |
186 100); | |
187 if (freshness_lifetime.InSeconds() <= 0) | |
188 return; | |
189 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable", | |
190 received_content_length); | |
191 if (freshness_lifetime.InHours() < 4) | |
192 return; | |
193 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable4Hours", | |
194 received_content_length); | |
195 | |
196 if (freshness_lifetime.InHours() < 24) | |
197 return; | |
198 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable24Hours", | |
199 received_content_length); | |
200 } | |
201 | |
202 #if defined(OS_ANDROID) | 109 #if defined(OS_ANDROID) |
203 void RecordPrecacheStatsOnUIThread(const GURL& url, | 110 void RecordPrecacheStatsOnUIThread(const GURL& url, |
204 const base::Time& fetch_time, int64 size, | 111 const base::Time& fetch_time, int64 size, |
205 bool was_cached, void* profile_id) { | 112 bool was_cached, void* profile_id) { |
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
207 | 114 |
208 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 115 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
209 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) { | 116 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) { |
210 return; | 117 return; |
211 } | 118 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 154 |
248 ChromeNetworkDelegate::ChromeNetworkDelegate( | 155 ChromeNetworkDelegate::ChromeNetworkDelegate( |
249 extensions::EventRouterForwarder* event_router, | 156 extensions::EventRouterForwarder* event_router, |
250 BooleanPrefMember* enable_referrers) | 157 BooleanPrefMember* enable_referrers) |
251 : profile_(NULL), | 158 : profile_(NULL), |
252 enable_referrers_(enable_referrers), | 159 enable_referrers_(enable_referrers), |
253 enable_do_not_track_(NULL), | 160 enable_do_not_track_(NULL), |
254 force_safe_search_(NULL), | 161 force_safe_search_(NULL), |
255 force_google_safe_search_(NULL), | 162 force_google_safe_search_(NULL), |
256 force_youtube_safety_mode_(NULL), | 163 force_youtube_safety_mode_(NULL), |
257 data_reduction_proxy_enabled_(NULL), | |
258 #if defined(ENABLE_CONFIGURATION_POLICY) | 164 #if defined(ENABLE_CONFIGURATION_POLICY) |
259 url_blacklist_manager_(NULL), | 165 url_blacklist_manager_(NULL), |
260 #endif | 166 #endif |
261 domain_reliability_monitor_(NULL), | 167 domain_reliability_monitor_(NULL), |
262 received_content_length_(0), | |
263 original_content_length_(0), | |
264 first_request_(true), | 168 first_request_(true), |
265 prerender_tracker_(NULL), | 169 prerender_tracker_(NULL) { |
266 data_reduction_proxy_params_(NULL), | |
267 data_reduction_proxy_usage_stats_(NULL), | |
268 data_reduction_proxy_auth_request_handler_(NULL), | |
269 data_reduction_proxy_statistics_prefs_(NULL) { | |
270 DCHECK(enable_referrers); | 170 DCHECK(enable_referrers); |
271 extensions_delegate_.reset( | 171 extensions_delegate_.reset( |
272 ChromeExtensionsNetworkDelegate::Create(event_router)); | 172 ChromeExtensionsNetworkDelegate::Create(event_router)); |
273 } | 173 } |
274 | 174 |
275 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} | 175 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} |
276 | 176 |
277 void ChromeNetworkDelegate::set_extension_info_map( | 177 void ChromeNetworkDelegate::set_extension_info_map( |
278 extensions::InfoMap* extension_info_map) { | 178 extensions::InfoMap* extension_info_map) { |
279 extensions_delegate_->set_extension_info_map(extension_info_map); | 179 extensions_delegate_->set_extension_info_map(extension_info_map); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 force_youtube_safety_mode->MoveToThread( | 240 force_youtube_safety_mode->MoveToThread( |
341 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 241 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
342 } | 242 } |
343 } | 243 } |
344 | 244 |
345 // static | 245 // static |
346 void ChromeNetworkDelegate::AllowAccessToAllFiles() { | 246 void ChromeNetworkDelegate::AllowAccessToAllFiles() { |
347 g_allow_file_access_ = true; | 247 g_allow_file_access_ = true; |
348 } | 248 } |
349 | 249 |
350 // static | |
351 // TODO(megjablon): Use data_reduction_proxy_delayed_pref_service to read prefs. | |
352 // Until updated the pref values may be up to an hour behind on desktop. | |
353 base::Value* ChromeNetworkDelegate::HistoricNetworkStatsInfoToValue( | |
354 PrefService* prefs) { | |
355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
356 int64 total_received = prefs->GetInt64( | |
357 data_reduction_proxy::prefs::kHttpReceivedContentLength); | |
358 int64 total_original = prefs->GetInt64( | |
359 data_reduction_proxy::prefs::kHttpOriginalContentLength); | |
360 | |
361 base::DictionaryValue* dict = new base::DictionaryValue(); | |
362 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | |
363 dict->SetString("historic_received_content_length", | |
364 base::Int64ToString(total_received)); | |
365 dict->SetString("historic_original_content_length", | |
366 base::Int64ToString(total_original)); | |
367 return dict; | |
368 } | |
369 | |
370 base::Value* ChromeNetworkDelegate::SessionNetworkStatsInfoToValue() const { | |
371 base::DictionaryValue* dict = new base::DictionaryValue(); | |
372 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | |
373 dict->SetString("session_received_content_length", | |
374 base::Int64ToString(received_content_length_)); | |
375 dict->SetString("session_original_content_length", | |
376 base::Int64ToString(original_content_length_)); | |
377 return dict; | |
378 } | |
379 | |
380 int ChromeNetworkDelegate::OnBeforeURLRequest( | 250 int ChromeNetworkDelegate::OnBeforeURLRequest( |
381 net::URLRequest* request, | 251 net::URLRequest* request, |
382 const net::CompletionCallback& callback, | 252 const net::CompletionCallback& callback, |
383 GURL* new_url) { | 253 GURL* new_url) { |
384 #if defined(ENABLE_CONFIGURATION_POLICY) | 254 #if defined(ENABLE_CONFIGURATION_POLICY) |
385 // TODO(joaodasilva): This prevents extensions from seeing URLs that are | 255 // TODO(joaodasilva): This prevents extensions from seeing URLs that are |
386 // blocked. However, an extension might redirect the request to another URL, | 256 // blocked. However, an extension might redirect the request to another URL, |
387 // which is not blocked. | 257 // which is not blocked. |
388 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; | 258 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; |
389 if (url_blacklist_manager_ && | 259 if (url_blacklist_manager_ && |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 297 |
428 if (force_safe_search && rv == net::OK && new_url->is_empty()) | 298 if (force_safe_search && rv == net::OK && new_url->is_empty()) |
429 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 299 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
430 | 300 |
431 if (connect_interceptor_) | 301 if (connect_interceptor_) |
432 connect_interceptor_->WitnessURLRequest(request); | 302 connect_interceptor_->WitnessURLRequest(request); |
433 | 303 |
434 return rv; | 304 return rv; |
435 } | 305 } |
436 | 306 |
437 void ChromeNetworkDelegate::OnResolveProxy( | |
438 const GURL& url, | |
439 int load_flags, | |
440 const net::ProxyService& proxy_service, | |
441 net::ProxyInfo* result) { | |
442 if (!on_resolve_proxy_handler_.is_null() && | |
443 !proxy_config_getter_.is_null()) { | |
444 on_resolve_proxy_handler_.Run(url, load_flags, | |
445 proxy_config_getter_.Run(), | |
446 proxy_service.config(), | |
447 proxy_service.proxy_retry_info(), | |
448 data_reduction_proxy_params_, result); | |
449 } | |
450 } | |
451 | |
452 void ChromeNetworkDelegate::OnProxyFallback(const net::ProxyServer& bad_proxy, | |
453 int net_error) { | |
454 if (data_reduction_proxy_usage_stats_) { | |
455 data_reduction_proxy_usage_stats_->OnProxyFallback( | |
456 bad_proxy, net_error); | |
457 } | |
458 } | |
459 | |
460 int ChromeNetworkDelegate::OnBeforeSendHeaders( | 307 int ChromeNetworkDelegate::OnBeforeSendHeaders( |
461 net::URLRequest* request, | 308 net::URLRequest* request, |
462 const net::CompletionCallback& callback, | 309 const net::CompletionCallback& callback, |
463 net::HttpRequestHeaders* headers) { | 310 net::HttpRequestHeaders* headers) { |
464 bool force_safety_mode = | 311 bool force_safety_mode = |
465 (force_safe_search_ && force_safe_search_->GetValue()) || | 312 (force_safe_search_ && force_safe_search_->GetValue()) || |
466 (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue()); | 313 (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue()); |
467 if (force_safety_mode) | 314 if (force_safety_mode) |
468 safe_search_util::ForceYouTubeSafetyMode(request, headers); | 315 safe_search_util::ForceYouTubeSafetyMode(request, headers); |
469 | 316 |
470 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest"); | 317 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest"); |
471 return extensions_delegate_->OnBeforeSendHeaders(request, callback, headers); | 318 return extensions_delegate_->OnBeforeSendHeaders(request, callback, headers); |
472 } | 319 } |
473 | 320 |
474 void ChromeNetworkDelegate::OnBeforeSendProxyHeaders( | |
475 net::URLRequest* request, | |
476 const net::ProxyInfo& proxy_info, | |
477 net::HttpRequestHeaders* headers) { | |
478 if (data_reduction_proxy_auth_request_handler_) { | |
479 data_reduction_proxy_auth_request_handler_->MaybeAddRequestHeader( | |
480 request, proxy_info.proxy_server(), headers); | |
481 } | |
482 } | |
483 | |
484 void ChromeNetworkDelegate::OnSendHeaders( | 321 void ChromeNetworkDelegate::OnSendHeaders( |
485 net::URLRequest* request, | 322 net::URLRequest* request, |
486 const net::HttpRequestHeaders& headers) { | 323 const net::HttpRequestHeaders& headers) { |
487 extensions_delegate_->OnSendHeaders(request, headers); | 324 extensions_delegate_->OnSendHeaders(request, headers); |
488 } | 325 } |
489 | 326 |
490 int ChromeNetworkDelegate::OnHeadersReceived( | 327 int ChromeNetworkDelegate::OnHeadersReceived( |
491 net::URLRequest* request, | 328 net::URLRequest* request, |
492 const net::CompletionCallback& callback, | 329 const net::CompletionCallback& callback, |
493 const net::HttpResponseHeaders* original_response_headers, | 330 const net::HttpResponseHeaders* original_response_headers, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 378 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
542 "423948 ChromeNetworkDelegate::OnRawBytesRead2")); | 379 "423948 ChromeNetworkDelegate::OnRawBytesRead2")); |
543 | 380 |
544 task_manager->model()->NotifyBytesRead(request, bytes_read); | 381 task_manager->model()->NotifyBytesRead(request, bytes_read); |
545 } | 382 } |
546 #endif // defined(ENABLE_TASK_MANAGER) | 383 #endif // defined(ENABLE_TASK_MANAGER) |
547 } | 384 } |
548 | 385 |
549 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, | 386 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, |
550 bool started) { | 387 bool started) { |
551 if (data_reduction_proxy_usage_stats_) | |
552 data_reduction_proxy_usage_stats_->OnUrlRequestCompleted(request, started); | |
553 | |
554 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request); | 388 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request); |
555 if (request->status().status() == net::URLRequestStatus::SUCCESS) { | 389 if (request->status().status() == net::URLRequestStatus::SUCCESS) { |
| 390 #if defined(OS_ANDROID) |
556 // For better accuracy, we use the actual bytes read instead of the length | 391 // For better accuracy, we use the actual bytes read instead of the length |
557 // specified with the Content-Length header, which may be inaccurate, | 392 // specified with the Content-Length header, which may be inaccurate, |
558 // or missing, as is the case with chunked encoding. | 393 // or missing, as is the case with chunked encoding. |
559 int64 received_content_length = request->received_response_content_length(); | 394 int64 received_content_length = request->received_response_content_length(); |
560 | 395 |
561 #if defined(OS_ANDROID) | |
562 if (precache::PrecacheManager::IsPrecachingEnabled()) { | 396 if (precache::PrecacheManager::IsPrecachingEnabled()) { |
563 // Record precache metrics when a fetch is completed successfully, if | 397 // Record precache metrics when a fetch is completed successfully, if |
564 // precaching is enabled. | 398 // precaching is enabled. |
565 BrowserThread::PostTask( | 399 BrowserThread::PostTask( |
566 BrowserThread::UI, FROM_HERE, | 400 BrowserThread::UI, FROM_HERE, |
567 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), | 401 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), |
568 base::Time::Now(), received_content_length, | 402 base::Time::Now(), received_content_length, |
569 request->was_cached(), profile_)); | 403 request->was_cached(), profile_)); |
570 } | 404 } |
571 #endif // defined(OS_ANDROID) | 405 #endif // defined(OS_ANDROID) |
572 | |
573 // Only record for http or https urls. | |
574 bool is_http = request->url().SchemeIs("http"); | |
575 bool is_https = request->url().SchemeIs("https"); | |
576 | |
577 if (!request->was_cached() && // Don't record cached content | |
578 received_content_length && // Zero-byte responses aren't useful. | |
579 (is_http || is_https)) { // Only record for HTTP or HTTPS urls. | |
580 int64 original_content_length = | |
581 request->response_info().headers->GetInt64HeaderValue( | |
582 "x-original-content-length"); | |
583 data_reduction_proxy::DataReductionProxyRequestType request_type = | |
584 data_reduction_proxy::GetDataReductionProxyRequestType(request); | |
585 | |
586 base::TimeDelta freshness_lifetime = | |
587 request->response_info().headers->GetFreshnessLifetimes( | |
588 request->response_info().response_time).freshness; | |
589 int64 adjusted_original_content_length = | |
590 data_reduction_proxy::GetAdjustedOriginalContentLength( | |
591 request_type, original_content_length, | |
592 received_content_length); | |
593 AccumulateContentLength(received_content_length, | |
594 adjusted_original_content_length, | |
595 request_type); | |
596 RecordContentLengthHistograms(received_content_length, | |
597 original_content_length, | |
598 freshness_lifetime); | |
599 | |
600 if (data_reduction_proxy_enabled_ && | |
601 data_reduction_proxy_usage_stats_ && | |
602 !proxy_config_getter_.is_null()) { | |
603 data_reduction_proxy_usage_stats_->RecordBytesHistograms( | |
604 request, | |
605 *data_reduction_proxy_enabled_, | |
606 proxy_config_getter_.Run()); | |
607 } | |
608 DVLOG(2) << __FUNCTION__ | |
609 << " received content length: " << received_content_length | |
610 << " original content length: " << original_content_length | |
611 << " url: " << request->url(); | |
612 } | |
613 | |
614 extensions_delegate_->OnCompleted(request, started); | 406 extensions_delegate_->OnCompleted(request, started); |
615 } else if (request->status().status() == net::URLRequestStatus::FAILED || | 407 } else if (request->status().status() == net::URLRequestStatus::FAILED || |
616 request->status().status() == net::URLRequestStatus::CANCELED) { | 408 request->status().status() == net::URLRequestStatus::CANCELED) { |
617 extensions_delegate_->OnCompleted(request, started); | 409 extensions_delegate_->OnCompleted(request, started); |
618 } else { | 410 } else { |
619 NOTREACHED(); | 411 NOTREACHED(); |
620 } | 412 } |
621 if (domain_reliability_monitor_) | 413 if (domain_reliability_monitor_) |
622 domain_reliability_monitor_->OnCompleted(request, started); | 414 domain_reliability_monitor_->OnCompleted(request, started); |
623 extensions_delegate_->ForwardProxyErrors(request); | 415 extensions_delegate_->ForwardProxyErrors(request); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 607 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
816 const net::URLRequest& request, | 608 const net::URLRequest& request, |
817 const GURL& target_url, | 609 const GURL& target_url, |
818 const GURL& referrer_url) const { | 610 const GURL& referrer_url) const { |
819 base::debug::StackTrace callstack; | 611 base::debug::StackTrace callstack; |
820 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 612 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
821 base::Bind(&ReportInvalidReferrerSend, target_url, | 613 base::Bind(&ReportInvalidReferrerSend, target_url, |
822 referrer_url, callstack)); | 614 referrer_url, callstack)); |
823 return true; | 615 return true; |
824 } | 616 } |
825 | |
826 void ChromeNetworkDelegate::AccumulateContentLength( | |
827 int64 received_content_length, | |
828 int64 original_content_length, | |
829 data_reduction_proxy::DataReductionProxyRequestType request_type) { | |
830 DCHECK_GE(received_content_length, 0); | |
831 DCHECK_GE(original_content_length, 0); | |
832 if (data_reduction_proxy_statistics_prefs_) { | |
833 StoreAccumulatedContentLength(received_content_length, | |
834 original_content_length, | |
835 request_type, | |
836 reinterpret_cast<Profile*>(profile_), | |
837 data_reduction_proxy_statistics_prefs_); | |
838 } | |
839 received_content_length_ += received_content_length; | |
840 original_content_length_ += original_content_length; | |
841 } | |
OLD | NEW |