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 // 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 void SocketStream::ResponseHeaders::Realloc(size_t new_size) { | 44 void SocketStream::ResponseHeaders::Realloc(size_t new_size) { |
45 headers_.reset(static_cast<char*>(realloc(headers_.release(), new_size))); | 45 headers_.reset(static_cast<char*>(realloc(headers_.release(), new_size))); |
46 } | 46 } |
47 | 47 |
48 SocketStream::SocketStream(const GURL& url, Delegate* delegate) | 48 SocketStream::SocketStream(const GURL& url, Delegate* delegate) |
49 : delegate_(delegate), | 49 : delegate_(delegate), |
50 url_(url), | 50 url_(url), |
51 max_pending_send_allowed_(kMaxPendingSendAllowed), | 51 max_pending_send_allowed_(kMaxPendingSendAllowed), |
52 next_state_(STATE_NONE), | 52 next_state_(STATE_NONE), |
| 53 host_resolver_(NULL), |
| 54 cert_verifier_(NULL), |
53 http_auth_handler_factory_(NULL), | 55 http_auth_handler_factory_(NULL), |
54 factory_(ClientSocketFactory::GetDefaultFactory()), | 56 factory_(ClientSocketFactory::GetDefaultFactory()), |
55 proxy_mode_(kDirectConnection), | 57 proxy_mode_(kDirectConnection), |
56 proxy_url_(url), | 58 proxy_url_(url), |
57 pac_request_(NULL), | 59 pac_request_(NULL), |
58 ALLOW_THIS_IN_INITIALIZER_LIST( | 60 ALLOW_THIS_IN_INITIALIZER_LIST( |
59 io_callback_(this, &SocketStream::OnIOCompleted)), | 61 io_callback_(this, &SocketStream::OnIOCompleted)), |
60 ALLOW_THIS_IN_INITIALIZER_LIST( | 62 ALLOW_THIS_IN_INITIALIZER_LIST( |
61 read_callback_(this, &SocketStream::OnReadCompleted)), | 63 read_callback_(this, &SocketStream::OnReadCompleted)), |
62 ALLOW_THIS_IN_INITIALIZER_LIST( | 64 ALLOW_THIS_IN_INITIALIZER_LIST( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 net_log_ = BoundNetLog::Make( | 114 net_log_ = BoundNetLog::Make( |
113 context->net_log(), | 115 context->net_log(), |
114 NetLog::SOURCE_SOCKET_STREAM); | 116 NetLog::SOURCE_SOCKET_STREAM); |
115 | 117 |
116 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE, NULL); | 118 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE, NULL); |
117 } | 119 } |
118 } | 120 } |
119 | 121 |
120 if (context_) { | 122 if (context_) { |
121 host_resolver_ = context_->host_resolver(); | 123 host_resolver_ = context_->host_resolver(); |
| 124 cert_verifier_ = context_->cert_verifier(); |
122 http_auth_handler_factory_ = context_->http_auth_handler_factory(); | 125 http_auth_handler_factory_ = context_->http_auth_handler_factory(); |
123 } | 126 } |
124 } | 127 } |
125 | 128 |
126 void SocketStream::Connect() { | 129 void SocketStream::Connect() { |
127 DCHECK(MessageLoop::current()) << | 130 DCHECK(MessageLoop::current()) << |
128 "The current MessageLoop must exist"; | 131 "The current MessageLoop must exist"; |
129 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 132 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
130 "The current MessageLoop must be TYPE_IO"; | 133 "The current MessageLoop must be TYPE_IO"; |
131 if (context_) | 134 if (context_) |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 } | 796 } |
794 return result; | 797 return result; |
795 } | 798 } |
796 | 799 |
797 int SocketStream::DoSSLConnect() { | 800 int SocketStream::DoSSLConnect() { |
798 DCHECK(factory_); | 801 DCHECK(factory_); |
799 // TODO(agl): look into plumbing SSLHostInfo here. | 802 // TODO(agl): look into plumbing SSLHostInfo here. |
800 socket_.reset(factory_->CreateSSLClientSocket(socket_.release(), | 803 socket_.reset(factory_->CreateSSLClientSocket(socket_.release(), |
801 HostPortPair::FromURL(url_), | 804 HostPortPair::FromURL(url_), |
802 ssl_config_, | 805 ssl_config_, |
803 NULL /* ssl_host_info */)); | 806 NULL /* ssl_host_info */, |
| 807 cert_verifier_)); |
804 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 808 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
805 metrics_->OnSSLConnection(); | 809 metrics_->OnSSLConnection(); |
806 return socket_->Connect(&io_callback_); | 810 return socket_->Connect(&io_callback_); |
807 } | 811 } |
808 | 812 |
809 int SocketStream::DoSSLConnectComplete(int result) { | 813 int SocketStream::DoSSLConnectComplete(int result) { |
810 if (IsCertificateError(result)) { | 814 if (IsCertificateError(result)) { |
811 if (socket_->IsConnectedAndIdle()) { | 815 if (socket_->IsConnectedAndIdle()) { |
812 result = HandleCertificateError(result); | 816 result = HandleCertificateError(result); |
813 } else { | 817 } else { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 | 1027 |
1024 SSLConfigService* SocketStream::ssl_config_service() const { | 1028 SSLConfigService* SocketStream::ssl_config_service() const { |
1025 return context_->ssl_config_service(); | 1029 return context_->ssl_config_service(); |
1026 } | 1030 } |
1027 | 1031 |
1028 ProxyService* SocketStream::proxy_service() const { | 1032 ProxyService* SocketStream::proxy_service() const { |
1029 return context_->proxy_service(); | 1033 return context_->proxy_service(); |
1030 } | 1034 } |
1031 | 1035 |
1032 } // namespace net | 1036 } // namespace net |
OLD | NEW |