summaryrefslogtreecommitdiffstats
path: root/components/data_reduction_proxy/common/data_reduction_proxy_headers.h
diff options
context:
space:
mode:
authorbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-15 12:19:52 +0000
committerbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-15 12:19:52 +0000
commitcefb81130fcc85a5de0b737be52380a22b437574 (patch)
treea6c1e7b0d16272939e459446dce5d3f6c70e01cb /components/data_reduction_proxy/common/data_reduction_proxy_headers.h
parent344a02931fcd9f58e602bd0a1cdf2dde97737d77 (diff)
downloadchromium_src-cefb81130fcc85a5de0b737be52380a22b437574.zip
chromium_src-cefb81130fcc85a5de0b737be52380a22b437574.tar.gz
chromium_src-cefb81130fcc85a5de0b737be52380a22b437574.tar.bz2
Moved data reduction proxy header processing out of net
BUG=367221 Review URL: https://codereview.chromium.org/318753005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/data_reduction_proxy/common/data_reduction_proxy_headers.h')
-rw-r--r--components/data_reduction_proxy/common/data_reduction_proxy_headers.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/components/data_reduction_proxy/common/data_reduction_proxy_headers.h b/components/data_reduction_proxy/common/data_reduction_proxy_headers.h
new file mode 100644
index 0000000..88b0cd0
--- /dev/null
+++ b/components/data_reduction_proxy/common/data_reduction_proxy_headers.h
@@ -0,0 +1,59 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_
+#define COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "net/http/http_response_headers.h"
+#include "net/proxy/proxy_service.h"
+
+namespace data_reduction_proxy {
+
+// Contains instructions contained in the Chrome-Proxy header.
+struct DataReductionProxyInfo {
+ DataReductionProxyInfo() : bypass_all(false) {}
+
+ // True if Chrome should bypass all available data reduction proxies. False
+ // if only the currently connected data reduction proxy should be bypassed.
+ bool bypass_all;
+
+ // Amount of time to bypass the data reduction proxy or proxies.
+ base::TimeDelta bypass_duration;
+};
+
+// Returns true if the Chrome-Proxy header is present and contains a bypass
+// delay. Sets |proxy_info->bypass_duration| to the specified delay if greater
+// than 0, and to 0 otherwise to indicate that the default proxy delay
+// (as specified in |ProxyList::UpdateRetryInfoOnFallback|) should be used.
+// If all available data reduction proxies should by bypassed, |bypass_all| is
+// set to true. |proxy_info| must be non-NULL.
+bool GetDataReductionProxyInfo(
+ const net::HttpResponseHeaders* headers,
+ DataReductionProxyInfo* proxy_info);
+
+// Returns true if the response contain the data reduction proxy Via header
+// value. Used to check the integrity of data reduction proxy responses.
+bool HasDataReductionProxyViaHeader(const net::HttpResponseHeaders* headers);
+
+// Returns the reason why the Chrome proxy should be bypassed or not, and
+// populates |proxy_info| with information on how long to bypass if
+// applicable.
+net::ProxyService::DataReductionProxyBypassEventType
+GetDataReductionProxyBypassEventType(
+ const net::HttpResponseHeaders* headers,
+ DataReductionProxyInfo* proxy_info);
+
+// Searches for the specified Chrome-Proxy action, and if present interprets
+// its value as a duration in seconds.
+bool GetDataReductionProxyBypassDuration(
+ const net::HttpResponseHeaders* headers,
+ const std::string& action_prefix,
+ base::TimeDelta* duration);
+
+} // namespace data_reduction_proxy
+#endif // COMPONENTS_DATA_REDUCTION_PROXY_COMMON_DATA_REDUCTION_PROXY_HEADERS_H_