summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-22 18:46:15 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-22 18:46:15 +0000
commit653dc46f668da5aed227aafe39ec66fada3df230 (patch)
tree8e727f8d7cfc758b8ca32a06947c161aea05d8fd /net/http
parent59f994ca94ee8bcb4e87467eed3d3f50b358fd5a (diff)
downloadchromium_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 'net/http')
-rw-r--r--net/http/http_network_transaction_unittest.cc2
-rw-r--r--net/http/http_response_info.cc6
-rw-r--r--net/http/http_transaction_unittest.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index b66c269..81b8718 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -4227,7 +4227,7 @@ TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) {
// Setup state in response_
HttpResponseInfo* response = &trans->response_;
response->auth_challenge = new AuthChallengeInfo();
- response->ssl_info.cert_status = -15;
+ response->ssl_info.cert_status = static_cast<CertStatus>(-1); // Nonsensical.
response->response_time = base::Time::Now();
response->was_cached = true; // (Wouldn't ever actually be true...)
diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc
index a99990b..2496731 100644
--- a/net/http/http_response_info.cc
+++ b/net/http/http_response_info.cc
@@ -151,8 +151,8 @@ bool HttpResponseInfo::InitFromPickle(const Pickle& pickle,
return false;
}
if (flags & RESPONSE_INFO_HAS_CERT_STATUS) {
- int cert_status;
- if (!pickle.ReadInt(&iter, &cert_status))
+ CertStatus cert_status;
+ if (!pickle.ReadUInt32(&iter, &cert_status))
return false;
ssl_info.cert_status = cert_status;
}
@@ -244,7 +244,7 @@ void HttpResponseInfo::Persist(Pickle* pickle,
if (ssl_info.is_valid()) {
ssl_info.cert->Persist(pickle);
- pickle->WriteInt(ssl_info.cert_status);
+ pickle->WriteUInt32(ssl_info.cert_status);
if (ssl_info.security_bits != -1)
pickle->WriteInt(ssl_info.security_bits);
if (ssl_info.connection_status != 0)
diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h
index 714f263..fa6572a 100644
--- a/net/http/http_transaction_unittest.h
+++ b/net/http/http_transaction_unittest.h
@@ -62,7 +62,7 @@ struct MockTransaction {
const char* data;
int test_mode;
MockTransactionHandler handler;
- int cert_status;
+ net::CertStatus cert_status;
};
extern const MockTransaction kSimpleGET_Transaction;