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

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

Issue 8429034: Upstream: Build net_unittests for Android. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ssl.h> 10 #include <openssl/ssl.h>
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 const unsigned char* in, 785 const unsigned char* in,
786 unsigned int inlen) { 786 unsigned int inlen) {
787 #if defined(OPENSSL_NPN_NEGOTIATED) 787 #if defined(OPENSSL_NPN_NEGOTIATED)
788 if (ssl_config_.next_protos.empty()) { 788 if (ssl_config_.next_protos.empty()) {
789 *out = reinterpret_cast<uint8*>(const_cast<char*>("http/1.1")); 789 *out = reinterpret_cast<uint8*>(const_cast<char*>("http/1.1"));
790 *outlen = 8; 790 *outlen = 8;
791 npn_status_ = SSLClientSocket::kNextProtoUnsupported; 791 npn_status_ = SSLClientSocket::kNextProtoUnsupported;
792 return SSL_TLSEXT_ERR_OK; 792 return SSL_TLSEXT_ERR_OK;
793 } 793 }
794 794
795 int status = SSL_select_next_proto( 795 int status = OPENSSL_NPN_UNSUPPORTED;
796 out, outlen, in, inlen, 796 for (unsigned int i = 0; i < inlen; i++) {
797 reinterpret_cast<const unsigned char*>(ssl_config_.next_protos.data()), 797 for (std::vector<std::string>::const_iterator
798 ssl_config_.next_protos.size()); 798 j = ssl_config_.next_protos.begin();
799 j != ssl_config_.next_protos.end(); j++) {
800 if (in[i] == j->size() &&
801 memcmp(&in[i + 1], j->data(), in[i]) == 0) {
802 *out = (unsigned char *)in + i + 1;
803 *outlen = in[i];
804 status = OPENSSL_NPN_NEGOTIATED;
805 break;
806 }
807 }
808 if (status == OPENSSL_NPN_NEGOTIATED)
809 break;
810 }
michaelbai 2011/11/01 16:37:59 It seemed that this code is not android specific,
Jing Zhao 2011/11/02 16:22:55 http://codereview.chromium.org/8156001/ This chang
799 811
800 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); 812 npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen);
801 switch (status) { 813 switch (status) {
802 case OPENSSL_NPN_UNSUPPORTED: 814 case OPENSSL_NPN_UNSUPPORTED:
803 npn_status_ = SSLClientSocket::kNextProtoUnsupported; 815 npn_status_ = SSLClientSocket::kNextProtoUnsupported;
804 break; 816 break;
805 case OPENSSL_NPN_NEGOTIATED: 817 case OPENSSL_NPN_NEGOTIATED:
806 npn_status_ = SSLClientSocket::kNextProtoNegotiated; 818 npn_status_ = SSLClientSocket::kNextProtoNegotiated;
807 break; 819 break;
808 case OPENSSL_NPN_NO_OVERLAP: 820 case OPENSSL_NPN_NO_OVERLAP:
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, 1232 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv,
1221 user_write_buf_->data()); 1233 user_write_buf_->data());
1222 return rv; 1234 return rv;
1223 } 1235 }
1224 1236
1225 int err = SSL_get_error(ssl_, rv); 1237 int err = SSL_get_error(ssl_, rv);
1226 return MapOpenSSLError(err, err_tracer); 1238 return MapOpenSSLError(err, err_tracer);
1227 } 1239 }
1228 1240
1229 } // namespace net 1241 } // namespace net
OLDNEW
« net/net.gyp ('K') | « net/net.gyp ('k') | net/spdy/spdy_protocol_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698