diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-22 18:46:15 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-22 18:46:15 +0000 |
commit | 653dc46f668da5aed227aafe39ec66fada3df230 (patch) | |
tree | 8e727f8d7cfc758b8ca32a06947c161aea05d8fd /chrome/browser/ssl | |
parent | 59f994ca94ee8bcb4e87467eed3d3f50b358fd5a (diff) | |
download | chromium_src-653dc46f668da5aed227aafe39ec66fada3df230.zip chromium_src-653dc46f668da5aed227aafe39ec66fada3df230.tar.gz chromium_src-653dc46f668da5aed227aafe39ec66fada3df230.tar.bz2 |
For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. This allows code all over Chromium to use an explicit type instead of "int". (This isn't possible by simply naming the enum as technically the enum doesn't define all of the possible combinations of bits.) This also means the individual named bit constants themselves have the same explicit type. I find the resulting code to be noticeably clearer. This also exposed a bug in SSLErrorInfo::GetErrorsForCertStatus() where not having an explicit type allowed a function argument ordering bug to creep in, so I claim this is safer too.
I also added CERT_STATUS_NO_ERROR in place of "0" as a magic number.
Normally this makes things like DCHECK_EQ() unhappy, but when I'd originally tested this I didn't seem to need to make any changes due to that. Will be watching the trybots...
The original motiviation for this change was to find a way to eliminate some cases of passing anonymous-typed values as template arguments (which happens when you use a value from the enum in e.g. EXPECT_EQ()), which is technically illegal in C++03, though we don't warn about it. Simply naming the enum would have done this, but this would have encouraged readers to actually use the enum name as a type, which for a bitfield is inappropriate for the reason given in the first paragraph.
BUG=92247
TEST=Compiles
Review URL: http://codereview.chromium.org/7819009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl')
-rw-r--r-- | chrome/browser/ssl/ssl_browser_tests.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ssl/ssl_error_info.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ssl/ssl_error_info.h | 10 |
3 files changed, 10 insertions, 8 deletions
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc index 59b3712..cf21e5f 100644 --- a/chrome/browser/ssl/ssl_browser_tests.cc +++ b/chrome/browser/ssl/ssl_browser_tests.cc @@ -66,7 +66,7 @@ class SSLUITest : public InProcessBrowserTest { } void CheckAuthenticationBrokenState(TabContents* tab, - int error, + net::CertStatus error, bool ran_insecure_content, bool interstitial) { NavigationEntry* entry = tab->controller().GetActiveEntry(); diff --git a/chrome/browser/ssl/ssl_error_info.cc b/chrome/browser/ssl/ssl_error_info.cc index 63555d4..5eb1927 100644 --- a/chrome/browser/ssl/ssl_error_info.cc +++ b/chrome/browser/ssl/ssl_error_info.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -231,10 +231,10 @@ SSLErrorInfo::ErrorType SSLErrorInfo::NetErrorToErrorType(int net_error) { // static int SSLErrorInfo::GetErrorsForCertStatus(int cert_id, - int cert_status, + net::CertStatus cert_status, const GURL& url, std::vector<SSLErrorInfo>* errors) { - const int kErrorFlags[] = { + const net::CertStatus kErrorFlags[] = { net::CERT_STATUS_COMMON_NAME_INVALID, net::CERT_STATUS_DATE_INVALID, net::CERT_STATUS_AUTHORITY_INVALID, diff --git a/chrome/browser/ssl/ssl_error_info.h b/chrome/browser/ssl/ssl_error_info.h index ca87a0b4..5ef19f1 100644 --- a/chrome/browser/ssl/ssl_error_info.h +++ b/chrome/browser/ssl/ssl_error_info.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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 <vector> #include "base/string16.h" +#include "net/base/cert_status_flags.h" #include "net/base/x509_certificate.h" class GURL; @@ -46,9 +47,10 @@ class SSLErrorInfo { // Populates the specified |errors| vector with the errors contained in // |cert_status|. Returns the number of errors found. // Callers only interested in the error count can pass NULL for |errors|. - static int GetErrorsForCertStatus(int cert_status, - int cert_id, - const GURL& request_url, + // TODO(wtc): Document |cert_id| and |url| arguments. + static int GetErrorsForCertStatus(int cert_id, + net::CertStatus cert_status, + const GURL& url, std::vector<SSLErrorInfo>* errors); // A title describing the error, usually to be used with the details below. |