OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
7 | 7 |
8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "net/socket/ssl_client_socket.h" | 37 #include "net/socket/ssl_client_socket.h" |
38 #include "net/socket/tcp_client_socket.h" | 38 #include "net/socket/tcp_client_socket.h" |
39 #include "net/socket_stream/socket_stream_metrics.h" | 39 #include "net/socket_stream/socket_stream_metrics.h" |
40 #include "net/url_request/url_request.h" | 40 #include "net/url_request/url_request.h" |
41 | 41 |
42 static const int kMaxPendingSendAllowed = 32768; // 32 kilobytes. | 42 static const int kMaxPendingSendAllowed = 32768; // 32 kilobytes. |
43 static const int kReadBufferSize = 4096; | 43 static const int kReadBufferSize = 4096; |
44 | 44 |
45 namespace net { | 45 namespace net { |
46 | 46 |
| 47 int SocketStream::Delegate::OnStartOpenConnection( |
| 48 SocketStream* socket, const CompletionCallback& callback) { |
| 49 return OK; |
| 50 } |
| 51 |
| 52 void SocketStream::Delegate::OnAuthRequired(SocketStream* socket, |
| 53 AuthChallengeInfo* auth_info) { |
| 54 // By default, no credential is available and close the connection. |
| 55 socket->Close(); |
| 56 } |
| 57 |
| 58 void SocketStream::Delegate::OnSSLCertificateError( |
| 59 SocketStream* socket, |
| 60 const SSLInfo& ssl_info, |
| 61 bool fatal) { |
| 62 socket->CancelWithSSLError(ssl_info); |
| 63 } |
| 64 |
| 65 bool SocketStream::Delegate::CanGetCookies(SocketStream* socket, |
| 66 const GURL& url) { |
| 67 return true; |
| 68 } |
| 69 |
| 70 bool SocketStream::Delegate::CanSetCookie(SocketStream* request, |
| 71 const GURL& url, |
| 72 const std::string& cookie_line, |
| 73 CookieOptions* options) { |
| 74 return true; |
| 75 } |
| 76 |
47 SocketStream::ResponseHeaders::ResponseHeaders() : IOBuffer() {} | 77 SocketStream::ResponseHeaders::ResponseHeaders() : IOBuffer() {} |
48 | 78 |
49 void SocketStream::ResponseHeaders::Realloc(size_t new_size) { | 79 void SocketStream::ResponseHeaders::Realloc(size_t new_size) { |
50 headers_.reset(static_cast<char*>(realloc(headers_.release(), new_size))); | 80 headers_.reset(static_cast<char*>(realloc(headers_.release(), new_size))); |
51 } | 81 } |
52 | 82 |
53 SocketStream::ResponseHeaders::~ResponseHeaders() { data_ = NULL; } | 83 SocketStream::ResponseHeaders::~ResponseHeaders() { data_ = NULL; } |
54 | 84 |
55 SocketStream::SocketStream(const GURL& url, Delegate* delegate) | 85 SocketStream::SocketStream(const GURL& url, Delegate* delegate) |
56 : delegate_(delegate), | 86 : delegate_(delegate), |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 FROM_HERE, | 296 FROM_HERE, |
267 base::Bind(&SocketStream::DoLoop, this, OK)); | 297 base::Bind(&SocketStream::DoLoop, this, OK)); |
268 } | 298 } |
269 | 299 |
270 SocketStream::~SocketStream() { | 300 SocketStream::~SocketStream() { |
271 set_context(NULL); | 301 set_context(NULL); |
272 DCHECK(!delegate_); | 302 DCHECK(!delegate_); |
273 DCHECK(!pac_request_); | 303 DCHECK(!pac_request_); |
274 } | 304 } |
275 | 305 |
| 306 SocketStream::RequestHeaders::~RequestHeaders() { data_ = NULL; } |
| 307 |
276 void SocketStream::set_addresses(const AddressList& addresses) { | 308 void SocketStream::set_addresses(const AddressList& addresses) { |
277 addresses_ = addresses; | 309 addresses_ = addresses; |
278 } | 310 } |
279 | 311 |
280 void SocketStream::DoClose() { | 312 void SocketStream::DoClose() { |
281 closing_ = true; | 313 closing_ = true; |
282 // If next_state_ is STATE_TCP_CONNECT, it's waiting other socket | 314 // If next_state_ is STATE_TCP_CONNECT, it's waiting other socket |
283 // establishing connection. If next_state_ is STATE_AUTH_REQUIRED, it's | 315 // establishing connection. If next_state_ is STATE_AUTH_REQUIRED, it's |
284 // waiting for restarting. In these states, we'll close the SocketStream | 316 // waiting for restarting. In these states, we'll close the SocketStream |
285 // now. | 317 // now. |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 | 1321 |
1290 SSLConfigService* SocketStream::ssl_config_service() const { | 1322 SSLConfigService* SocketStream::ssl_config_service() const { |
1291 return context_->ssl_config_service(); | 1323 return context_->ssl_config_service(); |
1292 } | 1324 } |
1293 | 1325 |
1294 ProxyService* SocketStream::proxy_service() const { | 1326 ProxyService* SocketStream::proxy_service() const { |
1295 return context_->proxy_service(); | 1327 return context_->proxy_service(); |
1296 } | 1328 } |
1297 | 1329 |
1298 } // namespace net | 1330 } // namespace net |
OLD | NEW |