diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 23:06:49 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 23:06:49 +0000 |
commit | 33b9820a5039e8a9925ddc0ebaced8f50112ce3b (patch) | |
tree | fc66820a0ea13d0160dfb3253028cb8a1d3b468f /net | |
parent | 1797640037e0127eb5f47bc60dc94b78a2b904b5 (diff) | |
download | chromium_src-33b9820a5039e8a9925ddc0ebaced8f50112ce3b.zip chromium_src-33b9820a5039e8a9925ddc0ebaced8f50112ce3b.tar.gz chromium_src-33b9820a5039e8a9925ddc0ebaced8f50112ce3b.tar.bz2 |
Add OSSTATUS_LOG API.
Review URL: https://chromiumcodereview.appspot.com/9235084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/cert_database_mac.cc | 5 | ||||
-rw-r--r-- | net/base/keygen_handler_mac.cc | 5 | ||||
-rw-r--r-- | net/base/x509_cert_types_mac.cc | 5 | ||||
-rw-r--r-- | net/base/x509_certificate_mac.cc | 35 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_mac.cc | 14 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_nss.cc | 5 |
6 files changed, 33 insertions, 36 deletions
diff --git a/net/base/cert_database_mac.cc b/net/base/cert_database_mac.cc index 06b036f..e2542fd 100644 --- a/net/base/cert_database_mac.cc +++ b/net/base/cert_database_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,7 @@ #include <Security/Security.h> #include "base/logging.h" +#include "base/mac/mac_logging.h" #include "base/synchronization/lock.h" #include "crypto/mac_security_services_lock.h" #include "net/base/net_errors.h" @@ -53,7 +54,7 @@ int CertDatabase::AddUserCert(X509Certificate* cert) { case errSecDuplicateItem: return OK; default: - LOG(ERROR) << "CertDatabase failed to add cert to keychain: " << err; + OSSTATUS_LOG(ERROR, err) << "CertDatabase failed to add cert to keychain"; // TODO(snej): Map the error code more intelligently. return ERR_ADD_USER_CERT_FAILED; } diff --git a/net/base/keygen_handler_mac.cc b/net/base/keygen_handler_mac.cc index 1bb4038..12a904f2 100644 --- a/net/base/keygen_handler_mac.cc +++ b/net/base/keygen_handler_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "base/base64.h" #include "base/logging.h" +#include "base/mac/mac_logging.h" #include "base/mac/scoped_cftyperef.h" #include "base/string_util.h" #include "base/synchronization/lock.h" @@ -192,7 +193,7 @@ std::string KeygenHandler::GenKeyAndSignChallenge() { failure: if (err) - LOG(ERROR) << "SSL Keygen failed! OSStatus = " << err; + OSSTATUS_LOG(ERROR, err) << "SSL Keygen failed!"; else VLOG(1) << "SSL Keygen succeeded! Output is: " << result; diff --git a/net/base/x509_cert_types_mac.cc b/net/base/x509_cert_types_mac.cc index 7f192b1..11073ef 100644 --- a/net/base/x509_cert_types_mac.cc +++ b/net/base/x509_cert_types_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/i18n/icu_string_conversions.h" +#include "base/mac/mac_logging.h" #include "base/utf_string_conversions.h" namespace net { @@ -202,7 +203,7 @@ bool CertPrincipal::ParseDistinguishedName(const void* ber_name_data, OSStatus err = SecAsn1Decode(coder, ber_name_data, length, kNameTemplate, &name); if (err) { - LOG(ERROR) << "SecAsn1Decode returned " << err << "; name=" << name; + OSSTATUS_LOG(ERROR, err) << "SecAsn1Decode name=" << name; SecAsn1CoderRelease(coder); return false; } diff --git a/net/base/x509_certificate_mac.cc b/net/base/x509_certificate_mac.cc index b796288..b2bdbd0 100644 --- a/net/base/x509_certificate_mac.cc +++ b/net/base/x509_certificate_mac.cc @@ -13,6 +13,7 @@ #include "base/lazy_instance.h" #include "base/logging.h" +#include "base/mac/mac_logging.h" #include "base/mac/scoped_cftyperef.h" #include "base/memory/singleton.h" #include "base/pickle.h" @@ -53,11 +54,7 @@ int NetErrorFromOSStatus(OSStatus status) { case errSecAuthFailed: return ERR_ACCESS_DENIED; default: { - base::mac::ScopedCFTypeRef<CFStringRef> error_string( - SecCopyErrorMessageString(status, NULL)); - LOG(ERROR) << "Unknown error " << status - << " (" << base::SysCFStringRefToUTF8(error_string) << ")" - << " mapped to ERR_FAILED"; + OSSTATUS_LOG(ERROR, status) << "Unknown error mapped to ERR_FAILED"; return ERR_FAILED; } } @@ -121,11 +118,8 @@ CertStatus CertStatusFromOSStatus(OSStatus status) { // Failure was due to something Chromium doesn't define a // specific status for (such as basic constraints violation, or // unknown critical extension) - base::mac::ScopedCFTypeRef<CFStringRef> error_string( - SecCopyErrorMessageString(status, NULL)); - LOG(WARNING) << "Unknown error " << status - << " (" << base::SysCFStringRefToUTF8(error_string) << ")" - << " mapped to CERT_STATUS_INVALID"; + OSSTATUS_LOG(WARNING, status) + << "Unknown error mapped to CERT_STATUS_INVALID"; return CERT_STATUS_INVALID; } } @@ -536,8 +530,8 @@ void AddCertificatesFromBytes(const char* data, size_t length, OSStatus status = SecKeychainItemImport(local_data, NULL, &input_format, NULL, 0, NULL, NULL, &items); if (status) { - DLOG(WARNING) << status << " Unable to import items from data of length " - << length; + OSSTATUS_DLOG(WARNING, status) + << "Unable to import items from data of length " << length; return; } @@ -786,7 +780,7 @@ X509Certificate* X509Certificate::CreateSelfSigned( DCHECK(!subject.empty()); if (valid_duration.InSeconds() > kuint32max) { - LOG(ERROR) << "valid_duration too big" << valid_duration.InSeconds(); + LOG(ERROR) << "valid_duration too big " << valid_duration.InSeconds(); valid_duration = base::TimeDelta::FromSeconds(kuint32max); } @@ -906,7 +900,7 @@ X509Certificate* X509Certificate::CreateSelfSigned( SecCertificateCreateFromData(&encCert->CertBlob, encCert->CertType, encCert->CertEncoding, &certificate_ref); if (os_status != 0) { - DLOG(ERROR) << "SecCertificateCreateFromData failed: " << os_status; + OSSTATUS_DLOG(ERROR, os_status) << "SecCertificateCreateFromData failed"; return NULL; } scoped_cert.reset(certificate_ref); @@ -1331,8 +1325,7 @@ bool X509Certificate::IsIssuedBy( const std::vector<CertPrincipal>& valid_issuers) { // Get the cert's issuer chain. CFArrayRef cert_chain = NULL; - OSStatus result; - result = CopyCertChain(os_cert_handle(), &cert_chain); + OSStatus result = CopyCertChain(os_cert_handle(), &cert_chain); if (result) return false; ScopedCFTypeRef<CFArrayRef> scoped_cert_chain(cert_chain); @@ -1502,7 +1495,7 @@ bool X509Certificate::GetSSLClientCertificates( } if (err != errSecItemNotFound) { - LOG(ERROR) << "SecIdentitySearch error " << err; + OSSTATUS_LOG(ERROR, err) << "SecIdentitySearch error "; return false; } return true; @@ -1510,11 +1503,11 @@ bool X509Certificate::GetSSLClientCertificates( CFArrayRef X509Certificate::CreateClientCertificateChain() const { // Initialize the result array with just the IdentityRef of the receiver: - OSStatus result; SecIdentityRef identity; - result = SecIdentityCreateWithCertificate(NULL, cert_handle_, &identity); + OSStatus result = + SecIdentityCreateWithCertificate(NULL, cert_handle_, &identity); if (result) { - LOG(ERROR) << "SecIdentityCreateWithCertificate error " << result; + OSSTATUS_LOG(ERROR, result) << "SecIdentityCreateWithCertificate error"; return NULL; } ScopedCFTypeRef<CFMutableArrayRef> chain( @@ -1525,7 +1518,7 @@ CFArrayRef X509Certificate::CreateClientCertificateChain() const { result = CopyCertChain(cert_handle_, &cert_chain); ScopedCFTypeRef<CFArrayRef> scoped_cert_chain(cert_chain); if (result) { - LOG(ERROR) << "CreateIdentityCertificateChain error " << result; + OSSTATUS_LOG(ERROR, result) << "CreateIdentityCertificateChain error"; return chain.release(); } diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc index b6e03f7..824b447 100644 --- a/net/socket/ssl_client_socket_mac.cc +++ b/net/socket/ssl_client_socket_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +13,7 @@ #include "base/bind.h" #include "base/lazy_instance.h" +#include "base/mac/mac_logging.h" #include "base/mac/scoped_cftyperef.h" #include "base/string_util.h" #include "net/base/address_list.h" @@ -203,7 +204,7 @@ int NetErrorFromOSStatus(OSStatus status) { case errSSLPeerCertUnknown...errSSLPeerBadCert: case errSSLPeerUnknownCA: case errSSLPeerAccessDenied: - LOG(WARNING) << "Server rejected client cert (OSStatus=" << status << ")"; + OSSTATUS_LOG(WARNING, status) << "Server rejected client cert"; return ERR_BAD_SSL_CLIENT_AUTH_CERT; case errSSLNegotiation: @@ -215,8 +216,8 @@ int NetErrorFromOSStatus(OSStatus status) { case errSSLModuleAttach: case errSSLSessionNotFound: default: - LOG(WARNING) << "Unknown error " << status << - " mapped to net::ERR_FAILED"; + OSSTATUS_LOG(WARNING, status) + << "Unknown error mapped to net::ERR_FAILED"; return ERR_FAILED; } } @@ -240,8 +241,7 @@ OSStatus OSStatusFromNetError(int net_error) { case OK: return noErr; default: - LOG(WARNING) << "Unknown error " << net_error << - " mapped to paramErr"; + LOG(WARNING) << "Unknown error " << net_error << " mapped to paramErr"; return paramErr; } } @@ -1196,7 +1196,7 @@ int SSLClientSocketMac::SetClientCert() { VLOG(1) << "SSLSetCertificate(" << CFArrayGetCount(cert_refs) << " certs)"; OSStatus result = SSLSetCertificate(ssl_context_, cert_refs); if (result) - LOG(ERROR) << "SSLSetCertificate returned OSStatus " << result; + OSSTATUS_LOG(ERROR, result) << "SSLSetCertificate failed"; return result; } diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index 50b7514..6c70615 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -108,6 +108,7 @@ #include <Security/SecBase.h> #include <Security/SecCertificate.h> #include <Security/SecIdentity.h> +#include "base/mac/mac_logging.h" #elif defined(USE_NSS) #include <dlfcn.h> #endif @@ -2506,8 +2507,8 @@ SECStatus SSLClientSocketNSS::PlatformClientAuthHandler( cert_count))); return SECSuccess; } - LOG(WARNING) << "Client cert found, but could not be used: " - << os_error; + OSSTATUS_LOG(WARNING, os_error) + << "Client cert found, but could not be used"; if (*result_certs) { CERT_DestroyCertList(*result_certs); *result_certs = NULL; |