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 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/prerender/prerender_tracker.h" | 29 #include "chrome/browser/prerender/prerender_tracker.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
31 #include "chrome/browser/task_manager/task_manager.h" | 31 #include "chrome/browser/task_manager/task_manager.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | 34 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
35 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
" | 35 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
" |
36 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 36 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
37 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" | 37 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
38 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" | 38 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" |
| 39 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" |
39 #include "components/domain_reliability/monitor.h" | 40 #include "components/domain_reliability/monitor.h" |
40 #include "components/google/core/browser/google_util.h" | 41 #include "components/google/core/browser/google_util.h" |
41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/render_frame_host.h" | 43 #include "content/public/browser/render_frame_host.h" |
43 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
44 #include "content/public/browser/resource_request_info.h" | 45 #include "content/public/browser/resource_request_info.h" |
45 #include "extensions/common/constants.h" | 46 #include "extensions/common/constants.h" |
46 #include "net/base/host_port_pair.h" | 47 #include "net/base/host_port_pair.h" |
47 #include "net/base/net_errors.h" | 48 #include "net/base/net_errors.h" |
48 #include "net/base/net_log.h" | 49 #include "net/base/net_log.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 287 |
287 } // namespace | 288 } // namespace |
288 | 289 |
289 ChromeNetworkDelegate::ChromeNetworkDelegate( | 290 ChromeNetworkDelegate::ChromeNetworkDelegate( |
290 extensions::EventRouterForwarder* event_router, | 291 extensions::EventRouterForwarder* event_router, |
291 BooleanPrefMember* enable_referrers) | 292 BooleanPrefMember* enable_referrers) |
292 : profile_(NULL), | 293 : profile_(NULL), |
293 enable_referrers_(enable_referrers), | 294 enable_referrers_(enable_referrers), |
294 enable_do_not_track_(NULL), | 295 enable_do_not_track_(NULL), |
295 force_google_safe_search_(NULL), | 296 force_google_safe_search_(NULL), |
| 297 data_reduction_proxy_enabled_(NULL), |
296 #if defined(ENABLE_CONFIGURATION_POLICY) | 298 #if defined(ENABLE_CONFIGURATION_POLICY) |
297 url_blacklist_manager_(NULL), | 299 url_blacklist_manager_(NULL), |
298 #endif | 300 #endif |
299 domain_reliability_monitor_(NULL), | 301 domain_reliability_monitor_(NULL), |
300 received_content_length_(0), | 302 received_content_length_(0), |
301 original_content_length_(0), | 303 original_content_length_(0), |
302 first_request_(true), | 304 first_request_(true), |
303 prerender_tracker_(NULL), | 305 prerender_tracker_(NULL), |
304 data_reduction_proxy_params_(NULL), | 306 data_reduction_proxy_params_(NULL), |
305 data_reduction_proxy_usage_stats_(NULL), | 307 data_reduction_proxy_usage_stats_(NULL), |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 const net::HttpRequestHeaders& headers) { | 508 const net::HttpRequestHeaders& headers) { |
507 extensions_delegate_->OnSendHeaders(request, headers); | 509 extensions_delegate_->OnSendHeaders(request, headers); |
508 } | 510 } |
509 | 511 |
510 int ChromeNetworkDelegate::OnHeadersReceived( | 512 int ChromeNetworkDelegate::OnHeadersReceived( |
511 net::URLRequest* request, | 513 net::URLRequest* request, |
512 const net::CompletionCallback& callback, | 514 const net::CompletionCallback& callback, |
513 const net::HttpResponseHeaders* original_response_headers, | 515 const net::HttpResponseHeaders* original_response_headers, |
514 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 516 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
515 GURL* allowed_unsafe_redirect_url) { | 517 GURL* allowed_unsafe_redirect_url) { |
| 518 net::ProxyService::DataReductionProxyBypassType bypass_type; |
516 if (data_reduction_proxy::MaybeBypassProxyAndPrepareToRetry( | 519 if (data_reduction_proxy::MaybeBypassProxyAndPrepareToRetry( |
517 data_reduction_proxy_params_, | 520 data_reduction_proxy_params_, |
518 request, | 521 request, |
519 original_response_headers, | 522 original_response_headers, |
520 override_response_headers)) { | 523 override_response_headers, |
| 524 &bypass_type)) { |
| 525 if (data_reduction_proxy_usage_stats_) |
| 526 data_reduction_proxy_usage_stats_->SetBypassType(bypass_type); |
521 return net::OK; | 527 return net::OK; |
522 } | 528 } |
523 | 529 |
524 return extensions_delegate_->OnHeadersReceived( | 530 return extensions_delegate_->OnHeadersReceived( |
525 request, | 531 request, |
526 callback, | 532 callback, |
527 original_response_headers, | 533 original_response_headers, |
528 override_response_headers, | 534 override_response_headers, |
529 allowed_unsafe_redirect_url); | 535 allowed_unsafe_redirect_url); |
530 } | 536 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 int64 adjusted_original_content_length = | 606 int64 adjusted_original_content_length = |
601 data_reduction_proxy::GetAdjustedOriginalContentLength( | 607 data_reduction_proxy::GetAdjustedOriginalContentLength( |
602 request_type, original_content_length, | 608 request_type, original_content_length, |
603 received_content_length); | 609 received_content_length); |
604 AccumulateContentLength(received_content_length, | 610 AccumulateContentLength(received_content_length, |
605 adjusted_original_content_length, | 611 adjusted_original_content_length, |
606 request_type); | 612 request_type); |
607 RecordContentLengthHistograms(received_content_length, | 613 RecordContentLengthHistograms(received_content_length, |
608 original_content_length, | 614 original_content_length, |
609 freshness_lifetime); | 615 freshness_lifetime); |
| 616 if (data_reduction_proxy_enabled_ && data_reduction_proxy_usage_stats_) { |
| 617 data_reduction_proxy_usage_stats_->RecordBypassedBytesHistograms( |
| 618 received_content_length, *request, *data_reduction_proxy_enabled_); |
| 619 } |
610 DVLOG(2) << __FUNCTION__ | 620 DVLOG(2) << __FUNCTION__ |
611 << " received content length: " << received_content_length | 621 << " received content length: " << received_content_length |
612 << " original content length: " << original_content_length | 622 << " original content length: " << original_content_length |
613 << " url: " << request->url(); | 623 << " url: " << request->url(); |
614 } | 624 } |
615 | 625 |
616 extensions_delegate_->OnCompleted(request, started); | 626 extensions_delegate_->OnCompleted(request, started); |
617 } else if (request->status().status() == net::URLRequestStatus::FAILED || | 627 } else if (request->status().status() == net::URLRequestStatus::FAILED || |
618 request->status().status() == net::URLRequestStatus::CANCELED) { | 628 request->status().status() == net::URLRequestStatus::CANCELED) { |
619 extensions_delegate_->OnCompleted(request, started); | 629 extensions_delegate_->OnCompleted(request, started); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 data_reduction_proxy::DataReductionProxyRequestType request_type) { | 843 data_reduction_proxy::DataReductionProxyRequestType request_type) { |
834 DCHECK_GE(received_content_length, 0); | 844 DCHECK_GE(received_content_length, 0); |
835 DCHECK_GE(original_content_length, 0); | 845 DCHECK_GE(original_content_length, 0); |
836 StoreAccumulatedContentLength(received_content_length, | 846 StoreAccumulatedContentLength(received_content_length, |
837 original_content_length, | 847 original_content_length, |
838 request_type, | 848 request_type, |
839 reinterpret_cast<Profile*>(profile_)); | 849 reinterpret_cast<Profile*>(profile_)); |
840 received_content_length_ += received_content_length; | 850 received_content_length_ += received_content_length; |
841 original_content_length_ += original_content_length; | 851 original_content_length_ += original_content_length; |
842 } | 852 } |
OLD | NEW |