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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
8 | 8 |
9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 // BufferRecv | 564 // BufferRecv |
565 // V-------------------------------| | 565 // V-------------------------------| |
566 // DoBufferRecv | 566 // DoBufferRecv |
567 // |----------------V | 567 // |----------------V |
568 // Read() | 568 // Read() |
569 // V----------------| | 569 // V----------------| |
570 // BufferRecvComplete() | 570 // BufferRecvComplete() |
571 // |-------------------------------V | 571 // |-------------------------------V |
572 // BufferRecvComplete() | 572 // BufferRecvComplete() |
573 // | | 573 // | |
574 // PostOrRunCallback() | 574 // DoReadCallback() |
575 // V-------------------------------| | 575 // V-------------------------------| |
576 // PostOrRunCallback() | 576 // UpdateReadStatus() |
Ryan Sleevi
2013/01/07 18:59:04
NACK on this. The intention of PostOrRunCallback i
Takashi Toyoshima
2013/01/08 06:25:39
Oh, I miss the case of single-threaded model and m
| |
577 // V---------------------| | 577 // V---------------------| |
578 // (Read Callback) | 578 // (Read Callback) |
579 // | 579 // |
580 ///////////////////////////////////////////////////////////////////////////// | 580 ///////////////////////////////////////////////////////////////////////////// |
581 class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> { | 581 class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> { |
582 public: | 582 public: |
583 // Creates a new Core. | 583 // Creates a new Core. |
584 // | 584 // |
585 // Any calls to NSS are executed on the |nss_task_runner|, while any calls | 585 // Any calls to NSS are executed on the |nss_task_runner|, while any calls |
586 // that need to operate on the underlying transport, net log, or server | 586 // that need to operate on the underlying transport, net log, or server |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 // any time. | 630 // any time. |
631 const HandshakeState& state() const { return network_handshake_state_; } | 631 const HandshakeState& state() const { return network_handshake_state_; } |
632 | 632 |
633 // Called on the network task runner. | 633 // Called on the network task runner. |
634 // Read() and Write() mirror the net::Socket functions of the same name. | 634 // Read() and Write() mirror the net::Socket functions of the same name. |
635 // If ERR_IO_PENDING is returned, |callback| will be invoked on the network | 635 // If ERR_IO_PENDING is returned, |callback| will be invoked on the network |
636 // task runner at a later point, unless the caller calls Detach(). | 636 // task runner at a later point, unless the caller calls Detach(). |
637 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 637 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
638 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 638 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
639 | 639 |
640 // Called on the network task runner. | |
641 bool HasPendingAsyncOperation(); | |
642 bool HasUnhandledData(); | |
643 | |
640 private: | 644 private: |
641 friend class base::RefCountedThreadSafe<Core>; | 645 friend class base::RefCountedThreadSafe<Core>; |
642 ~Core(); | 646 ~Core(); |
643 | 647 |
644 enum State { | 648 enum State { |
645 STATE_NONE, | 649 STATE_NONE, |
646 STATE_HANDSHAKE, | 650 STATE_HANDSHAKE, |
647 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, | 651 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, |
648 }; | 652 }; |
649 | 653 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 bool DoTransportIO(); | 732 bool DoTransportIO(); |
729 int BufferRecv(); | 733 int BufferRecv(); |
730 int BufferSend(); | 734 int BufferSend(); |
731 | 735 |
732 void OnRecvComplete(int result); | 736 void OnRecvComplete(int result); |
733 void OnSendComplete(int result); | 737 void OnSendComplete(int result); |
734 | 738 |
735 void DoConnectCallback(int result); | 739 void DoConnectCallback(int result); |
736 void DoReadCallback(int result); | 740 void DoReadCallback(int result); |
737 void DoWriteCallback(int result); | 741 void DoWriteCallback(int result); |
742 void UpdateNSSStatus(int amount_in_read_buffer, | |
743 bool operation_is_read, | |
744 const CompletionCallback& callback, | |
745 int rv); | |
738 | 746 |
739 // Client channel ID handler. | 747 // Client channel ID handler. |
740 static SECStatus ClientChannelIDHandler( | 748 static SECStatus ClientChannelIDHandler( |
741 void* arg, | 749 void* arg, |
742 PRFileDesc* socket, | 750 PRFileDesc* socket, |
743 SECKEYPublicKey **out_public_key, | 751 SECKEYPublicKey **out_public_key, |
744 SECKEYPrivateKey **out_private_key); | 752 SECKEYPrivateKey **out_private_key); |
745 | 753 |
746 // ImportChannelIDKeys is a helper function for turning a DER-encoded cert and | 754 // ImportChannelIDKeys is a helper function for turning a DER-encoded cert and |
747 // key into a SECKEYPublicKey and SECKEYPrivateKey. Returns OK upon success | 755 // key into a SECKEYPublicKey and SECKEYPrivateKey. Returns OK upon success |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 ClientSocketHandle* transport_; | 813 ClientSocketHandle* transport_; |
806 base::WeakPtrFactory<BoundNetLog> weak_net_log_factory_; | 814 base::WeakPtrFactory<BoundNetLog> weak_net_log_factory_; |
807 | 815 |
808 // The current handshake state. Mirrors |nss_handshake_state_|. | 816 // The current handshake state. Mirrors |nss_handshake_state_|. |
809 HandshakeState network_handshake_state_; | 817 HandshakeState network_handshake_state_; |
810 | 818 |
811 // The service for retrieving Channel ID keys. May be NULL. | 819 // The service for retrieving Channel ID keys. May be NULL. |
812 ServerBoundCertService* server_bound_cert_service_; | 820 ServerBoundCertService* server_bound_cert_service_; |
813 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; | 821 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; |
814 | 822 |
823 // The information about NSS task runner status. | |
824 int unhandled_buffer_size_; | |
825 bool waiting_read_; | |
826 bool waiting_write_; | |
827 | |
815 //////////////////////////////////////////////////////////////////////////// | 828 //////////////////////////////////////////////////////////////////////////// |
816 // Members that are ONLY accessed on the NSS task runner: | 829 // Members that are ONLY accessed on the NSS task runner: |
817 //////////////////////////////////////////////////////////////////////////// | 830 //////////////////////////////////////////////////////////////////////////// |
818 HostPortPair host_and_port_; | 831 HostPortPair host_and_port_; |
819 SSLConfig ssl_config_; | 832 SSLConfig ssl_config_; |
820 | 833 |
821 // NSS SSL socket. | 834 // NSS SSL socket. |
822 PRFileDesc* nss_fd_; | 835 PRFileDesc* nss_fd_; |
823 | 836 |
824 // Buffers for the network end of the SSL state machine | 837 // Buffers for the network end of the SSL state machine |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 ClientSocketHandle* transport, | 898 ClientSocketHandle* transport, |
886 const HostPortPair& host_and_port, | 899 const HostPortPair& host_and_port, |
887 const SSLConfig& ssl_config, | 900 const SSLConfig& ssl_config, |
888 BoundNetLog* net_log, | 901 BoundNetLog* net_log, |
889 ServerBoundCertService* server_bound_cert_service) | 902 ServerBoundCertService* server_bound_cert_service) |
890 : detached_(false), | 903 : detached_(false), |
891 transport_(transport), | 904 transport_(transport), |
892 weak_net_log_factory_(net_log), | 905 weak_net_log_factory_(net_log), |
893 server_bound_cert_service_(server_bound_cert_service), | 906 server_bound_cert_service_(server_bound_cert_service), |
894 domain_bound_cert_request_handle_(NULL), | 907 domain_bound_cert_request_handle_(NULL), |
908 unhandled_buffer_size_(0), | |
909 waiting_read_(false), | |
910 waiting_write_(false), | |
895 host_and_port_(host_and_port), | 911 host_and_port_(host_and_port), |
896 ssl_config_(ssl_config), | 912 ssl_config_(ssl_config), |
897 nss_fd_(NULL), | 913 nss_fd_(NULL), |
898 nss_bufs_(NULL), | 914 nss_bufs_(NULL), |
899 next_handshake_state_(STATE_NONE), | 915 next_handshake_state_(STATE_NONE), |
900 channel_id_xtn_negotiated_(false), | 916 channel_id_xtn_negotiated_(false), |
901 channel_id_needed_(false), | 917 channel_id_needed_(false), |
902 client_auth_cert_needed_(false), | 918 client_auth_cert_needed_(false), |
903 handshake_callback_called_(false), | 919 handshake_callback_called_(false), |
904 transport_recv_busy_(false), | 920 transport_recv_busy_(false), |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1097 return posted ? ERR_IO_PENDING : ERR_ABORTED; | 1113 return posted ? ERR_IO_PENDING : ERR_ABORTED; |
1098 } | 1114 } |
1099 | 1115 |
1100 DCHECK(OnNSSTaskRunner()); | 1116 DCHECK(OnNSSTaskRunner()); |
1101 DCHECK(handshake_callback_called_); | 1117 DCHECK(handshake_callback_called_); |
1102 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 1118 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
1103 DCHECK(user_read_callback_.is_null()); | 1119 DCHECK(user_read_callback_.is_null()); |
1104 DCHECK(user_connect_callback_.is_null()); | 1120 DCHECK(user_connect_callback_.is_null()); |
1105 DCHECK(!user_read_buf_); | 1121 DCHECK(!user_read_buf_); |
1106 DCHECK(nss_bufs_); | 1122 DCHECK(nss_bufs_); |
1123 DCHECK(!waiting_read_); | |
1107 | 1124 |
1108 user_read_buf_ = buf; | 1125 user_read_buf_ = buf; |
1109 user_read_buf_len_ = buf_len; | 1126 user_read_buf_len_ = buf_len; |
1127 waiting_read_ = true; | |
1110 | 1128 |
1111 int rv = DoReadLoop(OK); | 1129 int rv = DoReadLoop(OK); |
1112 if (rv == ERR_IO_PENDING) { | 1130 if (rv == ERR_IO_PENDING) { |
1113 user_read_callback_ = callback; | 1131 user_read_callback_ = callback; |
1114 } else { | 1132 } else { |
1115 user_read_buf_ = NULL; | 1133 user_read_buf_ = NULL; |
1116 user_read_buf_len_ = 0; | 1134 user_read_buf_len_ = 0; |
1135 waiting_read_ = false; | |
1117 | 1136 |
1118 if (!OnNetworkTaskRunner()) { | 1137 if (!OnNetworkTaskRunner()) { |
1119 PostOrRunCallback(FROM_HERE, base::Bind(callback, rv)); | 1138 PostOrRunCallback(FROM_HERE, base::Bind(callback, rv)); |
1120 return ERR_IO_PENDING; | 1139 return ERR_IO_PENDING; |
1121 } | 1140 } |
1122 } | 1141 } |
1123 | 1142 |
1124 return rv; | 1143 return rv; |
1125 } | 1144 } |
1126 | 1145 |
(...skipping 12 matching lines...) Expand all Loading... | |
1139 return rv; | 1158 return rv; |
1140 } | 1159 } |
1141 | 1160 |
1142 DCHECK(OnNSSTaskRunner()); | 1161 DCHECK(OnNSSTaskRunner()); |
1143 DCHECK(handshake_callback_called_); | 1162 DCHECK(handshake_callback_called_); |
1144 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 1163 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
1145 DCHECK(user_write_callback_.is_null()); | 1164 DCHECK(user_write_callback_.is_null()); |
1146 DCHECK(user_connect_callback_.is_null()); | 1165 DCHECK(user_connect_callback_.is_null()); |
1147 DCHECK(!user_write_buf_); | 1166 DCHECK(!user_write_buf_); |
1148 DCHECK(nss_bufs_); | 1167 DCHECK(nss_bufs_); |
1168 DCHECK(!waiting_write_); | |
1149 | 1169 |
1150 user_write_buf_ = buf; | 1170 user_write_buf_ = buf; |
1151 user_write_buf_len_ = buf_len; | 1171 user_write_buf_len_ = buf_len; |
1172 waiting_write_ = true; | |
1152 | 1173 |
1153 int rv = DoWriteLoop(OK); | 1174 int rv = DoWriteLoop(OK); |
1154 if (rv == ERR_IO_PENDING) { | 1175 if (rv == ERR_IO_PENDING) { |
1155 user_write_callback_ = callback; | 1176 user_write_callback_ = callback; |
1156 } else { | 1177 } else { |
1157 user_write_buf_ = NULL; | 1178 user_write_buf_ = NULL; |
1158 user_write_buf_len_ = 0; | 1179 user_write_buf_len_ = 0; |
1180 waiting_write_ = false; | |
1159 | 1181 |
1160 if (!OnNetworkTaskRunner()) { | 1182 if (!OnNetworkTaskRunner()) { |
1161 PostOrRunCallback(FROM_HERE, base::Bind(callback, rv)); | 1183 PostOrRunCallback(FROM_HERE, base::Bind(callback, rv)); |
1162 return ERR_IO_PENDING; | 1184 return ERR_IO_PENDING; |
1163 } | 1185 } |
1164 } | 1186 } |
1165 | 1187 |
1166 return rv; | 1188 return rv; |
1167 } | 1189 } |
1168 | 1190 |
1191 bool SSLClientSocketNSS::Core::HasPendingAsyncOperation() { | |
1192 DCHECK(OnNetworkTaskRunner()); | |
1193 return waiting_read_ || waiting_write_; | |
1194 } | |
1195 | |
1196 bool SSLClientSocketNSS::Core::HasUnhandledData() { | |
1197 DCHECK(OnNetworkTaskRunner()); | |
1198 return unhandled_buffer_size_ != 0; | |
1199 } | |
1200 | |
1169 bool SSLClientSocketNSS::Core::OnNSSTaskRunner() const { | 1201 bool SSLClientSocketNSS::Core::OnNSSTaskRunner() const { |
1170 return nss_task_runner_->RunsTasksOnCurrentThread(); | 1202 return nss_task_runner_->RunsTasksOnCurrentThread(); |
1171 } | 1203 } |
1172 | 1204 |
1173 bool SSLClientSocketNSS::Core::OnNetworkTaskRunner() const { | 1205 bool SSLClientSocketNSS::Core::OnNetworkTaskRunner() const { |
1174 return network_task_runner_->RunsTasksOnCurrentThread(); | 1206 return network_task_runner_->RunsTasksOnCurrentThread(); |
1175 } | 1207 } |
1176 | 1208 |
1177 // static | 1209 // static |
1178 SECStatus SSLClientSocketNSS::Core::OwnAuthCertHandler( | 1210 SECStatus SSLClientSocketNSS::Core::OwnAuthCertHandler( |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2250 PostOrRunCallback(FROM_HERE, c); | 2282 PostOrRunCallback(FROM_HERE, c); |
2251 } | 2283 } |
2252 | 2284 |
2253 void SSLClientSocketNSS::Core::DoReadCallback(int rv) { | 2285 void SSLClientSocketNSS::Core::DoReadCallback(int rv) { |
2254 DCHECK(OnNSSTaskRunner()); | 2286 DCHECK(OnNSSTaskRunner()); |
2255 DCHECK_NE(ERR_IO_PENDING, rv); | 2287 DCHECK_NE(ERR_IO_PENDING, rv); |
2256 DCHECK(!user_read_callback_.is_null()); | 2288 DCHECK(!user_read_callback_.is_null()); |
2257 | 2289 |
2258 user_read_buf_ = NULL; | 2290 user_read_buf_ = NULL; |
2259 user_read_buf_len_ = 0; | 2291 user_read_buf_len_ = 0; |
2260 base::Closure c = base::Bind( | 2292 char* buf; |
2261 base::ResetAndReturn(&user_read_callback_), | 2293 int amount_in_read_buffer = memio_GetReadParams(nss_bufs_, &buf); |
2262 rv); | 2294 CompletionCallback cb = base::ResetAndReturn(&user_read_callback_); |
2263 PostOrRunCallback(FROM_HERE, c); | 2295 // Curry the |amount_int_read_buffer| and |cb| back to the network task |
2296 // runner. | |
2297 network_task_runner_->PostTask( | |
2298 FROM_HERE, | |
2299 base::Bind(&Core::UpdateNSSStatus, | |
2300 this, | |
2301 amount_in_read_buffer, | |
2302 true, // Operation is read. | |
2303 cb, | |
2304 rv)); | |
Ryan Sleevi
2013/01/07 18:59:04
NACK: See above comments re: PostOrRunCallback. Yo
Takashi Toyoshima
2013/01/08 06:25:39
Done.
| |
2264 } | 2305 } |
2265 | 2306 |
2266 void SSLClientSocketNSS::Core::DoWriteCallback(int rv) { | 2307 void SSLClientSocketNSS::Core::DoWriteCallback(int rv) { |
2267 DCHECK(OnNSSTaskRunner()); | 2308 DCHECK(OnNSSTaskRunner()); |
2268 DCHECK_NE(ERR_IO_PENDING, rv); | 2309 DCHECK_NE(ERR_IO_PENDING, rv); |
2269 DCHECK(!user_write_callback_.is_null()); | 2310 DCHECK(!user_write_callback_.is_null()); |
2270 | 2311 |
2271 // Since Run may result in Write being called, clear |user_write_callback_| | 2312 // Since Run may result in Write being called, clear |user_write_callback_| |
2272 // up front. | 2313 // up front. |
2273 user_write_buf_ = NULL; | 2314 user_write_buf_ = NULL; |
2274 user_write_buf_len_ = 0; | 2315 user_write_buf_len_ = 0; |
2275 base::Closure c = base::Bind( | 2316 char* buf; |
2276 base::ResetAndReturn(&user_write_callback_), | 2317 // Update buffer status because DoWriteLoop called DoTransportIO which may |
2277 rv); | 2318 // perform read operations. |
2278 PostOrRunCallback(FROM_HERE, c); | 2319 int amount_in_read_buffer = memio_GetReadParams(nss_bufs_, &buf); |
2320 CompletionCallback cb = base::ResetAndReturn(&user_write_callback_); | |
2321 // Curry the |cb| back to the network task runner. | |
2322 network_task_runner_->PostTask( | |
2323 FROM_HERE, | |
2324 base::Bind(&Core::UpdateNSSStatus, | |
2325 this, | |
2326 amount_in_read_buffer, | |
2327 false, // Operation is not read, but write. | |
2328 cb, | |
2329 rv)); | |
Ryan Sleevi
2013/01/07 18:59:04
Also here
Takashi Toyoshima
2013/01/08 06:25:39
Done.
| |
2330 } | |
2331 | |
2332 void SSLClientSocketNSS::Core::UpdateNSSStatus( | |
2333 int amount_in_read_buffer, | |
2334 bool operation_is_read, | |
2335 const CompletionCallback& callback, | |
2336 int rv) { | |
Ryan Sleevi
2013/01/07 18:59:04
If you're going to post a callback, you should pos
Takashi Toyoshima
2013/01/08 06:25:39
Done.
| |
2337 DCHECK(OnNetworkTaskRunner()); | |
2338 DCHECK_NE(ERR_IO_PENDING, rv); | |
2339 DCHECK(!callback.is_null()); | |
2340 DCHECK((operation_is_read && waiting_read_) || | |
2341 (!operation_is_read && waiting_write_)); | |
2342 | |
2343 unhandled_buffer_size_ = amount_in_read_buffer; | |
2344 if (operation_is_read) | |
2345 waiting_read_ = false; | |
2346 else | |
2347 waiting_write_ = false; | |
2348 PostOrRunCallback(FROM_HERE, base::Bind(callback, rv)); | |
Ryan Sleevi
2013/01/07 18:59:04
At this point, you're guaranteed to be OnNetworkTa
Takashi Toyoshima
2013/01/08 06:25:39
Done.
| |
2279 } | 2349 } |
2280 | 2350 |
2281 SECStatus SSLClientSocketNSS::Core::ClientChannelIDHandler( | 2351 SECStatus SSLClientSocketNSS::Core::ClientChannelIDHandler( |
2282 void* arg, | 2352 void* arg, |
2283 PRFileDesc* socket, | 2353 PRFileDesc* socket, |
2284 SECKEYPublicKey **out_public_key, | 2354 SECKEYPublicKey **out_public_key, |
2285 SECKEYPrivateKey **out_private_key) { | 2355 SECKEYPrivateKey **out_private_key) { |
2286 Core* core = reinterpret_cast<Core*>(arg); | 2356 Core* core = reinterpret_cast<Core*>(arg); |
2287 DCHECK(core->OnNSSTaskRunner()); | 2357 DCHECK(core->OnNSSTaskRunner()); |
2288 | 2358 |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2891 } | 2961 } |
2892 | 2962 |
2893 bool SSLClientSocketNSS::IsConnected() const { | 2963 bool SSLClientSocketNSS::IsConnected() const { |
2894 // Ideally, we should also check if we have received the close_notify alert | 2964 // Ideally, we should also check if we have received the close_notify alert |
2895 // message from the server, and return false in that case. We're not doing | 2965 // message from the server, and return false in that case. We're not doing |
2896 // that, so this function may return a false positive. Since the upper | 2966 // that, so this function may return a false positive. Since the upper |
2897 // layer (HttpNetworkTransaction) needs to handle a persistent connection | 2967 // layer (HttpNetworkTransaction) needs to handle a persistent connection |
2898 // closed by the server when we send a request anyway, a false positive in | 2968 // closed by the server when we send a request anyway, a false positive in |
2899 // exchange for simpler code is a good trade-off. | 2969 // exchange for simpler code is a good trade-off. |
2900 EnterFunction(""); | 2970 EnterFunction(""); |
2901 bool ret = completed_handshake_ && transport_->socket()->IsConnected(); | 2971 bool ret; |
2972 | |
2973 if (!completed_handshake_) | |
2974 ret = false; | |
2975 else if (core_->HasPendingAsyncOperation()) | |
2976 ret = true; | |
2977 else if (core_->HasUnhandledData()) | |
2978 ret = true; | |
2979 else | |
2980 ret = transport_->socket()->IsConnected(); | |
2981 | |
2902 LeaveFunction(""); | 2982 LeaveFunction(""); |
2903 return ret; | 2983 return ret; |
2904 } | 2984 } |
2905 | 2985 |
2906 bool SSLClientSocketNSS::IsConnectedAndIdle() const { | 2986 bool SSLClientSocketNSS::IsConnectedAndIdle() const { |
2907 // Unlike IsConnected, this method doesn't return a false positive. | 2987 // Unlike IsConnected, this method doesn't return a false positive. |
2908 // | 2988 // |
2909 // Strictly speaking, we should check if we have received the close_notify | 2989 // Strictly speaking, we should check if we have received the close_notify |
2910 // alert message from the server, and return false in that case. Although | 2990 // alert message from the server, and return false in that case. Although |
2911 // the close_notify alert message means EOF in the SSL layer, it is just | 2991 // the close_notify alert message means EOF in the SSL layer, it is just |
2912 // bytes to the transport layer below, so | 2992 // bytes to the transport layer below, so |
2913 // transport_->socket()->IsConnectedAndIdle() returns the desired false | 2993 // transport_->socket()->IsConnectedAndIdle() returns the desired false |
2914 // when we receive close_notify. | 2994 // when we receive close_notify. |
2915 EnterFunction(""); | 2995 EnterFunction(""); |
2916 bool ret = completed_handshake_ && transport_->socket()->IsConnectedAndIdle(); | 2996 bool ret; |
2997 | |
2998 if (!completed_handshake_) | |
2999 ret = false; | |
3000 else if (core_->HasPendingAsyncOperation()) | |
3001 ret = true; // This is probably wrong, but mirrors TCP. | |
3002 else if (core_->HasUnhandledData()) | |
3003 ret = false; | |
3004 else | |
3005 ret = transport_->socket()->IsConnectedAndIdle(); | |
3006 | |
2917 LeaveFunction(""); | 3007 LeaveFunction(""); |
2918 return ret; | 3008 return ret; |
2919 } | 3009 } |
2920 | 3010 |
2921 int SSLClientSocketNSS::GetPeerAddress(IPEndPoint* address) const { | 3011 int SSLClientSocketNSS::GetPeerAddress(IPEndPoint* address) const { |
2922 return transport_->socket()->GetPeerAddress(address); | 3012 return transport_->socket()->GetPeerAddress(address); |
2923 } | 3013 } |
2924 | 3014 |
2925 int SSLClientSocketNSS::GetLocalAddress(IPEndPoint* address) const { | 3015 int SSLClientSocketNSS::GetLocalAddress(IPEndPoint* address) const { |
2926 return transport_->socket()->GetLocalAddress(address); | 3016 return transport_->socket()->GetLocalAddress(address); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3460 EnsureThreadIdAssigned(); | 3550 EnsureThreadIdAssigned(); |
3461 base::AutoLock auto_lock(lock_); | 3551 base::AutoLock auto_lock(lock_); |
3462 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 3552 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
3463 } | 3553 } |
3464 | 3554 |
3465 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 3555 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
3466 return server_bound_cert_service_; | 3556 return server_bound_cert_service_; |
3467 } | 3557 } |
3468 | 3558 |
3469 } // namespace net | 3559 } // namespace net |
OLD | NEW |