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

Unified Diff: net/base/cert_status_flags.h

Issue 7819009: For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. Th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/base/cert_status_flags.h
===================================================================
--- net/base/cert_status_flags.h (revision 101367)
+++ net/base/cert_status_flags.h (working copy)
@@ -6,45 +6,48 @@
#define NET_BASE_CERT_STATUS_FLAGS_H_
#pragma once
+#include "base/basictypes.h"
+
namespace net {
// Status flags, such as errors and extended validation.
-enum {
- // Bits 0 to 15 are for errors.
- CERT_STATUS_ALL_ERRORS = 0xFFFF,
- CERT_STATUS_COMMON_NAME_INVALID = 1 << 0,
- CERT_STATUS_DATE_INVALID = 1 << 1,
- CERT_STATUS_AUTHORITY_INVALID = 1 << 2,
- // 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP).
- CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4,
- CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5,
- CERT_STATUS_REVOKED = 1 << 6,
- CERT_STATUS_INVALID = 1 << 7,
- CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8,
- CERT_STATUS_NOT_IN_DNS = 1 << 9,
- CERT_STATUS_NON_UNIQUE_NAME = 1 << 10,
+// NOTE: Because these names have appeared in bug reports, we preserve them as
+// MACRO_STYLE for continuity, instead of renaming them to kConstantStyle as
+// befits most static consts.
+typedef uint32 CertStatus;
wtc 2011/09/21 23:54:25 The CertStatus type should be defined and document
Peter Kasting 2011/09/22 00:36:17 I don't understand what you're requesting that isn
wtc 2011/09/22 17:55:07 Yes. We need a comment to document that CertStatu
Peter Kasting 2011/09/22 18:25:50 Ah, thanks for the example. Added something.
+static const CertStatus CERT_STATUS_NO_ERROR = 0;
wtc 2011/09/21 23:54:25 Please remove the NO_ERROR constant. It is obviou
Peter Kasting 2011/09/22 00:36:17 I looked up ERROR_IS_SET in code search and didn't
wtc 2011/09/22 17:55:07 Sorry I wasn't clear. What I meant is that if a p
Peter Kasting 2011/09/22 18:25:50 Ah. I think where I'm coming from is that it's no
- // Bits 16 to 30 are for non-error statuses.
- CERT_STATUS_IS_EV = 1 << 16,
- CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17,
- CERT_STATUS_IS_DNSSEC = 1 << 18,
+// Bits 0 to 15 are for errors.
+static const CertStatus CERT_STATUS_ALL_ERRORS = 0xFFFF;
+static const CertStatus CERT_STATUS_COMMON_NAME_INVALID = 1 << 0;
+static const CertStatus CERT_STATUS_DATE_INVALID = 1 << 1;
+static const CertStatus CERT_STATUS_AUTHORITY_INVALID = 1 << 2;
+// 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP).
+static const CertStatus CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4;
+static const CertStatus CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5;
+static const CertStatus CERT_STATUS_REVOKED = 1 << 6;
+static const CertStatus CERT_STATUS_INVALID = 1 << 7;
+static const CertStatus CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8;
+static const CertStatus CERT_STATUS_NOT_IN_DNS = 1 << 9;
+static const CertStatus CERT_STATUS_NON_UNIQUE_NAME = 1 << 10;
- // 1 << 31 (the sign bit) is reserved so that the cert status will never be
- // negative.
-};
+// Bits 16 to 31 are for non-error statuses.
+static const CertStatus CERT_STATUS_IS_EV = 1 << 16;
+static const CertStatus CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17;
+static const CertStatus CERT_STATUS_IS_DNSSEC = 1 << 18;
wtc 2011/09/21 23:54:25 Changing how these flags are defined has the downs
Peter Kasting 2011/09/22 00:36:17 This is true of any cleanup to anything in the cod
// Returns true if the specified cert status has an error set.
-static inline bool IsCertStatusError(int status) {
+static inline bool IsCertStatusError(CertStatus status) {
return (CERT_STATUS_ALL_ERRORS & status) != 0;
}
// Maps a network error code to the equivalent certificate status flag. If
// the error code is not a certificate error, it is mapped to 0.
-int MapNetErrorToCertStatus(int error);
+CertStatus MapNetErrorToCertStatus(int error);
// Maps the most serious certificate error in the certificate status flags
// to the equivalent network error code.
-int MapCertStatusToNetError(int cert_status);
+int MapCertStatusToNetError(CertStatus cert_status);
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698