| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SURFACE_ID_H_ | 5 #ifndef CC_SURFACES_LOCAL_SURFACE_ID_H_ |
| 6 #define CC_SURFACES_LOCAL_SURFACE_ID_H_ | 6 #define CC_SURFACES_LOCAL_SURFACE_ID_H_ |
| 7 | 7 |
| 8 #include <inttypes.h> | 8 #include <inttypes.h> |
| 9 | 9 |
| 10 #include <iosfwd> | 10 #include <iosfwd> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 bool operator!=(const LocalSurfaceId& other) const { | 46 bool operator!=(const LocalSurfaceId& other) const { |
| 47 return !(*this == other); | 47 return !(*this == other); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool operator<(const LocalSurfaceId& other) const { | 50 bool operator<(const LocalSurfaceId& other) const { |
| 51 return std::tie(local_id_, nonce_) < | 51 return std::tie(local_id_, nonce_) < |
| 52 std::tie(other.local_id_, other.nonce_); | 52 std::tie(other.local_id_, other.nonce_); |
| 53 } | 53 } |
| 54 | 54 |
| 55 size_t hash() const { | 55 size_t hash() const { |
| 56 DCHECK(is_valid()) << ToString(); |
| 56 return base::HashInts( | 57 return base::HashInts( |
| 57 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); | 58 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); |
| 58 } | 59 } |
| 59 | 60 |
| 60 std::string ToString() const; | 61 std::string ToString() const; |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 friend struct mojo::StructTraits<mojom::LocalSurfaceIdDataView, | 64 friend struct mojo::StructTraits<mojom::LocalSurfaceIdDataView, |
| 64 LocalSurfaceId>; | 65 LocalSurfaceId>; |
| 65 | 66 |
| 66 uint32_t local_id_; | 67 uint32_t local_id_; |
| 67 base::UnguessableToken nonce_; | 68 base::UnguessableToken nonce_; |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 std::ostream& operator<<(std::ostream& out, | 71 std::ostream& operator<<(std::ostream& out, |
| 71 const LocalSurfaceId& local_surface_id); | 72 const LocalSurfaceId& local_surface_id); |
| 72 | 73 |
| 73 struct LocalSurfaceIdHash { | 74 struct LocalSurfaceIdHash { |
| 74 size_t operator()(const LocalSurfaceId& key) const { return key.hash(); } | 75 size_t operator()(const LocalSurfaceId& key) const { return key.hash(); } |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 } // namespace cc | 78 } // namespace cc |
| 78 | 79 |
| 79 #endif // CC_SURFACES_LOCAL_SURFACE_ID_H_ | 80 #endif // CC_SURFACES_LOCAL_SURFACE_ID_H_ |
| OLD | NEW |