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

Issue 7819009: For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. Th... (Closed)

Created:
9 years, 3 months ago by Peter Kasting
Modified:
9 years, 3 months ago
Reviewers:
wtc, jam
CC:
chromium-reviews, Avi (use Gerrit), kkania, brettw-cc_chromium.org, jam, cbentzel+watch_chromium.org, joi+watch-content_chromium.org, darin-cc_chromium.org, Paweł Hajdan Jr.
Visibility:
Public.

Description

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

Patch Set 1 #

Total comments: 5

Patch Set 2 : '' #

Patch Set 3 : '' #

Patch Set 4 : '' #

Total comments: 19

Patch Set 5 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+145 lines, -114 lines) Patch
M chrome/browser/automation/testing_automation_provider.h View 1 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/browser/automation/testing_automation_provider.cc View 1 2 3 4 1 chunk +6 lines, -5 lines 0 comments Download
M chrome/browser/page_info_model.cc View 1 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/ssl/ssl_browser_tests.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ssl/ssl_error_info.h View 1 2 3 4 2 chunks +5 lines, -3 lines 0 comments Download
M chrome/browser/ssl/ssl_error_info.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/tab_contents/render_view_context_menu.cc View 1 1 chunk +4 lines, -1 line 0 comments Download
M chrome/browser/ui/toolbar/toolbar_model.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/common/automation_messages_internal.h View 1 2 3 4 2 chunks +4 lines, -3 lines 0 comments Download
M chrome/test/automation/tab_proxy.h View 1 1 chunk +1 line, -1 line 0 comments Download
M chrome/test/automation/tab_proxy.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M content/browser/load_from_memory_cache_details.h View 1 2 chunks +4 lines, -3 lines 0 comments Download
M content/browser/load_from_memory_cache_details.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/resource_request_details.h View 1 3 chunks +3 lines, -2 lines 0 comments Download
M content/browser/ssl/ssl_manager.h View 1 2 chunks +8 lines, -6 lines 0 comments Download
M content/browser/ssl/ssl_manager.cc View 1 2 3 4 4 chunks +8 lines, -6 lines 0 comments Download
M content/browser/ssl/ssl_policy.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/ssl/ssl_request_info.h View 1 3 chunks +4 lines, -3 lines 0 comments Download
M content/browser/ssl/ssl_request_info.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M content/browser/tab_contents/navigation_entry.h View 1 3 chunks +4 lines, -3 lines 0 comments Download
M content/browser/tab_contents/navigation_entry_unittest.cc View 1 2 3 4 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/tab_contents/provisional_load_details.h View 1 3 chunks +3 lines, -2 lines 0 comments Download
M content/browser/tab_contents/tab_contents.cc View 1 2 3 4 1 chunk +4 lines, -1 line 0 comments Download
M net/base/cert_status_flags.h View 1 2 3 4 1 chunk +29 lines, -25 lines 0 comments Download
M net/base/cert_status_flags.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M net/base/cert_verify_result.h View 1 2 chunks +2 lines, -1 line 0 comments Download
M net/base/ssl_config_service.h View 1 3 chunks +4 lines, -3 lines 0 comments Download
M net/base/ssl_config_service.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M net/base/ssl_info.h View 1 2 chunks +2 lines, -1 line 0 comments Download
M net/base/x509_certificate_mac.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/base/x509_certificate_nss.cc View 1 2 chunks +3 lines, -3 lines 0 comments Download
M net/base/x509_certificate_openssl.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M net/base/x509_certificate_unittest.cc View 1 2 3 4 6 chunks +9 lines, -9 lines 0 comments Download
M net/base/x509_certificate_win.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_network_transaction_unittest.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_response_info.cc View 1 2 chunks +3 lines, -3 lines 0 comments Download
M net/http/http_transaction_unittest.h View 1 1 chunk +1 line, -1 line 0 comments Download
M net/socket/ssl_client_socket_mac.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M net/socket/ssl_client_socket_nss.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M net/socket/ssl_client_socket_openssl.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M net/socket/ssl_client_socket_win.cc View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 12 (0 generated)
Peter Kasting
jam: content/ wtc: rest
9 years, 3 months ago (2011-08-31 21:44:07 UTC) #1
Peter Kasting
NOTE (mostly to self): Also need to change "0" to "CERT_STATUS_NO_ERROR" in two places in ...
9 years, 3 months ago (2011-09-01 00:19:54 UTC) #2
jam
content lgtm
9 years, 3 months ago (2011-09-01 01:50:42 UTC) #3
wtc
Adding the CertStatus typedef is a good idea. But the potential "deal breaker" for this ...
9 years, 3 months ago (2011-09-02 22:40:35 UTC) #4
Peter Kasting
http://codereview.chromium.org/7819009/diff/1/net/base/cert_status_flags.h File net/base/cert_status_flags.h (right): http://codereview.chromium.org/7819009/diff/1/net/base/cert_status_flags.h#newcode34 net/base/cert_status_flags.h:34: static const CertStatus CERT_STATUS_IS_DNSSEC = 1 << 18; On ...
9 years, 3 months ago (2011-09-12 17:28:40 UTC) #5
Peter Kasting
http://codereview.chromium.org/7819009/diff/1/net/base/cert_status_flags.h File net/base/cert_status_flags.h (right): http://codereview.chromium.org/7819009/diff/1/net/base/cert_status_flags.h#newcode34 net/base/cert_status_flags.h:34: static const CertStatus CERT_STATUS_IS_DNSSEC = 1 << 18; On ...
9 years, 3 months ago (2011-09-12 17:33:41 UTC) #6
Peter Kasting
On 2011/09/12 17:28:40, Peter Kasting wrote: > http://codereview.chromium.org/7819009/diff/1/net/base/cert_status_flags.h > File net/base/cert_status_flags.h (right): > > In ...
9 years, 3 months ago (2011-09-15 20:28:06 UTC) #7
wtc
Sorry about the late reply. I was out of the office in the past few ...
9 years, 3 months ago (2011-09-20 18:21:17 UTC) #8
wtc
LGTM on Patch Set 4. Please remove the CERT_STATUS_NO_ERROR constant before you check this in. ...
9 years, 3 months ago (2011-09-21 23:54:24 UTC) #9
Peter Kasting
http://codereview.chromium.org/7819009/diff/25011/chrome/browser/ssl/ssl_error_info.h File chrome/browser/ssl/ssl_error_info.h (right): http://codereview.chromium.org/7819009/diff/25011/chrome/browser/ssl/ssl_error_info.h#newcode49 chrome/browser/ssl/ssl_error_info.h:49: // Callers only interested in the error count can ...
9 years, 3 months ago (2011-09-22 00:36:17 UTC) #10
wtc
http://codereview.chromium.org/7819009/diff/25011/net/base/cert_status_flags.h File net/base/cert_status_flags.h (right): http://codereview.chromium.org/7819009/diff/25011/net/base/cert_status_flags.h#newcode17 net/base/cert_status_flags.h:17: typedef uint32 CertStatus; On 2011/09/22 00:36:17, Peter Kasting wrote: ...
9 years, 3 months ago (2011-09-22 17:55:06 UTC) #11
Peter Kasting
9 years, 3 months ago (2011-09-22 18:25:50 UTC) #12
Will check in.

