| OLD | NEW |
| 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 CC_SURFACES_LOCAL_FRAME_ID_H_ | 5 #ifndef CC_SURFACES_LOCAL_FRAME_ID_H_ |
| 6 #define CC_SURFACES_LOCAL_FRAME_ID_H_ | 6 #define CC_SURFACES_LOCAL_FRAME_ID_H_ |
| 7 | 7 |
| 8 #include <inttypes.h> | 8 #include <inttypes.h> |
| 9 | 9 |
| 10 #include <iosfwd> | 10 #include <iosfwd> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool operator!=(const LocalFrameId& other) const { return !(*this == other); } | 45 bool operator!=(const LocalFrameId& other) const { return !(*this == other); } |
| 46 | 46 |
| 47 bool operator<(const LocalFrameId& other) const { | 47 bool operator<(const LocalFrameId& other) const { |
| 48 return std::tie(local_id_, nonce_) < | 48 return std::tie(local_id_, nonce_) < |
| 49 std::tie(other.local_id_, other.nonce_); | 49 std::tie(other.local_id_, other.nonce_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 size_t hash() const { | 52 size_t hash() const { |
| 53 DCHECK(is_valid()) << ToString(); |
| 53 return base::HashInts( | 54 return base::HashInts( |
| 54 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); | 55 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); |
| 55 } | 56 } |
| 56 | 57 |
| 57 std::string ToString() const; | 58 std::string ToString() const; |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 friend struct mojo::StructTraits<mojom::LocalFrameIdDataView, LocalFrameId>; | 61 friend struct mojo::StructTraits<mojom::LocalFrameIdDataView, LocalFrameId>; |
| 61 | 62 |
| 62 uint32_t local_id_; | 63 uint32_t local_id_; |
| 63 base::UnguessableToken nonce_; | 64 base::UnguessableToken nonce_; |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id); | 67 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id); |
| 67 | 68 |
| 68 struct LocalFrameIdHash { | 69 struct LocalFrameIdHash { |
| 69 size_t operator()(const LocalFrameId& key) const { return key.hash(); } | 70 size_t operator()(const LocalFrameId& key) const { return key.hash(); } |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 } // namespace cc | 73 } // namespace cc |
| 73 | 74 |
| 74 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ | 75 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ |
| OLD | NEW |