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

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

Issue 517693002: Add embedder-specific headers to HTTP CONNECT tunnel request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests 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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace base { 14 namespace base {
15 class SingleThreadTaskRunner; 15 class SingleThreadTaskRunner;
16 } 16 }
17 17
18 namespace net { 18 namespace net {
19 class HostPortPair;
19 class HttpRequestHeaders; 20 class HttpRequestHeaders;
20 class HttpResponseHeaders; 21 class HttpResponseHeaders;
21 class ProxyServer; 22 class ProxyServer;
22 class URLRequest; 23 class URLRequest;
23 } 24 }
24 25
25 namespace data_reduction_proxy { 26 namespace data_reduction_proxy {
26 27
27 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID)
28 extern const char kAndroidWebViewProtocolVersion[]; 29 extern const char kAndroidWebViewProtocolVersion[];
(...skipping 12 matching lines...) Expand all
41 DataReductionProxyAuthRequestHandler( 42 DataReductionProxyAuthRequestHandler(
42 const std::string& client, 43 const std::string& client,
43 const std::string& version, 44 const std::string& version,
44 DataReductionProxyParams* params, 45 DataReductionProxyParams* params,
45 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); 46 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
46 47
47 virtual ~DataReductionProxyAuthRequestHandler(); 48 virtual ~DataReductionProxyAuthRequestHandler();
48 49
49 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction 50 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction
50 // proxy authentication credentials. Only adds this header if the provided 51 // proxy authentication credentials. Only adds this header if the provided
51 // |proxy_server| is a data reduction proxy. Must be called on the IO thread. 52 // |proxy_server| is a data reduction proxy and not the data reduction proxy's
53 // CONNECT server. Must be called on the IO thread.
52 void MaybeAddRequestHeader(net::URLRequest* request, 54 void MaybeAddRequestHeader(net::URLRequest* request,
53 const net::ProxyServer& proxy_server, 55 const net::ProxyServer& proxy_server,
54 net::HttpRequestHeaders* request_headers); 56 net::HttpRequestHeaders* request_headers);
55 57
58 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction
59 // proxy authentication credentials. Only adds this header if the provided
60 // |proxy_server| is the data reduction proxy's CONNECT server. Must be called
61 // on the IO thread.
62 void MaybeAddProxyTunnelRequestHandler(
63 const net::HostPortPair& proxy_server,
64 net::HttpRequestHeaders* request_headers);
65
56 // Sets a new authentication key. This must be called for platforms that do 66 // Sets a new authentication key. This must be called for platforms that do
57 // not have a default key defined. See the constructor implementation for 67 // not have a default key defined. See the constructor implementation for
58 // those platforms. Must be called on the UI thread. 68 // those platforms. Must be called on the UI thread.
59 void SetKeyOnUI(const std::string& key); 69 void SetKeyOnUI(const std::string& key);
60 70
61 protected: 71 protected:
62 void Init(); 72 void Init();
63 void InitAuthenticationOnUI(const std::string& key); 73 void InitAuthenticationOnUI(const std::string& key);
64 74
65 void AddAuthorizationHeader(net::HttpRequestHeaders* headers); 75 void AddAuthorizationHeader(net::HttpRequestHeaders* headers);
(...skipping 19 matching lines...) Expand all
85 // Stores the supplied key and sets up credentials suitable for authenticating 95 // Stores the supplied key and sets up credentials suitable for authenticating
86 // with the data reduction proxy. 96 // with the data reduction proxy.
87 void InitAuthentication(const std::string& key); 97 void InitAuthentication(const std::string& key);
88 98
89 // Generates a session ID and credentials suitable for authenticating with 99 // Generates a session ID and credentials suitable for authenticating with
90 // the data reduction proxy. 100 // the data reduction proxy.
91 void ComputeCredentials(const base::Time& now, 101 void ComputeCredentials(const base::Time& now,
92 std::string* session, 102 std::string* session,
93 std::string* credentials); 103 std::string* credentials);
94 104
105 // Adds authentication headers only if |expects_ssl| is true and
106 // |proxy_server| is a data reduction proxy used for ssl tunneling via
107 // HTTP CONNECT, or |expect_ssl| is false and |proxy_server| is a data
108 // reduction proxy for HTTP traffic.
109 void MaybeAddRequestHeaderImpl(const net::HostPortPair& proxy_server,
110 bool expect_ssl,
111 net::HttpRequestHeaders* request_headers);
112
95 // Authentication state. 113 // Authentication state.
96 std::string key_; 114 std::string key_;
97 115
98 // Lives on the IO thread. 116 // Lives on the IO thread.
99 std::string session_; 117 std::string session_;
100 std::string credentials_; 118 std::string credentials_;
101 119
102 // Name of the client and version of the data reduction proxy protocol to use. 120 // Name of the client and version of the data reduction proxy protocol to use.
103 // Both live on the IO thread. 121 // Both live on the IO thread.
104 std::string client_; 122 std::string client_;
105 std::string version_; 123 std::string version_;
106 124
107 // The last time the session was updated. Used to ensure that a session is 125 // The last time the session was updated. Used to ensure that a session is
108 // never used for more than twenty-four hours. 126 // never used for more than twenty-four hours.
109 base::Time last_update_time_; 127 base::Time last_update_time_;
110 128
111 DataReductionProxyParams* data_reduction_proxy_params_; 129 DataReductionProxyParams* data_reduction_proxy_params_;
112 130
113 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 131 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
114 132
115 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); 133 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler);
116 }; 134 };
117 135
118 } // namespace data_reduction_proxy 136 } // namespace data_reduction_proxy
119 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_ 137 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698