OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 #include "net/base/ssl_client_socket_mac.h" | 5 #include "net/base/ssl_client_socket_mac.h" |
6 | 6 |
7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/ssl_info.h" | 10 #include "net/base/ssl_info.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 bool SSLClientSocketMac::IsConnected() const { | 300 bool SSLClientSocketMac::IsConnected() const { |
301 // Ideally, we should also check if we have received the close_notify alert | 301 // Ideally, we should also check if we have received the close_notify alert |
302 // message from the server, and return false in that case. We're not doing | 302 // message from the server, and return false in that case. We're not doing |
303 // that, so this function may return a false positive. Since the upper | 303 // that, so this function may return a false positive. Since the upper |
304 // layer (HttpNetworkTransaction) needs to handle a persistent connection | 304 // layer (HttpNetworkTransaction) needs to handle a persistent connection |
305 // closed by the server when we send a request anyway, a false positive in | 305 // closed by the server when we send a request anyway, a false positive in |
306 // exchange for simpler code is a good trade-off. | 306 // exchange for simpler code is a good trade-off. |
307 return completed_handshake_ && transport_->IsConnected(); | 307 return completed_handshake_ && transport_->IsConnected(); |
308 } | 308 } |
309 | 309 |
| 310 bool SSLClientSocketMac::IsConnectedAndIdle() const { |
| 311 // Unlike IsConnected, this method doesn't return a false positive. |
| 312 // |
| 313 // Strictly speaking, we should check if we have received the close_notify |
| 314 // alert message from the server, and return false in that case. Although |
| 315 // the close_notify alert message means EOF in the SSL layer, it is just |
| 316 // bytes to the transport layer below, so transport_->IsConnectedAndIdle() |
| 317 // returns the desired false when we receive close_notify. |
| 318 return completed_handshake_ && transport_->IsConnectedAndIdle(); |
| 319 } |
| 320 |
310 int SSLClientSocketMac::Read(char* buf, int buf_len, | 321 int SSLClientSocketMac::Read(char* buf, int buf_len, |
311 CompletionCallback* callback) { | 322 CompletionCallback* callback) { |
312 DCHECK(completed_handshake_); | 323 DCHECK(completed_handshake_); |
313 DCHECK(next_state_ == STATE_NONE); | 324 DCHECK(next_state_ == STATE_NONE); |
314 DCHECK(!user_callback_); | 325 DCHECK(!user_callback_); |
315 | 326 |
316 user_buf_ = buf; | 327 user_buf_ = buf; |
317 user_buf_len_ = buf_len; | 328 user_buf_len_ = buf_len; |
318 | 329 |
319 next_state_ = STATE_PAYLOAD_READ; | 330 next_state_ = STATE_PAYLOAD_READ; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 if (rv < 0 && rv != ERR_IO_PENDING) { | 758 if (rv < 0 && rv != ERR_IO_PENDING) { |
748 return OSStatusFromNetError(rv); | 759 return OSStatusFromNetError(rv); |
749 } | 760 } |
750 | 761 |
751 // always lie to our caller | 762 // always lie to our caller |
752 return noErr; | 763 return noErr; |
753 } | 764 } |
754 | 765 |
755 } // namespace net | 766 } // namespace net |
756 | 767 |
OLD | NEW |