OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ | 5 #ifndef NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ |
6 #define NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ | 6 #define NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <list> | 10 #include <list> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
17 #include "net/http/http_auth_controller.h" | 17 #include "net/http/http_auth_controller.h" |
| 18 #include "net/http/http_proxy_tunnel_client_socket.h" |
18 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
19 #include "net/http/http_request_info.h" | 20 #include "net/http/http_request_info.h" |
20 #include "net/http/http_response_info.h" | 21 #include "net/http/http_response_info.h" |
21 #include "net/socket/client_socket.h" | 22 #include "net/spdy/spdy_http_stream.h" |
22 #include "net/spdy/spdy_protocol.h" | 23 #include "net/spdy/spdy_protocol.h" |
23 #include "net/spdy/spdy_session.h" | 24 #include "net/spdy/spdy_session.h" |
24 #include "net/spdy/spdy_stream.h" | 25 #include "net/spdy/spdy_stream.h" |
25 | 26 |
26 | 27 |
27 class GURL; | 28 class GURL; |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 | 31 |
31 class AddressList; | 32 class AddressList; |
32 class ClientSocketHandle; | 33 class ClientSocketHandle; |
33 class HttpStream; | 34 class HttpStream; |
34 class IOBuffer; | 35 class IOBuffer; |
35 class SpdySession; | 36 class SpdySession; |
36 class SpdyStream; | 37 class SpdyStream; |
37 | 38 |
38 class SpdyProxyClientSocket : public ClientSocket, public SpdyStream::Delegate { | 39 class SpdyProxyClientSocket : public HttpProxyTunnelClientSocket, |
| 40 public SpdyStream::Delegate { |
39 public: | 41 public: |
40 // Create a socket on top of the |spdy_stream| by sending a SYN_STREAM | 42 // Create a socket on top of the |spdy_stream| by sending a SYN_STREAM |
41 // CONNECT frame for |endpoint|. After the SYN_REPLY is received, | 43 // CONNECT frame for |endpoint|. After the SYN_REPLY is received, |
42 // any data read/written to the socket will be transferred in data | 44 // any data read/written to the socket will be transferred in data |
43 // frames. | 45 // frames. |
44 SpdyProxyClientSocket(SpdyStream* spdy_stream, | 46 SpdyProxyClientSocket(SpdyStream* spdy_stream, |
45 const std::string& user_agent, | 47 const std::string& user_agent, |
46 const HostPortPair& endpoint, | 48 const HostPortPair& endpoint, |
47 const GURL& url, | 49 const GURL& url, |
48 const HostPortPair& proxy_server, | 50 const HostPortPair& proxy_server, |
49 HttpAuthCache* auth_cache, | 51 HttpAuthCache* auth_cache, |
50 HttpAuthHandlerFactory* auth_handler_factory); | 52 HttpAuthHandlerFactory* auth_handler_factory); |
51 | 53 |
52 | 54 |
53 // On destruction Disconnect() is called. | 55 // On destruction Disconnect() is called. |
54 virtual ~SpdyProxyClientSocket(); | 56 virtual ~SpdyProxyClientSocket(); |
55 | 57 |
56 const scoped_refptr<HttpAuthController>& auth_controller() { | 58 const scoped_refptr<HttpAuthController>& auth_controller() { |
57 return auth_; | 59 return auth_; |
58 } | 60 } |
59 | 61 |
60 const HttpResponseInfo* GetConnectResponseInfo() const { | 62 // HttpProxyTunnelClientSocket methods: |
| 63 |
| 64 virtual const HttpResponseInfo* GetConnectResponseInfo() const { |
61 return response_.headers ? &response_ : NULL; | 65 return response_.headers ? &response_ : NULL; |
62 } | 66 } |
63 | 67 |
| 68 // In the event of a non-200 response to the CONNECT request, this |
| 69 // method may be called to return an HttpStream in order to read |
| 70 // the response body. |
| 71 virtual HttpStream* GetConnectResponseStream(); |
| 72 |
64 // ClientSocket methods: | 73 // ClientSocket methods: |
65 | 74 |
66 virtual int Connect(CompletionCallback* callback); | 75 virtual int Connect(CompletionCallback* callback); |
67 virtual void Disconnect(); | 76 virtual void Disconnect(); |
68 virtual bool IsConnected() const; | 77 virtual bool IsConnected() const; |
69 virtual bool IsConnectedAndIdle() const; | 78 virtual bool IsConnectedAndIdle() const; |
70 virtual const BoundNetLog& NetLog() const { return net_log_; } | 79 virtual const BoundNetLog& NetLog() const { return net_log_; } |
71 virtual void SetSubresourceSpeculation(); | 80 virtual void SetSubresourceSpeculation(); |
72 virtual void SetOmniboxSpeculation(); | 81 virtual void SetOmniboxSpeculation(); |
73 virtual bool WasEverUsed() const; | 82 virtual bool WasEverUsed() const; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // User specified number of bytes to be written. | 177 // User specified number of bytes to be written. |
169 int write_buffer_len_; | 178 int write_buffer_len_; |
170 // Number of bytes written which have not been confirmed | 179 // Number of bytes written which have not been confirmed |
171 int write_bytes_outstanding_; | 180 int write_bytes_outstanding_; |
172 | 181 |
173 // True if read has ever returned zero for eof. | 182 // True if read has ever returned zero for eof. |
174 bool eof_has_been_read_; | 183 bool eof_has_been_read_; |
175 // True if the transport socket has ever sent data. | 184 // True if the transport socket has ever sent data. |
176 bool was_ever_used_; | 185 bool was_ever_used_; |
177 | 186 |
| 187 scoped_ptr<SpdyHttpStream> response_stream_; |
| 188 |
178 const BoundNetLog net_log_; | 189 const BoundNetLog net_log_; |
179 | 190 |
180 DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocket); | 191 DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocket); |
181 }; | 192 }; |
182 | 193 |
183 } // namespace net | 194 } // namespace net |
184 | 195 |
185 #endif // NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ | 196 #endif // NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ |
OLD | NEW |