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_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "net/http/http_response_headers.h" | 12 #include "net/http/http_response_headers.h" |
Ryan Sleevi
2014/07/22 08:22:25
Forward declare
Not at Google. Contact bengr
2014/07/22 23:03:53
Done.
| |
13 #include "net/proxy/proxy_service.h" | 13 #include "net/proxy/proxy_service.h" |
Ryan Sleevi
2014/07/22 08:22:25
Forward Declare
Not at Google. Contact bengr
2014/07/22 23:03:53
DataReductionProxyBypassType is an enum, so forwar
| |
14 | 14 |
15 using net::ProxyService; | 15 using net::ProxyService; |
Ryan Sleevi
2014/07/22 08:22:25
Do not use a Using directive in headers - http://g
Not at Google. Contact bengr
2014/07/22 23:03:53
Done.
| |
16 | 16 |
17 namespace data_reduction_proxy { | 17 namespace data_reduction_proxy { |
18 | 18 |
19 // Contains instructions contained in the Chrome-Proxy header. | 19 // Contains instructions contained in the Chrome-Proxy header. |
20 struct DataReductionProxyInfo { | 20 struct DataReductionProxyInfo { |
21 DataReductionProxyInfo() : bypass_all(false) {} | 21 DataReductionProxyInfo() : bypass_all(false) {} |
22 | 22 |
23 // True if Chrome should bypass all available data reduction proxies. False | 23 // True if Chrome should bypass all available data reduction proxies. False |
24 // if only the currently connected data reduction proxy should be bypassed. | 24 // if only the currently connected data reduction proxy should be bypassed. |
25 bool bypass_all; | 25 bool bypass_all; |
26 | 26 |
27 // Amount of time to bypass the data reduction proxy or proxies. | 27 // Amount of time to bypass the data reduction proxy or proxies. |
28 base::TimeDelta bypass_duration; | 28 base::TimeDelta bypass_duration; |
29 }; | 29 }; |
30 | 30 |
31 // Returns true if the Chrome-Proxy header is present and contains a bypass | 31 // Returns true if the Chrome-Proxy header is present and contains a bypass |
32 // delay. Sets |proxy_info->bypass_duration| to the specified delay if greater | 32 // delay. Sets |proxy_info->bypass_duration| to the specified delay if greater |
33 // than 0, and to 0 otherwise to indicate that the default proxy delay | 33 // than 0, and to 0 otherwise to indicate that the default proxy delay |
34 // (as specified in |ProxyList::UpdateRetryInfoOnFallback|) should be used. | 34 // (as specified in |ProxyList::UpdateRetryInfoOnFallback|) should be used. |
35 // If all available data reduction proxies should by bypassed, |bypass_all| is | 35 // If all available data reduction proxies should by bypassed, |bypass_all| is |
36 // set to true. |proxy_info| must be non-NULL. | 36 // set to true. |proxy_info| must be non-NULL. |
37 bool GetDataReductionProxyInfo( | 37 bool ParseHeadersAndSetProxyInfo( |
38 const net::HttpResponseHeaders* headers, | 38 const net::HttpResponseHeaders* headers, |
39 DataReductionProxyInfo* proxy_info); | 39 DataReductionProxyInfo* proxy_info); |
40 | 40 |
41 // Returns true if the response contain the data reduction proxy Via header | 41 // Returns true if the response contain the data reduction proxy Via header |
42 // value. Used to check the integrity of data reduction proxy responses. | 42 // value. Used to check the integrity of data reduction proxy responses. |
43 bool HasDataReductionProxyViaHeader(const net::HttpResponseHeaders* headers); | 43 bool HasDataReductionProxyViaHeader(const net::HttpResponseHeaders* headers); |
44 | 44 |
45 // Returns the reason why the Chrome proxy should be bypassed or not, and | 45 // Returns the reason why the Chrome proxy should be bypassed or not, and |
46 // populates |proxy_info| with information on how long to bypass if | 46 // populates |proxy_info| with information on how long to bypass if |
47 // applicable. | 47 // applicable. |
48 ProxyService::DataReductionProxyBypassType GetDataReductionProxyBypassType( | 48 ProxyService::DataReductionProxyBypassType GetDataReductionProxyBypassType( |
49 const net::HttpResponseHeaders* headers, | 49 const net::HttpResponseHeaders* headers, |
50 DataReductionProxyInfo* proxy_info); | 50 DataReductionProxyInfo* proxy_info); |
51 | 51 |
52 // Searches for the specified Chrome-Proxy action, and if present interprets | 52 // Searches for the specified Chrome-Proxy action, and if present interprets |
53 // its value as a duration in seconds. | 53 // its value as a duration in seconds. |
54 bool GetDataReductionProxyBypassDuration( | 54 bool ParseHeadersAndSetProxyInfoBypassDuration( |
55 const net::HttpResponseHeaders* headers, | 55 const net::HttpResponseHeaders* headers, |
56 const std::string& action_prefix, | 56 const std::string& action_prefix, |
57 base::TimeDelta* duration); | 57 DataReductionProxyInfo* proxy_info); |
58 | 58 |
59 } // namespace data_reduction_proxy | 59 } // namespace data_reduction_proxy |
60 #endif // COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H _ | 60 #endif // COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H _ |
OLD | NEW |