Chromium Code Reviews| Index: cc/surfaces/local_frame_id.h |
| diff --git a/cc/surfaces/local_frame_id.h b/cc/surfaces/local_frame_id.h |
| index 859e0070e8d339a92403860aa51afd371ac323cb..467fa196c0be0bf37e8ca323c28968b63370b02e 100644 |
| --- a/cc/surfaces/local_frame_id.h |
| +++ b/cc/surfaces/local_frame_id.h |
| @@ -10,24 +10,28 @@ |
| #include "base/hash.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/unguessable_token.h" |
| namespace cc { |
| class LocalFrameId { |
| public: |
| - constexpr LocalFrameId() : local_id_(0), nonce_(0) {} |
| + constexpr LocalFrameId() : local_id_(0) {} |
| constexpr LocalFrameId(const LocalFrameId& other) |
| : local_id_(other.local_id_), nonce_(other.nonce_) {} |
| - constexpr LocalFrameId(uint32_t local_id, uint64_t nonce) |
| + explicit LocalFrameId(uint32_t local_id) |
|
Fady Samuel
2016/10/07 14:18:11
Do we need this constructor? Can we simply create
Alex Z.
2016/10/07 14:27:49
Done.
|
| + : local_id_(local_id), nonce_(base::UnguessableToken::Create()) {} |
| + |
| + constexpr LocalFrameId(uint32_t local_id, const base::UnguessableToken& nonce) |
| : local_id_(local_id), nonce_(nonce) {} |
| - constexpr bool is_null() const { return local_id_ == 0 && nonce_ == 0; } |
| + constexpr bool is_null() const { return local_id_ == 0 && nonce_.is_empty(); } |
| constexpr uint32_t local_id() const { return local_id_; } |
| - constexpr uint64_t nonce() const { return nonce_; } |
| + constexpr const base::UnguessableToken& nonce() const { return nonce_; } |
| bool operator==(const LocalFrameId& other) const { |
| return local_id_ == other.local_id_ && nonce_ == other.nonce_; |
| @@ -40,16 +44,18 @@ class LocalFrameId { |
| std::tie(other.local_id_, other.nonce_); |
| } |
| - size_t hash() const { return base::HashInts(local_id_, nonce_); } |
| + size_t hash() const { |
| + return base::HashInts(local_id_, base::UnguessableTokenHash()(nonce_)); |
| + } |
| std::string ToString() const { |
| - return base::StringPrintf("LocalFrameId(%d, %" PRIu64 ")", local_id_, |
| - nonce_); |
| + return base::StringPrintf("LocalFrameId(%d, %s" PRIu64 ")", local_id_, |
| + nonce_.ToString().c_str()); |
| } |
| private: |
| uint32_t local_id_; |
| - uint64_t nonce_; |
| + base::UnguessableToken nonce_; |
| }; |
| struct LocalFrameIdHash { |