Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1207)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h

Issue 791493015: Adding q=low to the Chrome-Proxy request header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase test fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h
similarity index 75%
rename from components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h
rename to components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h
index 4675ec4e245b16a327fe2a4a05f09921e54b9084..a862cd67f1fc471728ab9aadbb705b0fbc51765f 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h
@@ -5,6 +5,9 @@
#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUEST_HANDLER_H_
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUEST_HANDLER_H_
+#include <map>
+#include <string>
+
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
@@ -24,6 +27,13 @@ class URLRequest;
namespace data_reduction_proxy {
+const char kSessionHeaderOption[] = "ps";
+const char kCredentialsHeaderOption[] = "sid";
+const char kBuildNumberHeaderOption[] = "b";
+const char kPatchNumberHeaderOption[] = "p";
+const char kClientHeaderOption[] = "c";
+const char kLoFiHeaderOption[] = "q";
+
#if defined(OS_ANDROID)
extern const char kAndroidWebViewProtocolVersion[];
#endif
@@ -50,18 +60,18 @@ typedef enum {
class DataReductionProxyParams;
-class DataReductionProxyAuthRequestHandler {
+class DataReductionProxyRequestOptions {
public:
static bool IsKeySetOnCommandLine();
- // Constructs a DataReductionProxyAuthRequestHandler object with the given
+ // Constructs a DataReductionProxyRequestOptions object with the given
// client type, params, and network task runner.
- DataReductionProxyAuthRequestHandler(
+ DataReductionProxyRequestOptions(
Client client,
DataReductionProxyParams* params,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
- virtual ~DataReductionProxyAuthRequestHandler();
+ virtual ~DataReductionProxyRequestOptions();
// Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction
// proxy authentication credentials. Only adds this header if the provided
@@ -91,7 +101,7 @@ class DataReductionProxyAuthRequestHandler {
protected:
void Init();
- void AddAuthorizationHeader(net::HttpRequestHeaders* headers);
+ void SetHeader(net::HttpRequestHeaders* headers);
// Returns a UTF16 string that's the hash of the configured authentication
// |key| and |salt|. Returns an empty UTF16 string if no key is configured or
@@ -106,21 +116,25 @@ class DataReductionProxyAuthRequestHandler {
virtual std::string GetDefaultKey() const;
// Visible for testing.
- DataReductionProxyAuthRequestHandler(
+ DataReductionProxyRequestOptions(
Client client,
const std::string& version,
DataReductionProxyParams* params,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
private:
- FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyRequestOptionsTest,
AuthorizationOnIOThread);
- FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyRequestOptionsTest,
AuthorizationIgnoresEmptyKey);
- FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyRequestOptionsTest,
AuthorizationBogusVersion);
- FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyRequestOptionsTest,
AuthHashForSalt);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyRequestOptionsTest,
+ AuthorizationLoFi);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyRequestOptionsTest,
+ AuthorizationLoFiOffThenOn);
// Returns the version of Chromium that is being used.
std::string ChromiumVersion() const;
@@ -131,12 +145,22 @@ class DataReductionProxyAuthRequestHandler {
std::string* build,
std::string* patch) const;
+ // Gets the version and client values and updates them in |header_options_|.
+ void UpdateVersion(const Client& client, const std::string& version);
+
+ // Updates the value of LoFi in |header_options_| and regenerates the header
+ // if necessary.
+ void UpdateLoFi();
+
// Generates a session ID and credentials suitable for authenticating with
// the data reduction proxy.
void ComputeCredentials(const base::Time& now,
std::string* session,
std::string* credentials);
+ // Generates and updates the session ID and credentials in |header_options_|.
+ void UpdateCredentials();
+
// Adds authentication headers only if |expects_ssl| is true and
// |proxy_server| is a data reduction proxy used for ssl tunneling via
// HTTP CONNECT, or |expect_ssl| is false and |proxy_server| is a data
@@ -145,18 +169,16 @@ class DataReductionProxyAuthRequestHandler {
bool expect_ssl,
net::HttpRequestHeaders* request_headers);
- // Authentication state.
- std::string key_;
+ // Regenerates the |header_value_| string which is concatenated to the
+ // Chrome-proxy header.
+ void RegenerateRequestHeaderValue();
- // Lives on the IO thread.
- std::string session_;
- std::string credentials_;
+ // Map and string of the request options to be added to the header.
+ std::map<std::string, std::string> header_options_;
+ std::string header_value_;
- // Name of the client and version of the data reduction proxy protocol to use.
- // Both live on the IO thread.
- std::string client_;
- std::string build_number_;
- std::string patch_number_;
+ // Authentication state.
+ std::string key_;
// The last time the session was updated. Used to ensure that a session is
// never used for more than twenty-four hours.
@@ -166,7 +188,7 @@ class DataReductionProxyAuthRequestHandler {
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
- DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler);
+ DISALLOW_COPY_AND_ASSIGN(DataReductionProxyRequestOptions);
};
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698