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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h

Issue 533003002: Use chromium version for data reduction proxy version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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_AUTH_REQUES T_HANDLER_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 22 matching lines...) Expand all
33 extern const char kClientChromeAndroid[]; 33 extern const char kClientChromeAndroid[];
34 extern const char kClientChromeIOS[]; 34 extern const char kClientChromeIOS[];
35 35
36 class DataReductionProxyParams; 36 class DataReductionProxyParams;
37 37
38 class DataReductionProxyAuthRequestHandler { 38 class DataReductionProxyAuthRequestHandler {
39 public: 39 public:
40 static bool IsKeySetOnCommandLine(); 40 static bool IsKeySetOnCommandLine();
41 41
42 // Constructs a DataReductionProxyAuthRequestHandler object with the given 42 // Constructs a DataReductionProxyAuthRequestHandler object with the given
43 // client, version, params, and network task runner. The Chromium |version| is 43 // client type, params, and network task runner.
44 // expected to be of the form "xx.xx.xx.xx". If it isn't of this form,
45 // |build_number_| and |patch_number_| are set to empty strings and not
46 // included in the header. http://crbug.com/410127 will change this so that
47 // the version is retrieved inside this constructor.
48 DataReductionProxyAuthRequestHandler( 44 DataReductionProxyAuthRequestHandler(
49 const std::string& client, 45 const std::string& client,
50 const std::string& version,
51 DataReductionProxyParams* params, 46 DataReductionProxyParams* params,
52 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); 47 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
53 48
54 virtual ~DataReductionProxyAuthRequestHandler(); 49 virtual ~DataReductionProxyAuthRequestHandler();
55 50
56 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction 51 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction
57 // proxy authentication credentials. Only adds this header if the provided 52 // proxy authentication credentials. Only adds this header if the provided
58 // |proxy_server| is a data reduction proxy and not the data reduction proxy's 53 // |proxy_server| is a data reduction proxy and not the data reduction proxy's
59 // CONNECT server. Must be called on the IO thread. 54 // CONNECT server. Must be called on the IO thread.
60 void MaybeAddRequestHeader(net::URLRequest* request, 55 void MaybeAddRequestHeader(net::URLRequest* request,
(...skipping 24 matching lines...) Expand all
85 // the data reduction proxy feature isn't available. 80 // the data reduction proxy feature isn't available.
86 static base::string16 AuthHashForSalt(int64 salt, 81 static base::string16 AuthHashForSalt(int64 salt,
87 const std::string& key); 82 const std::string& key);
88 // Visible for testing. 83 // Visible for testing.
89 virtual base::Time Now() const; 84 virtual base::Time Now() const;
90 virtual void RandBytes(void* output, size_t length); 85 virtual void RandBytes(void* output, size_t length);
91 86
92 // Visible for testing. 87 // Visible for testing.
93 virtual std::string GetDefaultKey() const; 88 virtual std::string GetDefaultKey() const;
94 89
90 // Visible for testing.
91 DataReductionProxyAuthRequestHandler(
92 const std::string& client,
93 const std::string& version,
94 DataReductionProxyParams* params,
95 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
96
95 private: 97 private:
96 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, 98 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
97 Authorization); 99 Authorization);
98 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, 100 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
99 AuthorizationBogusVersion); 101 AuthorizationBogusVersion);
100 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, 102 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest,
101 AuthHashForSalt); 103 AuthHashForSalt);
102 104
105 // Returns the version of Chromium that is being used.
106 std::string ChromiumVersion() const;
107
103 // Returns the build and patch numbers of |version|. If |version| isn't of the 108 // Returns the build and patch numbers of |version|. If |version| isn't of the
104 // form xx.xx.xx.xx build and patch are not modified. 109 // form xx.xx.xx.xx build and patch are not modified.
105 void GetChromiumBuildAndPatch(const std::string& version, 110 void GetChromiumBuildAndPatch(const std::string& version,
106 std::string* build, 111 std::string* build,
107 std::string* patch); 112 std::string* patch) const;
108 113
109 // Stores the supplied key and sets up credentials suitable for authenticating 114 // Stores the supplied key and sets up credentials suitable for authenticating
110 // with the data reduction proxy. 115 // with the data reduction proxy.
111 void InitAuthentication(const std::string& key); 116 void InitAuthentication(const std::string& key);
112 117
113 // Generates a session ID and credentials suitable for authenticating with 118 // Generates a session ID and credentials suitable for authenticating with
114 // the data reduction proxy. 119 // the data reduction proxy.
115 void ComputeCredentials(const base::Time& now, 120 void ComputeCredentials(const base::Time& now,
116 std::string* session, 121 std::string* session,
117 std::string* credentials); 122 std::string* credentials);
(...skipping 25 matching lines...) Expand all
143 148
144 DataReductionProxyParams* data_reduction_proxy_params_; 149 DataReductionProxyParams* data_reduction_proxy_params_;
145 150
146 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 151 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
147 152
148 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); 153 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler);
149 }; 154 };
150 155
151 } // namespace data_reduction_proxy 156 } // namespace data_reduction_proxy
152 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_ 157 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698