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

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

Issue 1696005: Add net log entries that summarize transmit and receive byte counts. (Closed)
Patch Set: More tests and address comments Created 10 years, 8 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
« no previous file with comments | « net/socket/ssl_client_socket_mac.h ('k') | net/socket/ssl_client_socket_nss.h » ('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) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_mac.h" 5 #include "net/socket/ssl_client_socket_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <netdb.h> 8 #include <netdb.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 11
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 user_connect_callback_(NULL), 511 user_connect_callback_(NULL),
512 user_read_callback_(NULL), 512 user_read_callback_(NULL),
513 user_write_callback_(NULL), 513 user_write_callback_(NULL),
514 user_read_buf_len_(0), 514 user_read_buf_len_(0),
515 user_write_buf_len_(0), 515 user_write_buf_len_(0),
516 next_handshake_state_(STATE_NONE), 516 next_handshake_state_(STATE_NONE),
517 completed_handshake_(false), 517 completed_handshake_(false),
518 handshake_interrupted_(false), 518 handshake_interrupted_(false),
519 client_cert_requested_(false), 519 client_cert_requested_(false),
520 ssl_context_(NULL), 520 ssl_context_(NULL),
521 pending_send_error_(OK) { 521 pending_send_error_(OK),
522 net_log_(transport_socket->NetLog()) {
522 } 523 }
523 524
524 SSLClientSocketMac::~SSLClientSocketMac() { 525 SSLClientSocketMac::~SSLClientSocketMac() {
525 Disconnect(); 526 Disconnect();
526 } 527 }
527 528
528 int SSLClientSocketMac::Connect(CompletionCallback* callback, 529 int SSLClientSocketMac::Connect(CompletionCallback* callback) {
529 const BoundNetLog& net_log) {
530 DCHECK(transport_.get()); 530 DCHECK(transport_.get());
531 DCHECK(next_handshake_state_ == STATE_NONE); 531 DCHECK(next_handshake_state_ == STATE_NONE);
532 DCHECK(!user_connect_callback_); 532 DCHECK(!user_connect_callback_);
533 533
534 net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT); 534 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT);
535 535
536 int rv = InitializeSSLContext(); 536 int rv = InitializeSSLContext();
537 if (rv != OK) { 537 if (rv != OK) {
538 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 538 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
539 return rv; 539 return rv;
540 } 540 }
541 541
542 next_handshake_state_ = STATE_HANDSHAKE_START; 542 next_handshake_state_ = STATE_HANDSHAKE_START;
543 rv = DoHandshakeLoop(OK); 543 rv = DoHandshakeLoop(OK);
544 if (rv == ERR_IO_PENDING) { 544 if (rv == ERR_IO_PENDING) {
545 net_log_ = net_log;
546 user_connect_callback_ = callback; 545 user_connect_callback_ = callback;
547 } else { 546 } else {
548 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 547 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
549 } 548 }
550 return rv; 549 return rv;
551 } 550 }
552 551
553 void SSLClientSocketMac::Disconnect() { 552 void SSLClientSocketMac::Disconnect() {
554 completed_handshake_ = false; 553 completed_handshake_ = false;
555 554
556 if (ssl_context_) { 555 if (ssl_context_) {
557 SSLClose(ssl_context_); 556 SSLClose(ssl_context_);
558 SSLDisposeContext(ssl_context_); 557 SSLDisposeContext(ssl_context_);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 user_write_buf_ = NULL; 860 user_write_buf_ = NULL;
862 user_write_buf_len_ = 0; 861 user_write_buf_len_ = 0;
863 c->Run(rv); 862 c->Run(rv);
864 } 863 }
865 864
866 void SSLClientSocketMac::OnHandshakeIOComplete(int result) { 865 void SSLClientSocketMac::OnHandshakeIOComplete(int result) {
867 DCHECK(next_handshake_state_ != STATE_NONE); 866 DCHECK(next_handshake_state_ != STATE_NONE);
868 int rv = DoHandshakeLoop(result); 867 int rv = DoHandshakeLoop(result);
869 if (rv != ERR_IO_PENDING) { 868 if (rv != ERR_IO_PENDING) {
870 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); 869 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
871 net_log_ = BoundNetLog();
872 DoConnectCallback(rv); 870 DoConnectCallback(rv);
873 } 871 }
874 } 872 }
875 873
876 void SSLClientSocketMac::OnTransportReadComplete(int result) { 874 void SSLClientSocketMac::OnTransportReadComplete(int result) {
877 if (result > 0) { 875 if (result > 0) {
878 recv_buffer_.insert(recv_buffer_.end(), 876 recv_buffer_.insert(recv_buffer_.end(),
879 read_io_buf_->data(), 877 read_io_buf_->data(),
880 read_io_buf_->data() + result); 878 read_io_buf_->data() + result);
881 } 879 }
882 read_io_buf_ = NULL; 880 read_io_buf_ = NULL;
883 881
884 if (next_handshake_state_ != STATE_NONE) { 882 if (next_handshake_state_ != STATE_NONE) {
885 int rv = DoHandshakeLoop(result); 883 int rv = DoHandshakeLoop(result);
886 if (rv != ERR_IO_PENDING) { 884 if (rv != ERR_IO_PENDING) {
887 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); 885 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
888 net_log_ = BoundNetLog();
889 DoConnectCallback(rv); 886 DoConnectCallback(rv);
890 } 887 }
891 return; 888 return;
892 } 889 }
893 if (user_read_buf_) { 890 if (user_read_buf_) {
894 if (result < 0) { 891 if (result < 0) {
895 DoReadCallback(result); 892 DoReadCallback(result);
896 return; 893 return;
897 } 894 }
898 int rv = DoPayloadRead(); 895 int rv = DoPayloadRead();
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 if (rv < 0 && rv != ERR_IO_PENDING) { 1293 if (rv < 0 && rv != ERR_IO_PENDING) {
1297 us->write_io_buf_ = NULL; 1294 us->write_io_buf_ = NULL;
1298 return OSStatusFromNetError(rv); 1295 return OSStatusFromNetError(rv);
1299 } 1296 }
1300 1297
1301 // always lie to our caller 1298 // always lie to our caller
1302 return noErr; 1299 return noErr;
1303 } 1300 }
1304 1301
1305 } // namespace net 1302 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_mac.h ('k') | net/socket/ssl_client_socket_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698