Commit fef2e255 authored by pauljensen's avatar pauljensen Committed by Commit bot

Add type-safe constructors to net::HashValue

BUG=551067

Review URL: https://codereview.chromium.org/1432663002

Cr-Commit-Position: refs/heads/master@{#363051}
parent 7a746bbf
......@@ -31,6 +31,15 @@ bool SHA256HashValue::Equals(const SHA256HashValue& other) const {
return memcmp(data, other.data, sizeof(data)) == 0;
}
HashValue::HashValue(const SHA1HashValue& hash) : HashValue(HASH_VALUE_SHA1) {
fingerprint.sha1 = hash;
}
HashValue::HashValue(const SHA256HashValue& hash)
: HashValue(HASH_VALUE_SHA256) {
fingerprint.sha256 = hash;
}
bool HashValue::Equals(const HashValue& other) const {
if (tag != other.tag)
return false;
......
......@@ -36,6 +36,8 @@ enum HashValueTag {
class NET_EXPORT HashValue {
public:
explicit HashValue(const SHA1HashValue& hash);
explicit HashValue(const SHA256HashValue& hash);
explicit HashValue(HashValueTag tag) : tag(tag) {}
HashValue() : tag(HASH_VALUE_SHA1) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment