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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 | 624 |
625 // TODO(toyoshim): Check server advertisement of SPDY through the HTTP | 625 // TODO(toyoshim): Check server advertisement of SPDY through the HTTP |
626 // Alternate-Protocol header, then switch to SPDY if SPDY is available. | 626 // Alternate-Protocol header, then switch to SPDY if SPDY is available. |
627 // Usually we already have a session to the SPDY server because JavaScript | 627 // Usually we already have a session to the SPDY server because JavaScript |
628 // running WebSocket itself would be served by SPDY. But, in some situation | 628 // running WebSocket itself would be served by SPDY. But, in some situation |
629 // (E.g. Used by Chrome Extensions or used for cross origin connection), this | 629 // (E.g. Used by Chrome Extensions or used for cross origin connection), this |
630 // connection might be the first one. At that time, we should check | 630 // connection might be the first one. At that time, we should check |
631 // Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// . | 631 // Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// . |
632 | 632 |
633 return context_->proxy_service()->ResolveProxy( | 633 return context_->proxy_service()->ResolveProxy( |
634 proxy_url_, net::LOAD_NORMAL, &proxy_info_, io_callback_, &pac_request_, | 634 proxy_url_, net::LOAD_NORMAL, &proxy_info_, io_callback_, &pac_request_, |
wtc
2014/07/30 04:56:52
Note to self: omit "net::".
| |
635 NULL, net_log_); | 635 NULL, net_log_); |
636 } | 636 } |
637 | 637 |
638 int SocketStream::DoResolveProxyComplete(int result) { | 638 int SocketStream::DoResolveProxyComplete(int result) { |
639 pac_request_ = NULL; | 639 pac_request_ = NULL; |
640 if (result != OK) { | 640 if (result != OK) { |
641 DVLOG(1) << "Failed to resolve proxy: " << result; | 641 DVLOG(1) << "Failed to resolve proxy: " << result; |
642 if (delegate_) | 642 if (delegate_) |
643 delegate_->OnError(this, result); | 643 delegate_->OnError(this, result); |
644 proxy_info_.UseDirect(); | 644 proxy_info_.UseDirect(); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 next_state_ = STATE_CLOSE; | 1005 next_state_ = STATE_CLOSE; |
1006 } | 1006 } |
1007 return result; | 1007 return result; |
1008 } | 1008 } |
1009 | 1009 |
1010 int SocketStream::DoSecureProxyConnect() { | 1010 int SocketStream::DoSecureProxyConnect() { |
1011 DCHECK(factory_); | 1011 DCHECK(factory_); |
1012 SSLClientSocketContext ssl_context; | 1012 SSLClientSocketContext ssl_context; |
1013 ssl_context.cert_verifier = context_->cert_verifier(); | 1013 ssl_context.cert_verifier = context_->cert_verifier(); |
1014 ssl_context.transport_security_state = context_->transport_security_state(); | 1014 ssl_context.transport_security_state = context_->transport_security_state(); |
1015 ssl_context.server_bound_cert_service = context_->server_bound_cert_service(); | 1015 ssl_context.channel_id_service = context_->channel_id_service(); |
1016 scoped_ptr<StreamSocket> socket(factory_->CreateSSLClientSocket( | 1016 scoped_ptr<StreamSocket> socket(factory_->CreateSSLClientSocket( |
1017 connection_.Pass(), | 1017 connection_.Pass(), |
1018 proxy_info_.proxy_server().host_port_pair(), | 1018 proxy_info_.proxy_server().host_port_pair(), |
1019 proxy_ssl_config_, | 1019 proxy_ssl_config_, |
1020 ssl_context)); | 1020 ssl_context)); |
1021 connection_.reset(new ClientSocketHandle); | 1021 connection_.reset(new ClientSocketHandle); |
1022 connection_->SetSocket(socket.Pass()); | 1022 connection_->SetSocket(socket.Pass()); |
1023 next_state_ = STATE_SECURE_PROXY_CONNECT_COMPLETE; | 1023 next_state_ = STATE_SECURE_PROXY_CONNECT_COMPLETE; |
1024 metrics_->OnCountConnectionType(SocketStreamMetrics::SECURE_PROXY_CONNECTION); | 1024 metrics_->OnCountConnectionType(SocketStreamMetrics::SECURE_PROXY_CONNECTION); |
1025 return connection_->socket()->Connect(io_callback_); | 1025 return connection_->socket()->Connect(io_callback_); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 next_state_ = STATE_CLOSE; | 1061 next_state_ = STATE_CLOSE; |
1062 } | 1062 } |
1063 return result; | 1063 return result; |
1064 } | 1064 } |
1065 | 1065 |
1066 int SocketStream::DoSSLConnect() { | 1066 int SocketStream::DoSSLConnect() { |
1067 DCHECK(factory_); | 1067 DCHECK(factory_); |
1068 SSLClientSocketContext ssl_context; | 1068 SSLClientSocketContext ssl_context; |
1069 ssl_context.cert_verifier = context_->cert_verifier(); | 1069 ssl_context.cert_verifier = context_->cert_verifier(); |
1070 ssl_context.transport_security_state = context_->transport_security_state(); | 1070 ssl_context.transport_security_state = context_->transport_security_state(); |
1071 ssl_context.server_bound_cert_service = context_->server_bound_cert_service(); | 1071 ssl_context.channel_id_service = context_->channel_id_service(); |
1072 scoped_ptr<StreamSocket> socket( | 1072 scoped_ptr<StreamSocket> socket( |
1073 factory_->CreateSSLClientSocket(connection_.Pass(), | 1073 factory_->CreateSSLClientSocket(connection_.Pass(), |
1074 HostPortPair::FromURL(url_), | 1074 HostPortPair::FromURL(url_), |
1075 server_ssl_config_, | 1075 server_ssl_config_, |
1076 ssl_context)); | 1076 ssl_context)); |
1077 connection_.reset(new ClientSocketHandle); | 1077 connection_.reset(new ClientSocketHandle); |
1078 connection_->SetSocket(socket.Pass()); | 1078 connection_->SetSocket(socket.Pass()); |
1079 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 1079 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
1080 metrics_->OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION); | 1080 metrics_->OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION); |
1081 return connection_->socket()->Connect(io_callback_); | 1081 return connection_->socket()->Connect(io_callback_); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 | 1348 |
1349 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 1349 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
1350 return ERR_IO_PENDING; | 1350 return ERR_IO_PENDING; |
1351 } | 1351 } |
1352 | 1352 |
1353 CookieStore* SocketStream::cookie_store() const { | 1353 CookieStore* SocketStream::cookie_store() const { |
1354 return cookie_store_; | 1354 return cookie_store_; |
1355 } | 1355 } |
1356 | 1356 |
1357 } // namespace net | 1357 } // namespace net |
OLD | NEW |