| 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_BROWSER_DATA_REDUCTION_PROXY_PROTOCOL_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_PROTOCOL_H_ |
| 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_PROTOCOL_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_PROTOCOL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "webkit/common/resource_type.h" |
| 10 | 11 |
| 11 namespace base { | 12 namespace base { |
| 12 class TimeDelta; | 13 class TimeDelta; |
| 13 } | 14 } |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 class HttpResponseHeaders; | 17 class HttpResponseHeaders; |
| 17 class ProxyServer; | 18 class ProxyServer; |
| 18 class URLRequest; | 19 class URLRequest; |
| 20 class ProxyInfo; |
| 19 } | 21 } |
| 20 | 22 |
| 21 class GURL; | 23 class GURL; |
| 22 | 24 |
| 23 namespace data_reduction_proxy { | 25 namespace data_reduction_proxy { |
| 24 | 26 |
| 25 class DataReductionProxyParams; | 27 class DataReductionProxyParams; |
| 26 | 28 |
| 27 // Decides whether to mark the data reduction proxy as temporarily bad and | 29 // Decides whether to mark the data reduction proxy as temporarily bad and |
| 28 // put it on the proxy retry list. Returns true if the request should be | 30 // put it on the proxy retry list. Returns true if the request should be |
| 29 // retried. Sets |override_response_headers| to redirect if so. | 31 // retried. Sets |override_response_headers| to redirect if so. |
| 30 bool MaybeBypassProxyAndPrepareToRetry( | 32 bool MaybeBypassProxyAndPrepareToRetry( |
| 31 const DataReductionProxyParams* params, | 33 const DataReductionProxyParams* params, |
| 32 net::URLRequest* request, | 34 net::URLRequest* request, |
| 33 const net::HttpResponseHeaders* original_response_headers, | 35 const net::HttpResponseHeaders* original_response_headers, |
| 34 scoped_refptr<net::HttpResponseHeaders>* override_response_headers); | 36 scoped_refptr<net::HttpResponseHeaders>* override_response_headers); |
| 35 | 37 |
| 38 // Return DataReductionProxy-specific load flags to be associated with the |
| 39 // given request. |
| 40 int BuildLoadFlagsForRequest(ResourceType::Type resource_type); |
| 41 |
| 42 // Upon ProxyService.ResolveProxy(), bypass if the effective proxy is the data |
| 43 // reduction proxy and the net::LOAD_BYPASS_DATA_REDUCTION_PROXY load_flag is |
| 44 // set. |
| 45 void OnResolveProxyHandler(const GURL& url, int load_flags, |
| 46 net::ProxyInfo* result); |
| 47 |
| 36 // Returns true if the request method is idempotent. Only idempotent requests | 48 // Returns true if the request method is idempotent. Only idempotent requests |
| 37 // are retried on a bypass. Visible as part of the public API for testing. | 49 // are retried on a bypass. Visible as part of the public API for testing. |
| 38 bool IsRequestIdempotent(const net::URLRequest* request); | 50 bool IsRequestIdempotent(const net::URLRequest* request); |
| 39 | 51 |
| 40 // Sets the override headers to contain a status line that indicates a | 52 // Sets the override headers to contain a status line that indicates a |
| 41 // redirect (a 302), a "Location:" header that points to the request url, | 53 // redirect (a 302), a "Location:" header that points to the request url, |
| 42 // and sets load flags to bypass proxies. Visible as part of the public API for | 54 // and sets load flags to bypass proxies. Visible as part of the public API for |
| 43 // testing. | 55 // testing. |
| 44 void OverrideResponseAsRedirect( | 56 void OverrideResponseAsRedirect( |
| 45 net::URLRequest* request, | 57 net::URLRequest* request, |
| 46 const net::HttpResponseHeaders* original_response_headers, | 58 const net::HttpResponseHeaders* original_response_headers, |
| 47 scoped_refptr<net::HttpResponseHeaders>* override_response_headers); | 59 scoped_refptr<net::HttpResponseHeaders>* override_response_headers); |
| 48 | 60 |
| 49 // Adds non-empty entries in |data_reduction_proxies| to the retry map | 61 // Adds non-empty entries in |data_reduction_proxies| to the retry map |
| 50 // maintained by the proxy service of the request. Adds | 62 // maintained by the proxy service of the request. Adds |
| 51 // |data_reduction_proxies.second| to the retry list only if |bypass_all| is | 63 // |data_reduction_proxies.second| to the retry list only if |bypass_all| is |
| 52 // true. Visible as part of the public API for testing. | 64 // true. Visible as part of the public API for testing. |
| 53 void MarkProxiesAsBadUntil(net::URLRequest* request, | 65 void MarkProxiesAsBadUntil(net::URLRequest* request, |
| 54 base::TimeDelta& bypass_duration, | 66 base::TimeDelta& bypass_duration, |
| 55 bool bypass_all, | 67 bool bypass_all, |
| 56 const std::pair<GURL, GURL>& data_reduction_proxies); | 68 const std::pair<GURL, GURL>& data_reduction_proxies); |
| 57 | 69 |
| 58 } // namespace data_reduction_proxy | 70 } // namespace data_reduction_proxy |
| 59 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_PROTOCOL
_H_ | 71 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_PROTOCOL
_H_ |
| OLD | NEW |