| 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 #include "net/socket/ssl_client_socket_win.h" | 5 #include "net/socket/ssl_client_socket_win.h" |
| 6 | 6 |
| 7 #include <schnlsp.h> | 7 #include <schnlsp.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 561 |
| 562 ServerBoundCertService* SSLClientSocketWin::GetServerBoundCertService() const { | 562 ServerBoundCertService* SSLClientSocketWin::GetServerBoundCertService() const { |
| 563 return NULL; | 563 return NULL; |
| 564 } | 564 } |
| 565 | 565 |
| 566 int SSLClientSocketWin::Connect(const CompletionCallback& callback) { | 566 int SSLClientSocketWin::Connect(const CompletionCallback& callback) { |
| 567 DCHECK(transport_.get()); | 567 DCHECK(transport_.get()); |
| 568 DCHECK(next_state_ == STATE_NONE); | 568 DCHECK(next_state_ == STATE_NONE); |
| 569 DCHECK(user_connect_callback_.is_null()); | 569 DCHECK(user_connect_callback_.is_null()); |
| 570 | 570 |
| 571 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT, NULL); | 571 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); |
| 572 | 572 |
| 573 int rv = InitializeSSLContext(); | 573 int rv = InitializeSSLContext(); |
| 574 if (rv != OK) { | 574 if (rv != OK) { |
| 575 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL); | 575 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); |
| 576 return rv; | 576 return rv; |
| 577 } | 577 } |
| 578 | 578 |
| 579 writing_first_token_ = true; | 579 writing_first_token_ = true; |
| 580 next_state_ = STATE_HANDSHAKE_WRITE; | 580 next_state_ = STATE_HANDSHAKE_WRITE; |
| 581 rv = DoLoop(OK); | 581 rv = DoLoop(OK); |
| 582 if (rv == ERR_IO_PENDING) { | 582 if (rv == ERR_IO_PENDING) { |
| 583 user_connect_callback_ = callback; | 583 user_connect_callback_ = callback; |
| 584 } else { | 584 } else { |
| 585 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL); | 585 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); |
| 586 } | 586 } |
| 587 return rv; | 587 return rv; |
| 588 } | 588 } |
| 589 | 589 |
| 590 int SSLClientSocketWin::InitializeSSLContext() { | 590 int SSLClientSocketWin::InitializeSSLContext() { |
| 591 // If ssl_config_.version_max > SSL_PROTOCOL_VERSION_TLS1, it means the | 591 // If ssl_config_.version_max > SSL_PROTOCOL_VERSION_TLS1, it means the |
| 592 // SSLConfigService::SetDefaultVersionMax(SSL_PROTOCOL_VERSION_TLS1) call | 592 // SSLConfigService::SetDefaultVersionMax(SSL_PROTOCOL_VERSION_TLS1) call |
| 593 // in ClientSocketFactory::UseSystemSSL() is not effective. | 593 // in ClientSocketFactory::UseSystemSSL() is not effective. |
| 594 DCHECK_LE(ssl_config_.version_max, SSL_PROTOCOL_VERSION_TLS1); | 594 DCHECK_LE(ssl_config_.version_max, SSL_PROTOCOL_VERSION_TLS1); |
| 595 int ssl_version_mask = 0; | 595 int ssl_version_mask = 0; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 // (which occurs because we are in the middle of a Read when the | 850 // (which occurs because we are in the middle of a Read when the |
| 851 // renegotiation process starts). So we complete the Read here. | 851 // renegotiation process starts). So we complete the Read here. |
| 852 if (user_connect_callback_.is_null()) { | 852 if (user_connect_callback_.is_null()) { |
| 853 CompletionCallback c = user_read_callback_; | 853 CompletionCallback c = user_read_callback_; |
| 854 user_read_callback_.Reset(); | 854 user_read_callback_.Reset(); |
| 855 user_read_buf_ = NULL; | 855 user_read_buf_ = NULL; |
| 856 user_read_buf_len_ = 0; | 856 user_read_buf_len_ = 0; |
| 857 c.Run(rv); | 857 c.Run(rv); |
| 858 return; | 858 return; |
| 859 } | 859 } |
| 860 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL); | 860 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); |
| 861 CompletionCallback c = user_connect_callback_; | 861 CompletionCallback c = user_connect_callback_; |
| 862 user_connect_callback_.Reset(); | 862 user_connect_callback_.Reset(); |
| 863 c.Run(rv); | 863 c.Run(rv); |
| 864 } | 864 } |
| 865 } | 865 } |
| 866 | 866 |
| 867 void SSLClientSocketWin::OnReadComplete(int result) { | 867 void SSLClientSocketWin::OnReadComplete(int result) { |
| 868 DCHECK(completed_handshake()); | 868 DCHECK(completed_handshake()); |
| 869 | 869 |
| 870 result = DoPayloadReadComplete(result); | 870 result = DoPayloadReadComplete(result); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2_CA); | 1603 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2_CA); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 void SSLClientSocketWin::FreeSendBuffer() { | 1606 void SSLClientSocketWin::FreeSendBuffer() { |
| 1607 SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); | 1607 SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); |
| 1608 DCHECK(status == SEC_E_OK); | 1608 DCHECK(status == SEC_E_OK); |
| 1609 memset(&send_buffer_, 0, sizeof(send_buffer_)); | 1609 memset(&send_buffer_, 0, sizeof(send_buffer_)); |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 } // namespace net | 1612 } // namespace net |
| OLD | NEW |