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_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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 | 24 |
25 class AddressList; | 25 class AddressList; |
26 class ClientSocketHandle; | 26 class ClientSocketHandle; |
27 class HttpStream; | 27 class HttpStream; |
28 class IOBuffer;; | 28 class IOBuffer;; |
29 | 29 |
30 class HttpProxyClientSocket : public ClientSocket { | 30 class HttpProxyClientSocket : public ClientSocket { |
31 public: | 31 public: |
32 // Takes ownership of |transport_socket|, which should already be connected | 32 // Takes ownership of |auth| and |transport_socket|, which should already be |
33 // by the time Connect() is called. If tunnel is true then on Connect() | 33 // connected by the time Connect() is called. If tunnel is true then on |
34 // this socket will establish an Http tunnel. | 34 // Connect() this socket will establish an Http tunnel. |
35 HttpProxyClientSocket(ClientSocketHandle* transport_socket, | 35 HttpProxyClientSocket(ClientSocketHandle* transport_socket, |
36 const GURL& request_url, const HostPortPair& endpoint, | 36 const GURL& request_url, const HostPortPair& endpoint, |
37 const scoped_refptr<HttpAuthController>& auth, | 37 HttpAuthController* auth, bool tunnel); |
38 bool tunnel); | |
39 | 38 |
40 // On destruction Disconnect() is called. | 39 // On destruction Disconnect() is called. |
41 virtual ~HttpProxyClientSocket(); | 40 virtual ~HttpProxyClientSocket(); |
42 | 41 |
43 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then | 42 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then |
44 // credentials should be added to the HttpAuthController before calling | 43 // credentials should be added to the HttpAuthController before calling |
45 // RestartWithAuth. | 44 // RestartWithAuth. |
46 int RestartWithAuth(CompletionCallback* callback); | 45 int RestartWithAuth(const std::wstring& username, |
| 46 const std::wstring& password, |
| 47 CompletionCallback* callback); |
47 | 48 |
48 // Indicates if RestartWithAuth needs to be called. i.e. if Connect | 49 // Indicates if RestartWithAuth needs to be called. i.e. if Connect |
49 // returned PROXY_AUTH_REQUESTED. Only valid after Connect has been called. | 50 // returned PROXY_AUTH_REQUESTED. Only valid after Connect has been called. |
50 bool NeedsRestartWithAuth() const; | 51 bool NeedsRestartWithAuth() const; |
51 | 52 |
52 const HttpResponseInfo* GetResponseInfo() const { | 53 const HttpResponseInfo* GetResponseInfo() const { |
53 return response_.headers ? &response_ : NULL; | 54 return response_.headers ? &response_ : NULL; |
54 } | 55 } |
55 | 56 |
| 57 // Release the auth controller back to the caller. This is used when |
| 58 // we need to continue the auth conversation, but the connection doesn't |
| 59 // support keep alive. |
| 60 HttpAuthController* ReleaseAuthController() { |
| 61 return auth_.release(); |
| 62 } |
| 63 |
56 // ClientSocket methods: | 64 // ClientSocket methods: |
57 | 65 |
58 // Authenticates to the Http Proxy and then passes data freely. | 66 // Authenticates to the Http Proxy and then passes data freely. |
59 virtual int Connect(CompletionCallback* callback); | 67 virtual int Connect(CompletionCallback* callback); |
60 virtual void Disconnect(); | 68 virtual void Disconnect(); |
61 virtual bool IsConnected() const; | 69 virtual bool IsConnected() const; |
62 virtual bool IsConnectedAndIdle() const; | 70 virtual bool IsConnectedAndIdle() const; |
63 virtual const BoundNetLog& NetLog() const { return net_log_; } | 71 virtual const BoundNetLog& NetLog() const { return net_log_; } |
64 | 72 |
65 // Socket methods: | 73 // Socket methods: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 131 |
124 scoped_ptr<HttpStream> http_stream_; | 132 scoped_ptr<HttpStream> http_stream_; |
125 scoped_refptr<IOBuffer> drain_buf_; | 133 scoped_refptr<IOBuffer> drain_buf_; |
126 | 134 |
127 // Stores the underlying socket. | 135 // Stores the underlying socket. |
128 const scoped_ptr<ClientSocketHandle> transport_; | 136 const scoped_ptr<ClientSocketHandle> transport_; |
129 | 137 |
130 // The hostname and port of the endpoint. This is not necessarily the one | 138 // The hostname and port of the endpoint. This is not necessarily the one |
131 // specified by the URL, due to Alternate-Protocol or fixed testing ports. | 139 // specified by the URL, due to Alternate-Protocol or fixed testing ports. |
132 const HostPortPair endpoint_; | 140 const HostPortPair endpoint_; |
133 scoped_refptr<HttpAuthController> auth_; | 141 scoped_ptr<HttpAuthController> auth_; |
134 const bool tunnel_; | 142 const bool tunnel_; |
135 | 143 |
136 std::string request_headers_; | 144 std::string request_headers_; |
137 | 145 |
138 const BoundNetLog net_log_; | 146 const BoundNetLog net_log_; |
139 | 147 |
140 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); | 148 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); |
141 }; | 149 }; |
142 | 150 |
143 } // namespace net | 151 } // namespace net |
144 | 152 |
145 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ | 153 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ |
OLD | NEW |