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 15 matching lines...) Expand all Loading... | |
26 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 26 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
28 #include "chrome/browser/net/chrome_extensions_network_delegate.h" | 28 #include "chrome/browser/net/chrome_extensions_network_delegate.h" |
29 #include "chrome/browser/net/client_hints.h" | 29 #include "chrome/browser/net/client_hints.h" |
30 #include "chrome/browser/net/connect_interceptor.h" | 30 #include "chrome/browser/net/connect_interceptor.h" |
31 #include "chrome/browser/net/safe_search_util.h" | 31 #include "chrome/browser/net/safe_search_util.h" |
32 #include "chrome/browser/prerender/prerender_tracker.h" | 32 #include "chrome/browser/prerender/prerender_tracker.h" |
33 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
34 #include "chrome/browser/task_manager/task_manager.h" | 34 #include "chrome/browser/task_manager/task_manager.h" |
35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
36 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h" | |
37 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr ics.h" | |
38 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" | |
39 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usag e_stats.h" | |
40 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | |
41 #include "components/domain_reliability/monitor.h" | 36 #include "components/domain_reliability/monitor.h" |
42 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
43 #include "content/public/browser/render_frame_host.h" | 38 #include "content/public/browser/render_frame_host.h" |
44 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
45 #include "content/public/browser/resource_request_info.h" | 40 #include "content/public/browser/resource_request_info.h" |
46 #include "net/base/host_port_pair.h" | 41 #include "net/base/host_port_pair.h" |
47 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
48 #include "net/base/net_log.h" | 43 #include "net/base/net_log.h" |
49 #include "net/cookies/canonical_cookie.h" | 44 #include "net/cookies/canonical_cookie.h" |
50 #include "net/cookies/cookie_options.h" | 45 #include "net/cookies/cookie_options.h" |
51 #include "net/http/http_request_headers.h" | 46 #include "net/http/http_request_headers.h" |
52 #include "net/http/http_response_headers.h" | 47 #include "net/http/http_response_headers.h" |
53 #include "net/proxy/proxy_config.h" | |
54 #include "net/proxy/proxy_info.h" | |
55 #include "net/proxy/proxy_retry_info.h" | |
56 #include "net/proxy/proxy_server.h" | |
57 #include "net/url_request/url_request.h" | 48 #include "net/url_request/url_request.h" |
58 #include "net/url_request/url_request_context.h" | 49 #include "net/url_request/url_request_context.h" |
59 | 50 |
60 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
61 #include "chrome/browser/io_thread.h" | 52 #include "chrome/browser/io_thread.h" |
62 #include "components/precache/content/precache_manager.h" | 53 #include "components/precache/content/precache_manager.h" |
63 #include "components/precache/content/precache_manager_factory.h" | 54 #include "components/precache/content/precache_manager_factory.h" |
64 #endif | 55 #endif |
65 | 56 |
66 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 void ForceGoogleSafeSearchCallbackWrapper( | 98 void ForceGoogleSafeSearchCallbackWrapper( |
108 const net::CompletionCallback& callback, | 99 const net::CompletionCallback& callback, |
109 net::URLRequest* request, | 100 net::URLRequest* request, |
110 GURL* new_url, | 101 GURL* new_url, |
111 int rv) { | 102 int rv) { |
112 if (rv == net::OK && new_url->is_empty()) | 103 if (rv == net::OK && new_url->is_empty()) |
113 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 104 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
114 callback.Run(rv); | 105 callback.Run(rv); |
115 } | 106 } |
116 | 107 |
117 void UpdateContentLengthPrefs( | |
118 int received_content_length, | |
119 int original_content_length, | |
120 data_reduction_proxy::DataReductionProxyRequestType request_type, | |
121 Profile* profile, | |
122 data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs) { | |
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
124 DCHECK_GE(received_content_length, 0); | |
125 DCHECK_GE(original_content_length, 0); | |
126 | |
127 // Can be NULL in a unit test. | |
128 if (!g_browser_process) | |
129 return; | |
130 | |
131 // Ignore off-the-record data. | |
132 if (!g_browser_process->profile_manager()->IsValidProfile(profile) || | |
133 profile->IsOffTheRecord()) { | |
134 return; | |
135 } | |
136 data_reduction_proxy::UpdateContentLengthPrefs( | |
137 received_content_length, | |
138 original_content_length, | |
139 profile->GetPrefs(), | |
140 request_type, statistics_prefs); | |
141 } | |
142 | |
143 void StoreAccumulatedContentLength( | |
144 int received_content_length, | |
145 int original_content_length, | |
146 data_reduction_proxy::DataReductionProxyRequestType request_type, | |
147 Profile* profile, | |
148 data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs) { | |
149 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
150 base::Bind(&UpdateContentLengthPrefs, | |
151 received_content_length, | |
152 original_content_length, | |
153 request_type, | |
154 profile, | |
155 statistics_prefs)); | |
156 } | |
157 | |
158 void RecordContentLengthHistograms( | 108 void RecordContentLengthHistograms( |
bengr
2014/11/18 19:30:55
This should be moved to the DRPNetworkDelegate.
megjablon
2014/11/19 19:23:40
Done.
| |
159 int64 received_content_length, | 109 int64 received_content_length, |
160 int64 original_content_length, | 110 int64 original_content_length, |
161 const base::TimeDelta& freshness_lifetime) { | 111 const base::TimeDelta& freshness_lifetime) { |
162 // Add the current resource to these histograms only when a valid | 112 // Add the current resource to these histograms only when a valid |
163 // X-Original-Content-Length header is present. | 113 // X-Original-Content-Length header is present. |
164 if (original_content_length >= 0) { | 114 if (original_content_length >= 0) { |
165 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthWithValidOCL", | 115 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthWithValidOCL", |
166 received_content_length); | 116 received_content_length); |
167 UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLengthWithValidOCL", | 117 UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLengthWithValidOCL", |
168 original_content_length); | 118 original_content_length); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 194 |
245 } // namespace | 195 } // namespace |
246 | 196 |
247 ChromeNetworkDelegate::ChromeNetworkDelegate( | 197 ChromeNetworkDelegate::ChromeNetworkDelegate( |
248 extensions::EventRouterForwarder* event_router, | 198 extensions::EventRouterForwarder* event_router, |
249 BooleanPrefMember* enable_referrers) | 199 BooleanPrefMember* enable_referrers) |
250 : profile_(NULL), | 200 : profile_(NULL), |
251 enable_referrers_(enable_referrers), | 201 enable_referrers_(enable_referrers), |
252 enable_do_not_track_(NULL), | 202 enable_do_not_track_(NULL), |
253 force_google_safe_search_(NULL), | 203 force_google_safe_search_(NULL), |
254 data_reduction_proxy_enabled_(NULL), | |
255 #if defined(ENABLE_CONFIGURATION_POLICY) | 204 #if defined(ENABLE_CONFIGURATION_POLICY) |
256 url_blacklist_manager_(NULL), | 205 url_blacklist_manager_(NULL), |
257 #endif | 206 #endif |
258 domain_reliability_monitor_(NULL), | 207 domain_reliability_monitor_(NULL), |
259 received_content_length_(0), | |
260 original_content_length_(0), | |
261 first_request_(true), | 208 first_request_(true), |
262 prerender_tracker_(NULL), | 209 prerender_tracker_(NULL) { |
263 data_reduction_proxy_params_(NULL), | |
264 data_reduction_proxy_usage_stats_(NULL), | |
265 data_reduction_proxy_auth_request_handler_(NULL), | |
266 data_reduction_proxy_statistics_prefs_(NULL) { | |
267 DCHECK(enable_referrers); | 210 DCHECK(enable_referrers); |
268 extensions_delegate_.reset( | 211 extensions_delegate_.reset( |
269 ChromeExtensionsNetworkDelegate::Create(event_router)); | 212 ChromeExtensionsNetworkDelegate::Create(event_router)); |
270 } | 213 } |
271 | 214 |
272 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} | 215 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} |
273 | 216 |
274 void ChromeNetworkDelegate::set_extension_info_map( | 217 void ChromeNetworkDelegate::set_extension_info_map( |
275 extensions::InfoMap* extension_info_map) { | 218 extensions::InfoMap* extension_info_map) { |
276 extensions_delegate_->set_extension_info_map(extension_info_map); | 219 extensions_delegate_->set_extension_info_map(extension_info_map); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 force_google_safe_search->MoveToThread( | 267 force_google_safe_search->MoveToThread( |
325 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 268 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
326 } | 269 } |
327 } | 270 } |
328 | 271 |
329 // static | 272 // static |
330 void ChromeNetworkDelegate::AllowAccessToAllFiles() { | 273 void ChromeNetworkDelegate::AllowAccessToAllFiles() { |
331 g_allow_file_access_ = true; | 274 g_allow_file_access_ = true; |
332 } | 275 } |
333 | 276 |
334 // static | |
335 // TODO(megjablon): Use data_reduction_proxy_delayed_pref_service to read prefs. | |
336 // Until updated the pref values may be up to an hour behind on desktop. | |
337 base::Value* ChromeNetworkDelegate::HistoricNetworkStatsInfoToValue( | |
338 PrefService* prefs) { | |
339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
340 int64 total_received = prefs->GetInt64( | |
341 data_reduction_proxy::prefs::kHttpReceivedContentLength); | |
342 int64 total_original = prefs->GetInt64( | |
343 data_reduction_proxy::prefs::kHttpOriginalContentLength); | |
344 | |
345 base::DictionaryValue* dict = new base::DictionaryValue(); | |
346 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | |
347 dict->SetString("historic_received_content_length", | |
348 base::Int64ToString(total_received)); | |
349 dict->SetString("historic_original_content_length", | |
350 base::Int64ToString(total_original)); | |
351 return dict; | |
352 } | |
353 | |
354 base::Value* ChromeNetworkDelegate::SessionNetworkStatsInfoToValue() const { | |
355 base::DictionaryValue* dict = new base::DictionaryValue(); | |
356 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | |
357 dict->SetString("session_received_content_length", | |
358 base::Int64ToString(received_content_length_)); | |
359 dict->SetString("session_original_content_length", | |
360 base::Int64ToString(original_content_length_)); | |
361 return dict; | |
362 } | |
363 | |
364 int ChromeNetworkDelegate::OnBeforeURLRequest( | 277 int ChromeNetworkDelegate::OnBeforeURLRequest( |
365 net::URLRequest* request, | 278 net::URLRequest* request, |
366 const net::CompletionCallback& callback, | 279 const net::CompletionCallback& callback, |
367 GURL* new_url) { | 280 GURL* new_url) { |
368 #if defined(ENABLE_CONFIGURATION_POLICY) | 281 #if defined(ENABLE_CONFIGURATION_POLICY) |
369 // TODO(joaodasilva): This prevents extensions from seeing URLs that are | 282 // TODO(joaodasilva): This prevents extensions from seeing URLs that are |
370 // blocked. However, an extension might redirect the request to another URL, | 283 // blocked. However, an extension might redirect the request to another URL, |
371 // which is not blocked. | 284 // which is not blocked. |
372 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; | 285 int error = net::ERR_BLOCKED_BY_ADMINISTRATOR; |
373 if (url_blacklist_manager_ && | 286 if (url_blacklist_manager_ && |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 | 323 |
411 if (force_safe_search && rv == net::OK && new_url->is_empty()) | 324 if (force_safe_search && rv == net::OK && new_url->is_empty()) |
412 safe_search_util::ForceGoogleSafeSearch(request, new_url); | 325 safe_search_util::ForceGoogleSafeSearch(request, new_url); |
413 | 326 |
414 if (connect_interceptor_) | 327 if (connect_interceptor_) |
415 connect_interceptor_->WitnessURLRequest(request); | 328 connect_interceptor_->WitnessURLRequest(request); |
416 | 329 |
417 return rv; | 330 return rv; |
418 } | 331 } |
419 | 332 |
420 void ChromeNetworkDelegate::OnResolveProxy( | |
421 const GURL& url, | |
422 int load_flags, | |
423 const net::ProxyService& proxy_service, | |
424 net::ProxyInfo* result) { | |
425 if (!on_resolve_proxy_handler_.is_null() && | |
426 !proxy_config_getter_.is_null()) { | |
427 on_resolve_proxy_handler_.Run(url, load_flags, | |
428 proxy_config_getter_.Run(), | |
429 proxy_service.config(), | |
430 proxy_service.proxy_retry_info(), | |
431 data_reduction_proxy_params_, result); | |
432 } | |
433 } | |
434 | |
435 void ChromeNetworkDelegate::OnProxyFallback(const net::ProxyServer& bad_proxy, | |
436 int net_error) { | |
437 if (data_reduction_proxy_usage_stats_) { | |
438 data_reduction_proxy_usage_stats_->OnProxyFallback( | |
439 bad_proxy, net_error); | |
440 } | |
441 } | |
442 | |
443 int ChromeNetworkDelegate::OnBeforeSendHeaders( | 333 int ChromeNetworkDelegate::OnBeforeSendHeaders( |
444 net::URLRequest* request, | 334 net::URLRequest* request, |
445 const net::CompletionCallback& callback, | 335 const net::CompletionCallback& callback, |
446 net::HttpRequestHeaders* headers) { | 336 net::HttpRequestHeaders* headers) { |
447 bool force_safe_search = force_google_safe_search_ && | 337 bool force_safe_search = force_google_safe_search_ && |
448 force_google_safe_search_->GetValue(); | 338 force_google_safe_search_->GetValue(); |
449 if (force_safe_search) | 339 if (force_safe_search) |
450 safe_search_util::ForceYouTubeSafetyMode(request, headers); | 340 safe_search_util::ForceYouTubeSafetyMode(request, headers); |
451 | 341 |
452 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest"); | 342 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest"); |
453 return extensions_delegate_->OnBeforeSendHeaders(request, callback, headers); | 343 return extensions_delegate_->OnBeforeSendHeaders(request, callback, headers); |
454 } | 344 } |
455 | 345 |
456 void ChromeNetworkDelegate::OnBeforeSendProxyHeaders( | |
457 net::URLRequest* request, | |
458 const net::ProxyInfo& proxy_info, | |
459 net::HttpRequestHeaders* headers) { | |
460 if (data_reduction_proxy_auth_request_handler_) { | |
461 data_reduction_proxy_auth_request_handler_->MaybeAddRequestHeader( | |
462 request, proxy_info.proxy_server(), headers); | |
463 } | |
464 } | |
465 | |
466 void ChromeNetworkDelegate::OnSendHeaders( | 346 void ChromeNetworkDelegate::OnSendHeaders( |
467 net::URLRequest* request, | 347 net::URLRequest* request, |
468 const net::HttpRequestHeaders& headers) { | 348 const net::HttpRequestHeaders& headers) { |
469 extensions_delegate_->OnSendHeaders(request, headers); | 349 extensions_delegate_->OnSendHeaders(request, headers); |
470 } | 350 } |
471 | 351 |
472 int ChromeNetworkDelegate::OnHeadersReceived( | 352 int ChromeNetworkDelegate::OnHeadersReceived( |
473 net::URLRequest* request, | 353 net::URLRequest* request, |
474 const net::CompletionCallback& callback, | 354 const net::CompletionCallback& callback, |
475 const net::HttpResponseHeaders* original_response_headers, | 355 const net::HttpResponseHeaders* original_response_headers, |
(...skipping 27 matching lines...) Expand all Loading... | |
503 #if defined(ENABLE_TASK_MANAGER) | 383 #if defined(ENABLE_TASK_MANAGER) |
504 // This is not completely accurate, but as a first approximation ignore | 384 // This is not completely accurate, but as a first approximation ignore |
505 // requests that are served from the cache. See bug 330931 for more info. | 385 // requests that are served from the cache. See bug 330931 for more info. |
506 if (!request.was_cached()) | 386 if (!request.was_cached()) |
507 TaskManager::GetInstance()->model()->NotifyBytesRead(request, bytes_read); | 387 TaskManager::GetInstance()->model()->NotifyBytesRead(request, bytes_read); |
508 #endif // defined(ENABLE_TASK_MANAGER) | 388 #endif // defined(ENABLE_TASK_MANAGER) |
509 } | 389 } |
510 | 390 |
511 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, | 391 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, |
512 bool started) { | 392 bool started) { |
513 if (data_reduction_proxy_usage_stats_) | |
514 data_reduction_proxy_usage_stats_->OnUrlRequestCompleted(request, started); | |
515 | |
516 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request); | 393 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request); |
517 if (request->status().status() == net::URLRequestStatus::SUCCESS) { | 394 if (request->status().status() == net::URLRequestStatus::SUCCESS) { |
518 // For better accuracy, we use the actual bytes read instead of the length | 395 // For better accuracy, we use the actual bytes read instead of the length |
519 // specified with the Content-Length header, which may be inaccurate, | 396 // specified with the Content-Length header, which may be inaccurate, |
520 // or missing, as is the case with chunked encoding. | 397 // or missing, as is the case with chunked encoding. |
521 int64 received_content_length = request->received_response_content_length(); | 398 int64 received_content_length = request->received_response_content_length(); |
522 | 399 |
523 #if defined(OS_ANDROID) | 400 #if defined(OS_ANDROID) |
524 if (precache::PrecacheManager::IsPrecachingEnabled()) { | 401 if (precache::PrecacheManager::IsPrecachingEnabled()) { |
525 // Record precache metrics when a fetch is completed successfully, if | 402 // Record precache metrics when a fetch is completed successfully, if |
526 // precaching is enabled. | 403 // precaching is enabled. |
527 BrowserThread::PostTask( | 404 BrowserThread::PostTask( |
528 BrowserThread::UI, FROM_HERE, | 405 BrowserThread::UI, FROM_HERE, |
529 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), | 406 base::Bind(&RecordPrecacheStatsOnUIThread, request->url(), |
530 base::Time::Now(), received_content_length, | 407 base::Time::Now(), received_content_length, |
531 request->was_cached(), profile_)); | 408 request->was_cached(), profile_)); |
532 } | 409 } |
533 #endif // defined(OS_ANDROID) | 410 #endif // defined(OS_ANDROID) |
534 | 411 |
535 // Only record for http or https urls. | 412 // Only record for http or https urls. |
536 bool is_http = request->url().SchemeIs("http"); | 413 bool is_http = request->url().SchemeIs("http"); |
537 bool is_https = request->url().SchemeIs("https"); | 414 bool is_https = request->url().SchemeIs("https"); |
538 | 415 |
539 if (!request->was_cached() && // Don't record cached content | 416 if (!request->was_cached() && // Don't record cached content |
540 received_content_length && // Zero-byte responses aren't useful. | 417 received_content_length && // Zero-byte responses aren't useful. |
541 (is_http || is_https)) { // Only record for HTTP or HTTPS urls. | 418 (is_http || is_https)) { // Only record for HTTP or HTTPS urls. |
542 int64 original_content_length = | 419 int64 original_content_length = |
543 request->response_info().headers->GetInt64HeaderValue( | 420 request->response_info().headers->GetInt64HeaderValue( |
544 "x-original-content-length"); | 421 "x-original-content-length"); |
bengr
2014/11/18 19:30:55
This should be moved to the DRPNetworkDelegate.
megjablon
2014/11/19 19:23:40
Done.
| |
545 data_reduction_proxy::DataReductionProxyRequestType request_type = | |
546 data_reduction_proxy::GetDataReductionProxyRequestType(request); | |
547 | 422 |
548 base::TimeDelta freshness_lifetime = | 423 base::TimeDelta freshness_lifetime = |
bengr
2014/11/18 19:30:55
This should be moved to the DRPNetworkDelegate.
megjablon
2014/11/19 19:23:40
Done.
| |
549 request->response_info().headers->GetFreshnessLifetimes( | 424 request->response_info().headers->GetFreshnessLifetimes( |
550 request->response_info().response_time).freshness; | 425 request->response_info().response_time).freshness; |
551 int64 adjusted_original_content_length = | 426 |
552 data_reduction_proxy::GetAdjustedOriginalContentLength( | |
553 request_type, original_content_length, | |
554 received_content_length); | |
555 AccumulateContentLength(received_content_length, | |
556 adjusted_original_content_length, | |
557 request_type); | |
558 RecordContentLengthHistograms(received_content_length, | 427 RecordContentLengthHistograms(received_content_length, |
bengr
2014/11/18 19:30:55
This should be moved to the DRPNetworkDelegate.
megjablon
2014/11/19 19:23:40
Done.
| |
559 original_content_length, | 428 original_content_length, |
560 freshness_lifetime); | 429 freshness_lifetime); |
561 | 430 |
562 if (data_reduction_proxy_enabled_ && | |
563 data_reduction_proxy_usage_stats_ && | |
564 !proxy_config_getter_.is_null()) { | |
565 data_reduction_proxy_usage_stats_->RecordBytesHistograms( | |
566 request, | |
567 *data_reduction_proxy_enabled_, | |
568 proxy_config_getter_.Run()); | |
569 } | |
570 DVLOG(2) << __FUNCTION__ | 431 DVLOG(2) << __FUNCTION__ |
bengr
2014/11/18 19:30:55
This should be moved to the DRPNetworkDelegate.
megjablon
2014/11/19 19:23:40
Done.
| |
571 << " received content length: " << received_content_length | 432 << " received content length: " << received_content_length |
572 << " original content length: " << original_content_length | 433 << " original content length: " << original_content_length |
573 << " url: " << request->url(); | 434 << " url: " << request->url(); |
574 } | 435 } |
575 | 436 |
576 extensions_delegate_->OnCompleted(request, started); | 437 extensions_delegate_->OnCompleted(request, started); |
577 } else if (request->status().status() == net::URLRequestStatus::FAILED || | 438 } else if (request->status().status() == net::URLRequestStatus::FAILED || |
578 request->status().status() == net::URLRequestStatus::CANCELED) { | 439 request->status().status() == net::URLRequestStatus::CANCELED) { |
579 extensions_delegate_->OnCompleted(request, started); | 440 extensions_delegate_->OnCompleted(request, started); |
580 } else { | 441 } else { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 638 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
778 const net::URLRequest& request, | 639 const net::URLRequest& request, |
779 const GURL& target_url, | 640 const GURL& target_url, |
780 const GURL& referrer_url) const { | 641 const GURL& referrer_url) const { |
781 base::debug::StackTrace callstack; | 642 base::debug::StackTrace callstack; |
782 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 643 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
783 base::Bind(&ReportInvalidReferrerSend, target_url, | 644 base::Bind(&ReportInvalidReferrerSend, target_url, |
784 referrer_url, callstack)); | 645 referrer_url, callstack)); |
785 return true; | 646 return true; |
786 } | 647 } |
787 | |
788 void ChromeNetworkDelegate::AccumulateContentLength( | |
789 int64 received_content_length, | |
790 int64 original_content_length, | |
791 data_reduction_proxy::DataReductionProxyRequestType request_type) { | |
792 DCHECK_GE(received_content_length, 0); | |
793 DCHECK_GE(original_content_length, 0); | |
794 if (data_reduction_proxy_statistics_prefs_) { | |
795 StoreAccumulatedContentLength(received_content_length, | |
796 original_content_length, | |
797 request_type, | |
798 reinterpret_cast<Profile*>(profile_), | |
799 data_reduction_proxy_statistics_prefs_); | |
800 } | |
801 received_content_length_ += received_content_length; | |
802 original_content_length_ += original_content_length; | |
803 } | |
OLD | NEW |