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

Side by Side Diff: net/base/hash_value.cc

Issue 1738363002: Pickle (serialize and deserialize) MultiThreadedCertVerifier's |cache_| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/base/hash_value.h ('k') | net/cert/cert_verify_result.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/hash_value.h" 5 #include "net/base/hash_value.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 return memcmp(a, b, base::kSHA1Length); 23 return memcmp(a, b, base::kSHA1Length);
24 } 24 }
25 25
26 } // namespace 26 } // namespace
27 27
28 28
29 bool SHA1HashValue::Equals(const SHA1HashValue& other) const { 29 bool SHA1HashValue::Equals(const SHA1HashValue& other) const {
30 return memcmp(data, other.data, sizeof(data)) == 0; 30 return memcmp(data, other.data, sizeof(data)) == 0;
31 } 31 }
32 32
33 bool SHA1HashValue::Persist(base::Pickle* pickle) const {
34 return pickle->WriteBytes(data, sizeof(data));
35 }
36
37 bool SHA1HashValue::CreateFromPickle(base::PickleIterator* iter,
38 SHA1HashValue* hash) {
39 const char* outdata_char = NULL;
40 if (!iter->ReadBytes(&outdata_char, sizeof(hash->data)))
41 return false;
42 memcpy(&hash->data, outdata_char, sizeof(hash->data));
43 return true;
44 }
45
33 bool SHA256HashValue::Equals(const SHA256HashValue& other) const { 46 bool SHA256HashValue::Equals(const SHA256HashValue& other) const {
34 return memcmp(data, other.data, sizeof(data)) == 0; 47 return memcmp(data, other.data, sizeof(data)) == 0;
35 } 48 }
36 49
37 HashValue::HashValue(const SHA1HashValue& hash) : HashValue(HASH_VALUE_SHA1) { 50 HashValue::HashValue(const SHA1HashValue& hash) : HashValue(HASH_VALUE_SHA1) {
38 fingerprint.sha1 = hash; 51 fingerprint.sha1 = hash;
39 } 52 }
40 53
41 HashValue::HashValue(const SHA256HashValue& hash) 54 HashValue::HashValue(const SHA256HashValue& hash)
42 : HashValue(HASH_VALUE_SHA256) { 55 : HashValue(HASH_VALUE_SHA256) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 bool IsSHA256HashInSortedArray(const SHA256HashValue& hash, 139 bool IsSHA256HashInSortedArray(const SHA256HashValue& hash,
127 const uint8_t* array, 140 const uint8_t* array,
128 size_t array_byte_len) { 141 size_t array_byte_len) {
129 DCHECK_EQ(0u, array_byte_len % crypto::kSHA256Length); 142 DCHECK_EQ(0u, array_byte_len % crypto::kSHA256Length);
130 const size_t arraylen = array_byte_len / crypto::kSHA256Length; 143 const size_t arraylen = array_byte_len / crypto::kSHA256Length;
131 return NULL != bsearch(hash.data, array, arraylen, crypto::kSHA256Length, 144 return NULL != bsearch(hash.data, array, arraylen, crypto::kSHA256Length,
132 CompareSHA1Hashes); 145 CompareSHA1Hashes);
133 } 146 }
134 147
135 } // namespace net 148 } // namespace net
OLDNEW
« no previous file with comments | « net/base/hash_value.h ('k') | net/cert/cert_verify_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698