Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: net/socket/ssl_client_socket_openssl.cc

Issue 169643006: Use sockets with unread data if they've never been used before. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mmenke comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_client_socket_openssl.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // OpenSSL binding for SSLClientSocket. The class layout and general principle 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle
6 // of operation is derived from SSLClientSocketNSS. 6 // of operation is derived from SSLClientSocketNSS.
7 7
8 #include "net/socket/ssl_client_socket_openssl.h" 8 #include "net/socket/ssl_client_socket_openssl.h"
9 9
10 #include <openssl/err.h> 10 #include <openssl/err.h>
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 const SSLConfig& ssl_config, 480 const SSLConfig& ssl_config,
481 const SSLClientSocketContext& context) 481 const SSLClientSocketContext& context)
482 : transport_send_busy_(false), 482 : transport_send_busy_(false),
483 transport_recv_busy_(false), 483 transport_recv_busy_(false),
484 transport_recv_eof_(false), 484 transport_recv_eof_(false),
485 weak_factory_(this), 485 weak_factory_(this),
486 pending_read_error_(kNoPendingReadResult), 486 pending_read_error_(kNoPendingReadResult),
487 transport_write_error_(OK), 487 transport_write_error_(OK),
488 server_cert_chain_(new PeerCertificateChain(NULL)), 488 server_cert_chain_(new PeerCertificateChain(NULL)),
489 completed_handshake_(false), 489 completed_handshake_(false),
490 was_ever_used_(false),
490 client_auth_cert_needed_(false), 491 client_auth_cert_needed_(false),
491 cert_verifier_(context.cert_verifier), 492 cert_verifier_(context.cert_verifier),
492 server_bound_cert_service_(context.server_bound_cert_service), 493 server_bound_cert_service_(context.server_bound_cert_service),
493 ssl_(NULL), 494 ssl_(NULL),
494 transport_bio_(NULL), 495 transport_bio_(NULL),
495 transport_(transport_socket.Pass()), 496 transport_(transport_socket.Pass()),
496 host_and_port_(host_and_port), 497 host_and_port_(host_and_port),
497 ssl_config_(ssl_config), 498 ssl_config_(ssl_config),
498 ssl_session_cache_shard_(context.ssl_session_cache_shard), 499 ssl_session_cache_shard_(context.ssl_session_cache_shard),
499 trying_cached_session_(false), 500 trying_cached_session_(false),
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 669
669 void SSLClientSocketOpenSSL::SetOmniboxSpeculation() { 670 void SSLClientSocketOpenSSL::SetOmniboxSpeculation() {
670 if (transport_.get() && transport_->socket()) { 671 if (transport_.get() && transport_->socket()) {
671 transport_->socket()->SetOmniboxSpeculation(); 672 transport_->socket()->SetOmniboxSpeculation();
672 } else { 673 } else {
673 NOTREACHED(); 674 NOTREACHED();
674 } 675 }
675 } 676 }
676 677
677 bool SSLClientSocketOpenSSL::WasEverUsed() const { 678 bool SSLClientSocketOpenSSL::WasEverUsed() const {
678 if (transport_.get() && transport_->socket()) 679 return was_ever_used_;
679 return transport_->socket()->WasEverUsed();
680
681 NOTREACHED();
682 return false;
683 } 680 }
684 681
685 bool SSLClientSocketOpenSSL::UsingTCPFastOpen() const { 682 bool SSLClientSocketOpenSSL::UsingTCPFastOpen() const {
686 if (transport_.get() && transport_->socket()) 683 if (transport_.get() && transport_->socket())
687 return transport_->socket()->UsingTCPFastOpen(); 684 return transport_->socket()->UsingTCPFastOpen();
688 685
689 NOTREACHED(); 686 NOTREACHED();
690 return false; 687 return false;
691 } 688 }
692 689
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 int buf_len, 740 int buf_len,
744 const CompletionCallback& callback) { 741 const CompletionCallback& callback) {
745 user_read_buf_ = buf; 742 user_read_buf_ = buf;
746 user_read_buf_len_ = buf_len; 743 user_read_buf_len_ = buf_len;
747 744
748 int rv = DoReadLoop(OK); 745 int rv = DoReadLoop(OK);
749 746
750 if (rv == ERR_IO_PENDING) { 747 if (rv == ERR_IO_PENDING) {
751 user_read_callback_ = callback; 748 user_read_callback_ = callback;
752 } else { 749 } else {
750 if (rv > 0)
751 was_ever_used_ = true;
753 user_read_buf_ = NULL; 752 user_read_buf_ = NULL;
754 user_read_buf_len_ = 0; 753 user_read_buf_len_ = 0;
755 } 754 }
756 755
757 return rv; 756 return rv;
758 } 757 }
759 758
760 int SSLClientSocketOpenSSL::Write(IOBuffer* buf, 759 int SSLClientSocketOpenSSL::Write(IOBuffer* buf,
761 int buf_len, 760 int buf_len,
762 const CompletionCallback& callback) { 761 const CompletionCallback& callback) {
763 user_write_buf_ = buf; 762 user_write_buf_ = buf;
764 user_write_buf_len_ = buf_len; 763 user_write_buf_len_ = buf_len;
765 764
766 int rv = DoWriteLoop(OK); 765 int rv = DoWriteLoop(OK);
767 766
768 if (rv == ERR_IO_PENDING) { 767 if (rv == ERR_IO_PENDING) {
769 user_write_callback_ = callback; 768 user_write_callback_ = callback;
770 } else { 769 } else {
770 if (rv > 0)
771 was_ever_used_ = true;
771 user_write_buf_ = NULL; 772 user_write_buf_ = NULL;
772 user_write_buf_len_ = 0; 773 user_write_buf_len_ = 0;
773 } 774 }
774 775
775 return rv; 776 return rv;
776 } 777 }
777 778
778 bool SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { 779 bool SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) {
779 return transport_->socket()->SetReceiveBufferSize(size); 780 return transport_->socket()->SetReceiveBufferSize(size);
780 } 781 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (IsChannelIDEnabled(ssl_config_, server_bound_cert_service_)) { 901 if (IsChannelIDEnabled(ssl_config_, server_bound_cert_service_)) {
901 SSL_enable_tls_channel_id(ssl_); 902 SSL_enable_tls_channel_id(ssl_);
902 } 903 }
903 904
904 return true; 905 return true;
905 } 906 }
906 907
907 void SSLClientSocketOpenSSL::DoReadCallback(int rv) { 908 void SSLClientSocketOpenSSL::DoReadCallback(int rv) {
908 // Since Run may result in Read being called, clear |user_read_callback_| 909 // Since Run may result in Read being called, clear |user_read_callback_|
909 // up front. 910 // up front.
911 if (rv > 0)
912 was_ever_used_ = true;
910 user_read_buf_ = NULL; 913 user_read_buf_ = NULL;
911 user_read_buf_len_ = 0; 914 user_read_buf_len_ = 0;
912 base::ResetAndReturn(&user_read_callback_).Run(rv); 915 base::ResetAndReturn(&user_read_callback_).Run(rv);
913 } 916 }
914 917
915 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) { 918 void SSLClientSocketOpenSSL::DoWriteCallback(int rv) {
916 // Since Run may result in Write being called, clear |user_write_callback_| 919 // Since Run may result in Write being called, clear |user_write_callback_|
917 // up front. 920 // up front.
921 if (rv > 0)
922 was_ever_used_ = true;
918 user_write_buf_ = NULL; 923 user_write_buf_ = NULL;
919 user_write_buf_len_ = 0; 924 user_write_buf_len_ = 0;
920 base::ResetAndReturn(&user_write_callback_).Run(rv); 925 base::ResetAndReturn(&user_write_callback_).Run(rv);
921 } 926 }
922 927
923 bool SSLClientSocketOpenSSL::DoTransportIO() { 928 bool SSLClientSocketOpenSSL::DoTransportIO() {
924 bool network_moved = false; 929 bool network_moved = false;
925 int rv; 930 int rv;
926 // Read and write as much data as possible. The loop is necessary because 931 // Read and write as much data as possible. The loop is necessary because
927 // Write() may return synchronously. 932 // Write() may return synchronously.
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 #endif 1572 #endif
1568 return SSL_TLSEXT_ERR_OK; 1573 return SSL_TLSEXT_ERR_OK;
1569 } 1574 }
1570 1575
1571 scoped_refptr<X509Certificate> 1576 scoped_refptr<X509Certificate>
1572 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1577 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1573 return server_cert_; 1578 return server_cert_;
1574 } 1579 }
1575 1580
1576 } // namespace net 1581 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_openssl.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698