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

Side by Side Diff: net/socket/ssl_client_socket_nss.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_nss.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) 2006-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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived
6 // from AuthCertificateCallback() in 6 // from AuthCertificateCallback() in
7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp.
8 8
9 /* ***** BEGIN LICENSE BLOCK ***** 9 /* ***** BEGIN LICENSE BLOCK *****
10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 * 11 *
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 user_connect_callback_(NULL), 246 user_connect_callback_(NULL),
247 user_read_callback_(NULL), 247 user_read_callback_(NULL),
248 user_write_callback_(NULL), 248 user_write_callback_(NULL),
249 user_read_buf_len_(0), 249 user_read_buf_len_(0),
250 user_write_buf_len_(0), 250 user_write_buf_len_(0),
251 server_cert_nss_(NULL), 251 server_cert_nss_(NULL),
252 client_auth_cert_needed_(false), 252 client_auth_cert_needed_(false),
253 completed_handshake_(false), 253 completed_handshake_(false),
254 next_handshake_state_(STATE_NONE), 254 next_handshake_state_(STATE_NONE),
255 nss_fd_(NULL), 255 nss_fd_(NULL),
256 nss_bufs_(NULL) { 256 nss_bufs_(NULL),
257 net_log_(transport_socket->NetLog()) {
257 EnterFunction(""); 258 EnterFunction("");
258 } 259 }
259 260
260 SSLClientSocketNSS::~SSLClientSocketNSS() { 261 SSLClientSocketNSS::~SSLClientSocketNSS() {
261 EnterFunction(""); 262 EnterFunction("");
262 Disconnect(); 263 Disconnect();
263 LeaveFunction(""); 264 LeaveFunction("");
264 } 265 }
265 266
266 int SSLClientSocketNSS::Init() { 267 int SSLClientSocketNSS::Init() {
267 EnterFunction(""); 268 EnterFunction("");
268 // Initialize the NSS SSL library in a threadsafe way. This also 269 // Initialize the NSS SSL library in a threadsafe way. This also
269 // initializes the NSS base library. 270 // initializes the NSS base library.
270 EnsureNSSSSLInit(); 271 EnsureNSSSSLInit();
271 if (!NSS_IsInitialized()) 272 if (!NSS_IsInitialized())
272 return ERR_UNEXPECTED; 273 return ERR_UNEXPECTED;
273 #if !defined(OS_WIN) 274 #if !defined(OS_WIN)
274 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop 275 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop
275 // by MessageLoopForIO::current(). 276 // by MessageLoopForIO::current().
276 // X509Certificate::Verify() runs on a worker thread of CertVerifier. 277 // X509Certificate::Verify() runs on a worker thread of CertVerifier.
277 EnsureOCSPInit(); 278 EnsureOCSPInit();
278 #endif 279 #endif
279 280
280 LeaveFunction(""); 281 LeaveFunction("");
281 return OK; 282 return OK;
282 } 283 }
283 284
284 int SSLClientSocketNSS::Connect(CompletionCallback* callback, 285 int SSLClientSocketNSS::Connect(CompletionCallback* callback) {
285 const BoundNetLog& net_log) {
286 EnterFunction(""); 286 EnterFunction("");
287 DCHECK(transport_.get()); 287 DCHECK(transport_.get());
288 DCHECK(next_handshake_state_ == STATE_NONE); 288 DCHECK(next_handshake_state_ == STATE_NONE);
289 DCHECK(!user_read_callback_); 289 DCHECK(!user_read_callback_);
290 DCHECK(!user_write_callback_); 290 DCHECK(!user_write_callback_);
291 DCHECK(!user_connect_callback_); 291 DCHECK(!user_connect_callback_);
292 DCHECK(!user_read_buf_); 292 DCHECK(!user_read_buf_);
293 DCHECK(!user_write_buf_); 293 DCHECK(!user_write_buf_);
294 294
295 net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT); 295 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT);
296 296
297 int rv = Init(); 297 int rv = Init();
298 if (rv != OK) { 298 if (rv != OK) {
299 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 299 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
300 return rv; 300 return rv;
301 } 301 }
302 302
303 rv = InitializeSSLOptions(); 303 rv = InitializeSSLOptions();
304 if (rv != OK) { 304 if (rv != OK) {
305 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 305 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
306 return rv; 306 return rv;
307 } 307 }
308 308
309 GotoState(STATE_HANDSHAKE); 309 GotoState(STATE_HANDSHAKE);
310 rv = DoHandshakeLoop(OK); 310 rv = DoHandshakeLoop(OK);
311 if (rv == ERR_IO_PENDING) { 311 if (rv == ERR_IO_PENDING) {
312 user_connect_callback_ = callback; 312 user_connect_callback_ = callback;
313 net_log_ = net_log;
314 } else { 313 } else {
315 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); 314 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
316 } 315 }
317 316
318 LeaveFunction(""); 317 LeaveFunction("");
319 return rv > OK ? OK : rv; 318 return rv > OK ? OK : rv;
320 } 319 }
321 320
322 int SSLClientSocketNSS::InitializeSSLOptions() { 321 int SSLClientSocketNSS::InitializeSSLOptions() {
323 // Transport connected, now hook it up to nss 322 // Transport connected, now hook it up to nss
324 // TODO(port): specify rx and tx buffer sizes separately 323 // TODO(port): specify rx and tx buffer sizes separately
325 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize); 324 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 user_connect_callback_ = NULL; 811 user_connect_callback_ = NULL;
813 c->Run(rv > OK ? OK : rv); 812 c->Run(rv > OK ? OK : rv);
814 LeaveFunction(""); 813 LeaveFunction("");
815 } 814 }
816 815
817 void SSLClientSocketNSS::OnHandshakeIOComplete(int result) { 816 void SSLClientSocketNSS::OnHandshakeIOComplete(int result) {
818 EnterFunction(result); 817 EnterFunction(result);
819 int rv = DoHandshakeLoop(result); 818 int rv = DoHandshakeLoop(result);
820 if (rv != ERR_IO_PENDING) { 819 if (rv != ERR_IO_PENDING) {
821 net_log_.EndEvent(net::NetLog::TYPE_SSL_CONNECT); 820 net_log_.EndEvent(net::NetLog::TYPE_SSL_CONNECT);
822 net_log_ = BoundNetLog();
823 DoConnectCallback(rv); 821 DoConnectCallback(rv);
824 } 822 }
825 LeaveFunction(""); 823 LeaveFunction("");
826 } 824 }
827 825
828 void SSLClientSocketNSS::OnSendComplete(int result) { 826 void SSLClientSocketNSS::OnSendComplete(int result) {
829 EnterFunction(result); 827 EnterFunction(result);
830 if (next_handshake_state_ == STATE_HANDSHAKE) { 828 if (next_handshake_state_ == STATE_HANDSHAKE) {
831 // In handshake phase. 829 // In handshake phase.
832 OnHandshakeIOComplete(result); 830 OnHandshakeIOComplete(result);
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 PRErrorCode prerr = PR_GetError(); 1436 PRErrorCode prerr = PR_GetError();
1439 if (prerr == PR_WOULD_BLOCK_ERROR) { 1437 if (prerr == PR_WOULD_BLOCK_ERROR) {
1440 LeaveFunction(""); 1438 LeaveFunction("");
1441 return ERR_IO_PENDING; 1439 return ERR_IO_PENDING;
1442 } 1440 }
1443 LeaveFunction(""); 1441 LeaveFunction("");
1444 return MapNSPRError(prerr); 1442 return MapNSPRError(prerr);
1445 } 1443 }
1446 1444
1447 } // namespace net 1445 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_nss.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698