Chromium Code Reviews| Index: net/socket/ssl_client_socket_nss.cc |
| =================================================================== |
| --- net/socket/ssl_client_socket_nss.cc (revision 142108) |
| +++ net/socket/ssl_client_socket_nss.cc (working copy) |
| @@ -382,11 +382,17 @@ |
| CERT_DestroyCertificate(certs[i]); |
| } |
| +// Helper functions to make it possible to log events from within the |
| +// SSLClientSocketNSS::Core. |
| +void AddLogEvent(BoundNetLog* net_log, |
| + NetLog::EventType event_type) { |
|
eroman
2012/06/14 17:45:50
Might fit on one line
mmenke
2012/06/14 18:03:45
Done.
|
| + if (!net_log) |
| + return; |
| + net_log->AddEvent(event_type); |
| +} |
| + |
| // Helper function to make it possible to log events from within the |
| -// SSLClientSocketNSS::Core. Can't use Bind with BoundNetLog::AddEntry directly |
| -// on Windows because it is overloaded. |
| -// TODO(mmenke): Other than shutdown, NetLog is threadsafe. Figure out if this |
| -// is needed. |
| +// SSLClientSocketNSS::Core. |
| void AddLogEventWithCallback(BoundNetLog* net_log, |
| NetLog::EventType event_type, |
| const NetLog::ParametersCallback& callback) { |
| @@ -395,18 +401,6 @@ |
| net_log->AddEvent(event_type, callback); |
| } |
| -// Helper functions to make it possible to log events from within the |
| -// SSLClientSocketNSS::Core. Can't use Bind with BoundNetLog::AddEntry directly |
| -// on Windows because it is overloaded. |
| -// TODO(mmenke): This function is deprecated, delete it. |
| -void AddLogEvent(BoundNetLog* net_log, |
| - NetLog::EventType event_type, |
| - const scoped_refptr<NetLog::EventParameters>& event_params) { |
| - if (!net_log) |
| - return; |
| - net_log->AddEvent(event_type, event_params); |
| -} |
| - |
| // Helper function to make it easier to call BoundNetLog::AddByteTransferEvent |
| // from within the SSLClientSocketNSS::Core. |
| // AddByteTransferEvent expects to receive a const char*, which within the |
| @@ -1318,8 +1312,7 @@ |
| core->PostOrRunCallback( |
| FROM_HERE, |
| base::Bind(&AddLogEvent, core->weak_net_log_, |
| - NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, |
| - scoped_refptr<NetLog::EventParameters>())); |
| + NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED)); |
| const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); |
| @@ -1364,10 +1357,9 @@ |
| // number collision. See crbug.com/97355. |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", 0)))); |
| + NetLog::IntegerCallback("cert_count", 0))); |
|
eroman
2012/06/14 17:45:50
[optional]: "cert_count" is repeated several times
mmenke
2012/06/14 18:03:45
Done.
|
| return SECFailure; |
| } |
| CERTCertList* cert_chain = CERT_NewCertList(); |
| @@ -1387,10 +1379,9 @@ |
| CERT_DestroyCertList(cert_chain); |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", 0)))); |
| + NetLog::IntegerCallback("cert_count", 0))); |
| return SECFailure; |
| } |
| CERT_AddCertToListTail(cert_chain, intermediate); |
| @@ -1410,11 +1401,9 @@ |
| int cert_count = 1 + intermediates.size(); |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", |
| - cert_count)))); |
| + NetLog::IntegerCallback("cert_count", cert_count))); |
| return SECSuccess; |
| } |
| LOG(WARNING) << "Client cert found without private key"; |
| @@ -1423,10 +1412,9 @@ |
| // Send no client certificate. |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", 0)))); |
| + NetLog::IntegerCallback("cert_count", 0))); |
| return SECFailure; |
| } |
| @@ -1445,10 +1433,9 @@ |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", 0)))); |
| + NetLog::IntegerCallback("cert_count", 0))); |
| return SECFailure; |
| } |
| @@ -1590,11 +1577,9 @@ |
| } |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", |
| - cert_count)))); |
| + NetLog::IntegerCallback("cert_count", cert_count))); |
| return SECSuccess; |
| } |
| OSSTATUS_LOG(WARNING, os_error) |
| @@ -1614,10 +1599,9 @@ |
| // Send no client certificate. |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", 0)))); |
| + NetLog::IntegerCallback("cert_count", 0))); |
| return SECFailure; |
| } |
| @@ -1670,8 +1654,7 @@ |
| core->PostOrRunCallback( |
| FROM_HERE, |
| base::Bind(&AddLogEvent, core->weak_net_log_, |
| - NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, |
| - scoped_refptr<NetLog::EventParameters>())); |
| + NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED)); |
| const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); |
| @@ -1701,10 +1684,9 @@ |
| // NSS will construct the certificate chain. |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", -1)))); |
| + NetLog::IntegerCallback("cert_count", -1))); |
| return SECSuccess; |
| } |
| @@ -1713,10 +1695,9 @@ |
| // Send no client certificate. |
| core->PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, core->weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, core->weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", 0)))); |
| + NetLog::IntegerCallback("cert_count", 0))); |
| return SECFailure; |
| } |
| @@ -1964,9 +1945,9 @@ |
| int rv = ERR_UNEXPECTED; |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_READ_ERROR, |
| - make_scoped_refptr(new SSLErrorParams(rv, 0)))); |
| + CreateNetLogSSLErrorCallback(rv, 0))); |
| return rv; |
| } |
| @@ -1993,9 +1974,9 @@ |
| int rv = ERR_UNEXPECTED; |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_READ_ERROR, |
| - make_scoped_refptr(new SSLErrorParams(rv, 0)))); |
| + CreateNetLogSSLErrorCallback(rv, 0))); |
| return rv; |
| } |
| @@ -2028,9 +2009,9 @@ |
| net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| - make_scoped_refptr(new SSLErrorParams(net_error, 0)))); |
| + CreateNetLogSSLErrorCallback(net_error, 0))); |
| // If the handshake already succeeded (because the server requests but |
| // doesn't require a client cert), we need to invalidate the SSL session |
| @@ -2048,10 +2029,9 @@ |
| net_error = ERR_SSL_PROTOCOL_ERROR; |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| - make_scoped_refptr( |
| - new SSLErrorParams(net_error, 0)))); |
| + CreateNetLogSSLErrorCallback(net_error, 0))); |
| } else { |
| #if defined(SSL_ENABLE_OCSP_STAPLING) |
| // TODO(agl): figure out how to plumb an OCSP response into the Mac |
| @@ -2126,10 +2106,9 @@ |
| } else { |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| - make_scoped_refptr( |
| - new SSLErrorParams(net_error, prerr)))); |
| + CreateNetLogSSLErrorCallback(net_error, prerr))); |
| } |
| } |
| @@ -2167,11 +2146,9 @@ |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", |
| - cert_chain->len)))); |
| + NetLog::IntegerCallback("cert_count", cert_chain->len))); |
| rv = SSL_RestartHandshakeAfterCertReq(nss_fd_, cert, key, cert_chain); |
| if (rv != SECSuccess) |
| @@ -2193,9 +2170,9 @@ |
| rv = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_READ_ERROR, |
| - make_scoped_refptr(new SSLErrorParams(rv, 0)))); |
| + CreateNetLogSSLErrorCallback(rv, 0))); |
| return rv; |
| } |
| if (rv >= 0) { |
| @@ -2213,9 +2190,9 @@ |
| rv = HandleNSSError(prerr, false); |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_READ_ERROR, |
| - make_scoped_refptr(new SSLErrorParams(rv, prerr)))); |
| + CreateNetLogSSLErrorCallback(rv, prerr))); |
| return rv; |
| } |
| @@ -2240,9 +2217,9 @@ |
| rv = HandleNSSError(prerr, false); |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_WRITE_ERROR, |
| - make_scoped_refptr(new SSLErrorParams(rv, prerr)))); |
| + CreateNetLogSSLErrorCallback(rv, prerr))); |
| return rv; |
| } |
| @@ -2488,11 +2465,9 @@ |
| int cert_count = (rv == SECSuccess) ? 1 : 0; |
| PostOrRunCallback( |
| FROM_HERE, |
| - base::Bind(&AddLogEvent, weak_net_log_, |
| + base::Bind(&AddLogEventWithCallback, weak_net_log_, |
| NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| - make_scoped_refptr( |
| - new NetLogIntegerParameter("cert_count", |
| - cert_count)))); |
| + NetLog::IntegerCallback("cert_count", cert_count))); |
| return rv; |
| } |
| @@ -2697,7 +2672,7 @@ |
| if (detached_) |
| return ERR_FAILED; |
| - weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT, NULL); |
| + weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT); |
| int rv = server_bound_cert_service_->GetDomainBoundCert( |
| origin, |
| @@ -2942,7 +2917,7 @@ |
| EnsureThreadIdAssigned(); |
| - net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT, NULL); |
| + net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); |
| int rv = Init(); |
| if (rv != OK) { |
| @@ -3529,7 +3504,7 @@ |
| // server then it will have optimistically started a verification of that |
| // chain. So, if the prediction was correct, we should wait for that |
| // verification to finish rather than start our own. |
| - net_log_.AddEvent(NetLog::TYPE_SSL_VERIFICATION_MERGED, NULL); |
| + net_log_.AddEvent(NetLog::TYPE_SSL_VERIFICATION_MERGED); |
| UMA_HISTOGRAM_ENUMERATION("Net.SSLVerificationMerged", 1 /* true */, 2); |
| base::TimeTicks end_time = ssl_host_info_->verification_end_time(); |
| if (end_time.is_null()) |