http://codereview.chromium.org/7819009/diff/25011/net/base/cert_status_flags.h
File net/base/cert_status_flags.h (right):

http://codereview.chromium.org/7819009/diff/25011/net/base/cert_status_flags....
net/base/cert_status_flags.h:17: typedef uint32 CertStatus;
On 2011/09/22 17:55:07, wtc wrote:
> Yes.  We need a comment to document that CertStatus is a
> bitwise-OR of the CERT_STATUS_xxx flags.

Ah, thanks for the example.  Added something.

http://codereview.chromium.org/7819009/diff/25011/net/base/cert_status_flags....
net/base/cert_status_flags.h:18: static const CertStatus CERT_STATUS_NO_ERROR   
               = 0;
On 2011/09/22 17:55:07, wtc wrote:
> Sorry I wasn't clear.  What I meant is that if a programmer
> needs a NO_ERROR constant to understand what a bitmask of 0
> means, that shows he is unfamiliar with bit manipulation,
> and therefore he is likely to also need functions/macros
> for setting a bit flag, clearing a bit flag, or testing if
> a bit flag is set.

Ah.  I think where I'm coming from is that it's not always obvious at all usage
points that CertStatus is actually a bitfield, what the bit values are, and what
"0" means, without referring back to the definition here.  I was trying to help
that.  But you own this code, so if you really don't think it's a good idea,
fair enough.  I've removed it.

Powered by Google App Engine
This is Rietveld 408576698