OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWOR
K_DELEGATE_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWOR
K_DELEGATE_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWOR
K_DELEGATE_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWOR
K_DELEGATE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 class ProxyService; | 36 class ProxyService; |
37 class URLRequest; | 37 class URLRequest; |
38 } | 38 } |
39 | 39 |
40 namespace data_reduction_proxy { | 40 namespace data_reduction_proxy { |
41 | 41 |
42 class DataReductionProxyConfig; | 42 class DataReductionProxyConfig; |
43 class DataReductionProxyConfigurator; | 43 class DataReductionProxyConfigurator; |
44 class DataReductionProxyIOData; | 44 class DataReductionProxyIOData; |
45 class DataReductionProxyRequestOptions; | 45 class DataReductionProxyRequestOptions; |
46 class DataReductionProxyUsageStats; | 46 class DataReductionProxyBypassStats; |
47 | 47 |
48 // DataReductionProxyNetworkDelegate is a LayeredNetworkDelegate that wraps a | 48 // DataReductionProxyNetworkDelegate is a LayeredNetworkDelegate that wraps a |
49 // NetworkDelegate and adds Data Reduction Proxy specific logic. | 49 // NetworkDelegate and adds Data Reduction Proxy specific logic. |
50 class DataReductionProxyNetworkDelegate : public net::LayeredNetworkDelegate { | 50 class DataReductionProxyNetworkDelegate : public net::LayeredNetworkDelegate { |
51 public: | 51 public: |
52 // Provides an additional proxy configuration that can be consulted after | 52 // Provides an additional proxy configuration that can be consulted after |
53 // proxy resolution. Used to get the Data Reduction Proxy config and give it | 53 // proxy resolution. Used to get the Data Reduction Proxy config and give it |
54 // to the OnResolveProxyHandler and RecordBytesHistograms. | 54 // to the OnResolveProxyHandler and RecordBytesHistograms. |
55 typedef base::Callback<const net::ProxyConfig&()> ProxyConfigGetter; | 55 typedef base::Callback<const net::ProxyConfig&()> ProxyConfigGetter; |
56 | 56 |
57 // Constructs a DataReductionProxyNetworkdelegate object with the given | 57 // Constructs a DataReductionProxyNetworkdelegate object with the given |
58 // |network_delegate|, |config|, |handler|, and |getter|. Takes ownership of | 58 // |network_delegate|, |config|, |handler|, and |getter|. Takes ownership of |
59 // and wraps the |network_delegate|, calling an internal implementation for | 59 // and wraps the |network_delegate|, calling an internal implementation for |
60 // each delegate method. For example, the implementation of | 60 // each delegate method. For example, the implementation of |
61 // OnHeadersReceived() calls OnHeadersReceivedInternal(). | 61 // OnHeadersReceived() calls OnHeadersReceivedInternal(). |
62 DataReductionProxyNetworkDelegate( | 62 DataReductionProxyNetworkDelegate( |
63 scoped_ptr<net::NetworkDelegate> network_delegate, | 63 scoped_ptr<net::NetworkDelegate> network_delegate, |
64 DataReductionProxyConfig* config, | 64 DataReductionProxyConfig* config, |
65 DataReductionProxyRequestOptions* handler, | 65 DataReductionProxyRequestOptions* handler, |
66 const DataReductionProxyConfigurator* configurator); | 66 const DataReductionProxyConfigurator* configurator); |
67 ~DataReductionProxyNetworkDelegate() override; | 67 ~DataReductionProxyNetworkDelegate() override; |
68 | 68 |
69 // Initializes member variables to record data reduction proxy prefs and | 69 // Initializes member variables to record data reduction proxy prefs and |
70 // report UMA. | 70 // report UMA. |
71 void InitIODataAndUMA( | 71 void InitIODataAndUMA( |
72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
73 DataReductionProxyIOData* io_data, | 73 DataReductionProxyIOData* io_data, |
74 BooleanPrefMember* data_reduction_proxy_enabled, | 74 BooleanPrefMember* data_reduction_proxy_enabled, |
75 DataReductionProxyUsageStats* usage_stats); | 75 DataReductionProxyBypassStats* bypass_stats); |
76 | 76 |
77 // Creates a |Value| summary of the state of the network session. The caller | 77 // Creates a |Value| summary of the state of the network session. The caller |
78 // is responsible for deleting the returned value. | 78 // is responsible for deleting the returned value. |
79 base::Value* SessionNetworkStatsInfoToValue() const; | 79 base::Value* SessionNetworkStatsInfoToValue() const; |
80 | 80 |
81 private: | 81 private: |
82 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyNetworkDelegateTest, TotalLengths); | 82 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyNetworkDelegateTest, TotalLengths); |
83 | 83 |
84 // Called as the proxy is being resolved for |url|. Allows the delegate to | 84 // Called as the proxy is being resolved for |url|. Allows the delegate to |
85 // override the proxy resolution decision made by ProxyService. The delegate | 85 // override the proxy resolution decision made by ProxyService. The delegate |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 // Total original size of all content before it was transferred. | 133 // Total original size of all content before it was transferred. |
134 int64 original_content_length_; | 134 int64 original_content_length_; |
135 | 135 |
136 // Weak, owned by our owner. | 136 // Weak, owned by our owner. |
137 BooleanPrefMember* data_reduction_proxy_enabled_; | 137 BooleanPrefMember* data_reduction_proxy_enabled_; |
138 | 138 |
139 // All raw Data Reduction Proxy pointers must outlive |this|. | 139 // All raw Data Reduction Proxy pointers must outlive |this|. |
140 DataReductionProxyConfig* data_reduction_proxy_config_; | 140 DataReductionProxyConfig* data_reduction_proxy_config_; |
141 | 141 |
142 DataReductionProxyUsageStats* data_reduction_proxy_usage_stats_; | 142 DataReductionProxyBypassStats* data_reduction_proxy_bypass_stats_; |
143 | 143 |
144 DataReductionProxyRequestOptions* data_reduction_proxy_request_options_; | 144 DataReductionProxyRequestOptions* data_reduction_proxy_request_options_; |
145 | 145 |
146 DataReductionProxyIOData* data_reduction_proxy_io_data_; | 146 DataReductionProxyIOData* data_reduction_proxy_io_data_; |
147 | 147 |
148 const DataReductionProxyConfigurator* configurator_; | 148 const DataReductionProxyConfigurator* configurator_; |
149 | 149 |
150 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyNetworkDelegate); | 150 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyNetworkDelegate); |
151 }; | 151 }; |
152 | 152 |
153 // Adds data reduction proxies to |result|, where applicable, if result | 153 // Adds data reduction proxies to |result|, where applicable, if result |
154 // otherwise uses a direct connection for |url|, and the data reduction proxy is | 154 // otherwise uses a direct connection for |url|, and the data reduction proxy is |
155 // not bypassed. Also, configures |result| to proceed directly to the origin if | 155 // not bypassed. Also, configures |result| to proceed directly to the origin if |
156 // |result|'s current proxy is the data reduction proxy, the | 156 // |result|'s current proxy is the data reduction proxy, the |
157 // |net::LOAD_BYPASS_DATA_REDUCTION_PROXY| |load_flag| is set, and the | 157 // |net::LOAD_BYPASS_DATA_REDUCTION_PROXY| |load_flag| is set, and the |
158 // DataCompressionProxyCriticalBypass Finch trial is set. | 158 // DataCompressionProxyCriticalBypass Finch trial is set. |
159 void OnResolveProxyHandler(const GURL& url, | 159 void OnResolveProxyHandler(const GURL& url, |
160 int load_flags, | 160 int load_flags, |
161 const net::ProxyConfig& data_reduction_proxy_config, | 161 const net::ProxyConfig& data_reduction_proxy_config, |
162 const net::ProxyRetryInfoMap& proxy_retry_info, | 162 const net::ProxyRetryInfoMap& proxy_retry_info, |
163 const DataReductionProxyConfig* config, | 163 const DataReductionProxyConfig* config, |
164 net::ProxyInfo* result); | 164 net::ProxyInfo* result); |
165 | 165 |
166 } // namespace data_reduction_proxy | 166 } // namespace data_reduction_proxy |
167 | 167 |
168 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NET
WORK_DELEGATE_H_ | 168 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NET
WORK_DELEGATE_H_ |
OLD | NEW |