OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ | 5 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ |
6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ | 6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const HostPortPair& proxy_server, | 43 const HostPortPair& proxy_server, |
44 HttpAuthCache* http_auth_cache, | 44 HttpAuthCache* http_auth_cache, |
45 HttpAuthHandlerFactory* http_auth_handler_factory, | 45 HttpAuthHandlerFactory* http_auth_handler_factory, |
46 bool tunnel, | 46 bool tunnel, |
47 bool using_spdy, | 47 bool using_spdy, |
48 bool is_https_proxy); | 48 bool is_https_proxy); |
49 | 49 |
50 // On destruction Disconnect() is called. | 50 // On destruction Disconnect() is called. |
51 virtual ~HttpProxyClientSocket(); | 51 virtual ~HttpProxyClientSocket(); |
52 | 52 |
| 53 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then |
| 54 // credentials should be added to the HttpAuthController before calling |
| 55 // RestartWithAuth. |
| 56 int RestartWithAuth(OldCompletionCallback* callback); |
| 57 |
| 58 const scoped_refptr<HttpAuthController>& auth_controller() { |
| 59 return auth_; |
| 60 } |
| 61 |
53 bool using_spdy() { | 62 bool using_spdy() { |
54 return using_spdy_; | 63 return using_spdy_; |
55 } | 64 } |
56 | 65 |
57 // ProxyClientSocket methods: | 66 // ProxyClientSocket methods: |
58 virtual const HttpResponseInfo* GetConnectResponseInfo() const OVERRIDE; | 67 virtual const HttpResponseInfo* GetConnectResponseInfo() const OVERRIDE; |
59 virtual HttpStream* CreateConnectResponseStream() OVERRIDE; | 68 virtual HttpStream* CreateConnectResponseStream() OVERRIDE; |
60 virtual int RestartWithAuth(OldCompletionCallback* callback) OVERRIDE; | |
61 virtual const scoped_refptr<HttpAuthController>& auth_controller() OVERRIDE; | |
62 | 69 |
63 // StreamSocket methods: | 70 // StreamSocket methods: |
64 virtual int Connect(OldCompletionCallback* callback) OVERRIDE; | 71 virtual int Connect(OldCompletionCallback* callback) OVERRIDE; |
65 virtual void Disconnect() OVERRIDE; | 72 virtual void Disconnect() OVERRIDE; |
66 virtual bool IsConnected() const OVERRIDE; | 73 virtual bool IsConnected() const OVERRIDE; |
67 virtual bool IsConnectedAndIdle() const OVERRIDE; | 74 virtual bool IsConnectedAndIdle() const OVERRIDE; |
68 virtual const BoundNetLog& NetLog() const OVERRIDE; | 75 virtual const BoundNetLog& NetLog() const OVERRIDE; |
69 virtual void SetSubresourceSpeculation() OVERRIDE; | 76 virtual void SetSubresourceSpeculation() OVERRIDE; |
70 virtual void SetOmniboxSpeculation() OVERRIDE; | 77 virtual void SetOmniboxSpeculation() OVERRIDE; |
71 virtual bool WasEverUsed() const OVERRIDE; | 78 virtual bool WasEverUsed() const OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... |
89 enum State { | 96 enum State { |
90 STATE_NONE, | 97 STATE_NONE, |
91 STATE_GENERATE_AUTH_TOKEN, | 98 STATE_GENERATE_AUTH_TOKEN, |
92 STATE_GENERATE_AUTH_TOKEN_COMPLETE, | 99 STATE_GENERATE_AUTH_TOKEN_COMPLETE, |
93 STATE_SEND_REQUEST, | 100 STATE_SEND_REQUEST, |
94 STATE_SEND_REQUEST_COMPLETE, | 101 STATE_SEND_REQUEST_COMPLETE, |
95 STATE_READ_HEADERS, | 102 STATE_READ_HEADERS, |
96 STATE_READ_HEADERS_COMPLETE, | 103 STATE_READ_HEADERS_COMPLETE, |
97 STATE_DRAIN_BODY, | 104 STATE_DRAIN_BODY, |
98 STATE_DRAIN_BODY_COMPLETE, | 105 STATE_DRAIN_BODY_COMPLETE, |
| 106 STATE_TCP_RESTART, |
| 107 STATE_TCP_RESTART_COMPLETE, |
99 STATE_DONE, | 108 STATE_DONE, |
100 }; | 109 }; |
101 | 110 |
102 // The size in bytes of the buffer we use to drain the response body that | 111 // The size in bytes of the buffer we use to drain the response body that |
103 // we want to throw away. The response body is typically a small error | 112 // we want to throw away. The response body is typically a small error |
104 // page just a few hundred bytes long. | 113 // page just a few hundred bytes long. |
105 static const int kDrainBodyBufferSize = 1024; | 114 static const int kDrainBodyBufferSize = 1024; |
106 | 115 |
107 int PrepareForAuthRestart(); | 116 int PrepareForAuthRestart(); |
108 int DidDrainBodyForAuthRestart(bool keep_alive); | 117 int DidDrainBodyForAuthRestart(bool keep_alive); |
109 | 118 |
| 119 int HandleAuthChallenge(); |
| 120 |
110 void LogBlockedTunnelResponse(int response_code) const; | 121 void LogBlockedTunnelResponse(int response_code) const; |
111 | 122 |
112 void DoCallback(int result); | 123 void DoCallback(int result); |
113 void OnIOComplete(int result); | 124 void OnIOComplete(int result); |
114 | 125 |
115 int DoLoop(int last_io_result); | 126 int DoLoop(int last_io_result); |
116 int DoGenerateAuthToken(); | 127 int DoGenerateAuthToken(); |
117 int DoGenerateAuthTokenComplete(int result); | 128 int DoGenerateAuthTokenComplete(int result); |
118 int DoSendRequest(); | 129 int DoSendRequest(); |
119 int DoSendRequestComplete(int result); | 130 int DoSendRequestComplete(int result); |
120 int DoReadHeaders(); | 131 int DoReadHeaders(); |
121 int DoReadHeadersComplete(int result); | 132 int DoReadHeadersComplete(int result); |
122 int DoDrainBody(); | 133 int DoDrainBody(); |
123 int DoDrainBodyComplete(int result); | 134 int DoDrainBodyComplete(int result); |
| 135 int DoTCPRestart(); |
| 136 int DoTCPRestartComplete(int result); |
124 | 137 |
125 OldCompletionCallbackImpl<HttpProxyClientSocket> io_callback_; | 138 OldCompletionCallbackImpl<HttpProxyClientSocket> io_callback_; |
126 State next_state_; | 139 State next_state_; |
127 | 140 |
128 // Stores the callback to the layer above, called on completing Connect(). | 141 // Stores the callback to the layer above, called on completing Connect(). |
129 OldCompletionCallback* user_callback_; | 142 OldCompletionCallback* user_callback_; |
130 | 143 |
131 HttpRequestInfo request_; | 144 HttpRequestInfo request_; |
132 HttpResponseInfo response_; | 145 HttpResponseInfo response_; |
133 | 146 |
(...skipping 18 matching lines...) Expand all Loading... |
152 HttpRequestHeaders request_headers_; | 165 HttpRequestHeaders request_headers_; |
153 | 166 |
154 const BoundNetLog net_log_; | 167 const BoundNetLog net_log_; |
155 | 168 |
156 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); | 169 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); |
157 }; | 170 }; |
158 | 171 |
159 } // namespace net | 172 } // namespace net |
160 | 173 |
161 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ | 174 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ |
OLD | NEW |