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

Side by Side Diff: base/unguessable_token.h

Issue 2353663003: Add base::UnguessableToken << operator (Closed)
Patch Set: Addressed comment. Created 4 years, 3 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 | « no previous file | base/unguessable_token.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BASE_UNGUESSABLE_TOKEN_H_ 5 #ifndef BASE_UNGUESSABLE_TOKEN_H_
6 #define BASE_UNGUESSABLE_TOKEN_H_ 6 #define BASE_UNGUESSABLE_TOKEN_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <iosfwd>
10 #include <tuple> 11 #include <tuple>
11 12
12 #include "base/base_export.h" 13 #include "base/base_export.h"
13 #include "base/hash.h" 14 #include "base/hash.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 16
16 namespace base { 17 namespace base {
17 18
18 struct UnguessableTokenHash; 19 struct UnguessableTokenHash;
19 20
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 private: 80 private:
80 friend struct UnguessableTokenHash; 81 friend struct UnguessableTokenHash;
81 UnguessableToken(uint64_t high, uint64_t low); 82 UnguessableToken(uint64_t high, uint64_t low);
82 83
83 // Note: Two uint64_t are used instead of uint8_t[16], in order to have a 84 // Note: Two uint64_t are used instead of uint8_t[16], in order to have a
84 // simpler ToString() and is_empty(). 85 // simpler ToString() and is_empty().
85 uint64_t high_ = 0; 86 uint64_t high_ = 0;
86 uint64_t low_ = 0; 87 uint64_t low_ = 0;
87 }; 88 };
88 89
90 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
91 const UnguessableToken& token);
92
89 // For use in std::unordered_map. 93 // For use in std::unordered_map.
90 struct UnguessableTokenHash { 94 struct UnguessableTokenHash {
91 size_t operator()(const base::UnguessableToken& token) const { 95 size_t operator()(const base::UnguessableToken& token) const {
92 DCHECK(token); 96 DCHECK(token);
93 return base::HashInts64(token.high_, token.low_); 97 return base::HashInts64(token.high_, token.low_);
94 } 98 }
95 }; 99 };
96 100
97 } // namespace base 101 } // namespace base
98 102
99 #endif // BASE_UNGUESSABLE_TOKEN_H_ 103 #endif // BASE_UNGUESSABLE_TOKEN_H_
OLDNEW
« no previous file with comments | « no previous file | base/unguessable_token.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698