| OLD | NEW |
| 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 #ifndef NET_BASE_HASH_VALUE_H_ | 5 #ifndef NET_BASE_HASH_VALUE_H_ |
| 6 #define NET_BASE_HASH_VALUE_H_ | 6 #define NET_BASE_HASH_VALUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/pickle.h" |
| 15 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 | 21 |
| 21 struct NET_EXPORT SHA1HashValue { | 22 struct NET_EXPORT SHA1HashValue { |
| 22 bool Equals(const SHA1HashValue& other) const; | 23 bool Equals(const SHA1HashValue& other) const; |
| 23 | 24 |
| 25 // Appends a representation of this object to the given pickle. |
| 26 bool Persist(base::Pickle* pickle) const; |
| 27 |
| 28 // Create an SHA1HashValue from the representation stored in the given pickle. |
| 29 // The data for this object is found relative to the given pickle_iter, which |
| 30 // should be passed to the pickle's various Read* methods. |
| 31 // Returns false on failure. |
| 32 static bool CreateFromPickle(base::PickleIterator* iter, SHA1HashValue* hash); |
| 33 |
| 24 unsigned char data[20]; | 34 unsigned char data[20]; |
| 25 }; | 35 }; |
| 26 | 36 |
| 27 struct NET_EXPORT SHA256HashValue { | 37 struct NET_EXPORT SHA256HashValue { |
| 28 bool Equals(const SHA256HashValue& other) const; | 38 bool Equals(const SHA256HashValue& other) const; |
| 29 | 39 |
| 30 unsigned char data[32]; | 40 unsigned char data[32]; |
| 31 }; | 41 }; |
| 32 | 42 |
| 33 enum HashValueTag { | 43 enum HashValueTag { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 125 |
| 116 // IsSHA256HashInSortedArray returns true iff |hash| is in |array|, a sorted | 126 // IsSHA256HashInSortedArray returns true iff |hash| is in |array|, a sorted |
| 117 // array of SHA256 hashes. | 127 // array of SHA256 hashes. |
| 118 bool IsSHA256HashInSortedArray(const SHA256HashValue& hash, | 128 bool IsSHA256HashInSortedArray(const SHA256HashValue& hash, |
| 119 const uint8_t* array, | 129 const uint8_t* array, |
| 120 size_t array_byte_len); | 130 size_t array_byte_len); |
| 121 | 131 |
| 122 } // namespace net | 132 } // namespace net |
| 123 | 133 |
| 124 #endif // NET_BASE_HASH_VALUE_H_ | 134 #endif // NET_BASE_HASH_VALUE_H_ |
| OLD | NEW |