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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 | 152 |
246 } // namespace | 153 } // namespace |
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_google_safe_search_(NULL), | 161 force_google_safe_search_(NULL), |
255 data_reduction_proxy_enabled_(NULL), | |
256 #if defined(ENABLE_CONFIGURATION_POLICY) | 162 #if defined(ENABLE_CONFIGURATION_POLICY) |
257 url_blacklist_manager_(NULL), | 163 url_blacklist_manager_(NULL), |
258 #endif | 164 #endif |
259 domain_reliability_monitor_(NULL), | 165 domain_reliability_monitor_(NULL), |
260 received_content_length_(0), | |
261 original_content_length_(0), | |
262 first_request_(true), | 166 first_request_(true), |
263 prerender_tracker_(NULL), | 167 prerender_tracker_(NULL) { |
264 data_reduction_proxy_params_(NULL), | |
265 data_reduction_proxy_usage_stats_(NULL), | |
266 data_reduction_proxy_auth_request_handler_(NULL), | |
267 data_reduction_proxy_statistics_prefs_(NULL) { | |
268 DCHECK(enable_referrers); | 168 DCHECK(enable_referrers); |
269 extensions_delegate_.reset( | 169 extensions_delegate_.reset( |
270 ChromeExtensionsNetworkDelegate::Create(event_router)); | 170 ChromeExtensionsNetworkDelegate::Create(event_router)); |
271 } | 171 } |
272 | 172 |
273 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} | 173 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} |
274 | 174 |
275 void ChromeNetworkDelegate::set_extension_info_map( | 175 void ChromeNetworkDelegate::set_extension_info_map( |
276 extensions::InfoMap* extension_info_map) { | 176 extensions::InfoMap* extension_info_map) { |
277 extensions_delegate_->set_extension_info_map(extension_info_map); | 177 extensions_delegate_->set_extension_info_map(extension_info_map); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 force_google_safe_search->MoveToThread( | 225 force_google_safe_search->MoveToThread( |
326 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 226 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
327 } | 227 } |
328 } | 228 } |
329 | 229 |
330 // static | 230 // static |
331 void ChromeNetworkDelegate::AllowAccessToAllFiles() { | 231 void ChromeNetworkDelegate::AllowAccessToAllFiles() { |
332 g_allow_file_access_ = true; | 232 g_allow_file_access_ = true; |
333 } | 233 } |
334 | 234 |
335 // static | |
336 // TODO(megjablon): Use data_reduction_proxy_delayed_pref_service to read prefs. | |
337 // Until updated the pref values may be up to an hour behind on desktop. | |
338 base::Value* ChromeNetworkDelegate::HistoricNetworkStatsInfoToValue( | |
339 PrefService* prefs) { | |
340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
341 int64 total_received = prefs->GetInt64( | |
342 data_reduction_proxy::prefs::kHttpReceivedContentLength); | |
343 int64 total_original = prefs->GetInt64( | |
344 data_reduction_proxy::prefs::kHttpOriginalContentLength); | |
345 | |
346 base::DictionaryValue* dict = new base::DictionaryValue(); | |
347 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | |
348 dict->SetString("historic_received_content_length", | |
349 base::Int64ToString(total_received)); | |
350 dict->SetString("historic_original_content_length", | |
351 base::Int64ToString(total_original)); | |
352 return dict; | |
353 } | |
354 | |
355 base::Value* ChromeNetworkDelegate::SessionNetworkStatsInfoToValue() const { | |
356 base::DictionaryValue* dict = new base::DictionaryValue(); | |
357 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | |
358 dict->SetString("session_received_content_length", | |
359 base::Int64ToString(received_content_length_)); | |
360 dict->SetString("session_original_content_length", | |
361 base::Int64ToString(original_content_length_)); | |
362 return dict; | |
363 } | |
364 | |
365 int ChromeNetworkDelegate::OnBeforeURLRequest( | 235 int ChromeNetworkDelegate::OnBeforeURLRequest( |
366 net::URLRequest* request, | 236 net::URLRequest* request, |
367 const net::CompletionCallback& callback, | 237 const net::CompletionCallback& callback, |
368 GURL* new_url) { | 238 GURL* new_url) { |
369 #if defined(ENABLE_CONFIGURATION_POLICY) | 239 #if defined(ENABLE_CONFIGURATION_POLICY) |
370 // TODO(joaodasilva): This prevents extensions from seeing URLs that are | 240 // TODO(joaodasilva): This prevents extensions from seeing URLs that are |
371 // blocked. However, an extension might redirect the request to another URL, | 241 // blocked. However, an extension might redirect the request to another URL, |
372 // which is not blocked. | 242 // which is not blocked. |
373 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; | 243 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; |
374 if (url_blacklist_manager_ && | 244 if (url_blacklist_manager_ && |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 | 281 |
412 if (force_safe_search && rv == net::OK && new_url->is_empty()) | 282 if (force_safe_search && rv == net::OK && new_url->is_empty()) |
413 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 283 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
414 | 284 |
415 if (connect_interceptor_) | 285 if (connect_interceptor_) |
416 connect_interceptor_->WitnessURLRequest(request); | 286 connect_interceptor_->WitnessURLRequest(request); |
417 | 287 |
418 return rv; | 288 return rv; |
419 } | 289 } |
420 | 290 |
421 void ChromeNetworkDelegate::OnResolveProxy( | |
422 const GURL& url, | |
423 int load_flags, | |
424 const net::ProxyService& proxy_service, | |
425 net::ProxyInfo* result) { | |
426 if (!on_resolve_proxy_handler_.is_null() && | |
427 !proxy_config_getter_.is_null()) { | |
428 on_resolve_proxy_handler_.Run(url, load_flags, | |
429 proxy_config_getter_.Run(), | |
430 proxy_service.config(), | |
431 proxy_service.proxy_retry_info(), | |
432 data_reduction_proxy_params_, result); | |
433 } | |
434 } | |
435 | |
436 void ChromeNetworkDelegate::OnProxyFallback(const net::ProxyServer& bad_proxy, | |
437 int net_error) { | |
438 if (data_reduction_proxy_usage_stats_) { | |
439 data_reduction_proxy_usage_stats_->OnProxyFallback( | |
440 bad_proxy, net_error); | |
441 } | |
442 } | |
443 | |
444 int ChromeNetworkDelegate::OnBeforeSendHeaders( | 291 int ChromeNetworkDelegate::OnBeforeSendHeaders( |
445 net::URLRequest* request, | 292 net::URLRequest* request, |
446 const net::CompletionCallback& callback, | 293 const net::CompletionCallback& callback, |
447 net::HttpRequestHeaders* headers) { | 294 net::HttpRequestHeaders* headers) { |
448 bool force_safe_search = force_google_safe_search_ && | 295 bool force_safe_search = force_google_safe_search_ && |
449 force_google_safe_search_->GetValue(); | 296 force_google_safe_search_->GetValue(); |
450 if (force_safe_search) | 297 if (force_safe_search) |
451 safe_search_util::ForceYouTubeSafetyMode(request, headers); | 298 safe_search_util::ForceYouTubeSafetyMode(request, headers); |
452 | 299 |
453 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest"); | 300 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest"); |
454 return extensions_delegate_->OnBeforeSendHeaders(request, callback, headers); | 301 return extensions_delegate_->OnBeforeSendHeaders(request, callback, headers); |
455 } | 302 } |
456 | 303 |
457 void ChromeNetworkDelegate::OnBeforeSendProxyHeaders( | |
458 net::URLRequest* request, | |
459 const net::ProxyInfo& proxy_info, | |
460 net::HttpRequestHeaders* headers) { | |
461 if (data_reduction_proxy_auth_request_handler_) { | |
462 data_reduction_proxy_auth_request_handler_->MaybeAddRequestHeader( | |
463 request, proxy_info.proxy_server(), headers); | |
464 } | |
465 } | |
466 | |
467 void ChromeNetworkDelegate::OnSendHeaders( | 304 void ChromeNetworkDelegate::OnSendHeaders( |
468 net::URLRequest* request, | 305 net::URLRequest* request, |
469 const net::HttpRequestHeaders& headers) { | 306 const net::HttpRequestHeaders& headers) { |
470 extensions_delegate_->OnSendHeaders(request, headers); | 307 extensions_delegate_->OnSendHeaders(request, headers); |
471 } | 308 } |
472 | 309 |
473 int ChromeNetworkDelegate::OnHeadersReceived( | 310 int ChromeNetworkDelegate::OnHeadersReceived( |
474 net::URLRequest* request, | 311 net::URLRequest* request, |
475 const net::CompletionCallback& callback, | 312 const net::CompletionCallback& callback, |
476 const net::HttpResponseHeaders* original_response_headers, | 313 const net::HttpResponseHeaders* original_response_headers, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 #if defined(ENABLE_TASK_MANAGER) | 346 #if defined(ENABLE_TASK_MANAGER) |
510 // This is not completely accurate, but as a first approximation ignore | 347 // This is not completely accurate, but as a first approximation ignore |
511 // requests that are served from the cache. See bug 330931 for more info. | 348 // requests that are served from the cache. See bug 330931 for more info. |
512 if (!request.was_cached()) | 349 if (!request.was_cached()) |
513 TaskManager::GetInstance()->model()->NotifyBytesRead(request, bytes_read); | 350 TaskManager::GetInstance()->model()->NotifyBytesRead(request, bytes_read); |
514 #endif // defined(ENABLE_TASK_MANAGER) | 351 #endif // defined(ENABLE_TASK_MANAGER) |
515 } | 352 } |
516 | 353 |
517 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, | 354 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, |
518 bool started) { | 355 bool started) { |
519 if (data_reduction_proxy_usage_stats_) | |
520 data_reduction_proxy_usage_stats_->OnUrlRequestCompleted(request, started); | |
521 | |
522 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request); | 356 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request); |
523 if (request->status().status() == net::URLRequestStatus::SUCCESS) { | 357 if (request->status().status() == net::URLRequestStatus::SUCCESS) { |
358 #if defined(OS_ANDROID) | |
bengr
2014/12/02 17:20:00
Why did this get added?
megjablon
2014/12/02 22:33:21
Just got moved. received_content_length is only us
| |
524 // For better accuracy, we use the actual bytes read instead of the length | 359 // For better accuracy, we use the actual bytes read instead of the length |
525 // specified with the Content-Length header, which may be inaccurate, | 360 // specified with the Content-Length header, which may be inaccurate, |
526 // or missing, as is the case with chunked encoding. | 361 // or missing, as is the case with chunked encoding. |
527 int64 received_content_length = request->received_response_content_length(); | 362 int64 received_content_length = request->received_response_content_length(); |
528 | 363 |
529 #if defined(OS_ANDROID) | |
530 if (precache::PrecacheManager::IsPrecachingEnabled()) { | 364 if (precache::PrecacheManager::IsPrecachingEnabled()) { |
531 // Record precache metrics when a fetch is completed successfully, if | 365 // Record precache metrics when a fetch is completed successfully, if |
532 // precaching is enabled. | 366 // precaching is enabled. |
533 BrowserThread::PostTask( | 367 BrowserThread::PostTask( |
534 BrowserThread::UI, FROM_HERE, | 368 BrowserThread::UI, FROM_HERE, |
535 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), | 369 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), |
536 base::Time::Now(), received_content_length, | 370 base::Time::Now(), received_content_length, |
537 request->was_cached(), profile_)); | 371 request->was_cached(), profile_)); |
538 } | 372 } |
539 #endif // defined(OS_ANDROID) | 373 #endif // defined(OS_ANDROID) |
540 | |
541 // Only record for http or https urls. | |
542 bool is_http = request->url().SchemeIs("http"); | |
543 bool is_https = request->url().SchemeIs("https"); | |
544 | |
545 if (!request->was_cached() && // Don't record cached content | |
546 received_content_length && // Zero-byte responses aren't useful. | |
547 (is_http || is_https)) { // Only record for HTTP or HTTPS urls. | |
548 int64 original_content_length = | |
549 request->response_info().headers->GetInt64HeaderValue( | |
550 "x-original-content-length"); | |
551 data_reduction_proxy::DataReductionProxyRequestType request_type = | |
552 data_reduction_proxy::GetDataReductionProxyRequestType(request); | |
553 | |
554 base::TimeDelta freshness_lifetime = | |
555 request->response_info().headers->GetFreshnessLifetimes( | |
556 request->response_info().response_time).freshness; | |
557 int64 adjusted_original_content_length = | |
558 data_reduction_proxy::GetAdjustedOriginalContentLength( | |
559 request_type, original_content_length, | |
560 received_content_length); | |
561 AccumulateContentLength(received_content_length, | |
562 adjusted_original_content_length, | |
563 request_type); | |
564 RecordContentLengthHistograms(received_content_length, | |
565 original_content_length, | |
566 freshness_lifetime); | |
567 | |
568 if (data_reduction_proxy_enabled_ && | |
569 data_reduction_proxy_usage_stats_ && | |
570 !proxy_config_getter_.is_null()) { | |
571 data_reduction_proxy_usage_stats_->RecordBytesHistograms( | |
572 request, | |
573 *data_reduction_proxy_enabled_, | |
574 proxy_config_getter_.Run()); | |
575 } | |
576 DVLOG(2) << __FUNCTION__ | |
577 << " received content length: " << received_content_length | |
578 << " original content length: " << original_content_length | |
579 << " url: " << request->url(); | |
580 } | |
581 | |
582 extensions_delegate_->OnCompleted(request, started); | 374 extensions_delegate_->OnCompleted(request, started); |
583 } else if (request->status().status() == net::URLRequestStatus::FAILED || | 375 } else if (request->status().status() == net::URLRequestStatus::FAILED || |
584 request->status().status() == net::URLRequestStatus::CANCELED) { | 376 request->status().status() == net::URLRequestStatus::CANCELED) { |
585 extensions_delegate_->OnCompleted(request, started); | 377 extensions_delegate_->OnCompleted(request, started); |
586 } else { | 378 } else { |
587 NOTREACHED(); | 379 NOTREACHED(); |
588 } | 380 } |
589 if (domain_reliability_monitor_) | 381 if (domain_reliability_monitor_) |
590 domain_reliability_monitor_->OnCompleted(request, started); | 382 domain_reliability_monitor_->OnCompleted(request, started); |
591 extensions_delegate_->ForwardProxyErrors(request); | 383 extensions_delegate_->ForwardProxyErrors(request); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 575 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
784 const net::URLRequest& request, | 576 const net::URLRequest& request, |
785 const GURL& target_url, | 577 const GURL& target_url, |
786 const GURL& referrer_url) const { | 578 const GURL& referrer_url) const { |
787 base::debug::StackTrace callstack; | 579 base::debug::StackTrace callstack; |
788 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 580 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
789 base::Bind(&ReportInvalidReferrerSend, target_url, | 581 base::Bind(&ReportInvalidReferrerSend, target_url, |
790 referrer_url, callstack)); | 582 referrer_url, callstack)); |
791 return true; | 583 return true; |
792 } | 584 } |
793 | |
794 void ChromeNetworkDelegate::AccumulateContentLength( | |
795 int64 received_content_length, | |
796 int64 original_content_length, | |
797 data_reduction_proxy::DataReductionProxyRequestType request_type) { | |
798 DCHECK_GE(received_content_length, 0); | |
799 DCHECK_GE(original_content_length, 0); | |
800 if (data_reduction_proxy_statistics_prefs_) { | |
801 StoreAccumulatedContentLength(received_content_length, | |
802 original_content_length, | |
803 request_type, | |
804 reinterpret_cast<Profile*>(profile_), | |
805 data_reduction_proxy_statistics_prefs_); | |
806 } | |
807 received_content_length_ += received_content_length; | |
808 original_content_length_ += original_content_length; | |
809 } | |
OLD | NEW |