| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <tuple> | 12 #include <tuple> |
| 13 | 13 |
| 14 #include "base/hash.h" | 14 #include "base/hash.h" |
| 15 #include "base/unguessable_token.h" | 15 #include "base/unguessable_token.h" |
| 16 #include "mojo/public/cpp/bindings/struct_traits.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 19 namespace mojom { |
| 20 class LocalFrameIdDataView; |
| 21 } |
| 18 | 22 |
| 19 class LocalFrameId { | 23 class LocalFrameId { |
| 20 public: | 24 public: |
| 21 constexpr LocalFrameId() : local_id_(0) {} | 25 constexpr LocalFrameId() : local_id_(0) {} |
| 22 | 26 |
| 23 constexpr LocalFrameId(const LocalFrameId& other) | 27 constexpr LocalFrameId(const LocalFrameId& other) |
| 24 : local_id_(other.local_id_), nonce_(other.nonce_) {} | 28 : local_id_(other.local_id_), nonce_(other.nonce_) {} |
| 25 | 29 |
| 26 constexpr LocalFrameId(uint32_t local_id, const base::UnguessableToken& nonce) | 30 constexpr LocalFrameId(uint32_t local_id, const base::UnguessableToken& nonce) |
| 27 : local_id_(local_id), nonce_(nonce) {} | 31 : local_id_(local_id), nonce_(nonce) {} |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 } | 50 } |
| 47 | 51 |
| 48 size_t hash() const { | 52 size_t hash() const { |
| 49 return base::HashInts( | 53 return base::HashInts( |
| 50 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); | 54 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); |
| 51 } | 55 } |
| 52 | 56 |
| 53 std::string ToString() const; | 57 std::string ToString() const; |
| 54 | 58 |
| 55 private: | 59 private: |
| 60 friend struct mojo::StructTraits<mojom::LocalFrameIdDataView, LocalFrameId>; |
| 61 |
| 56 uint32_t local_id_; | 62 uint32_t local_id_; |
| 57 base::UnguessableToken nonce_; | 63 base::UnguessableToken nonce_; |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id); | 66 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id); |
| 61 | 67 |
| 62 struct LocalFrameIdHash { | 68 struct LocalFrameIdHash { |
| 63 size_t operator()(const LocalFrameId& key) const { return key.hash(); } | 69 size_t operator()(const LocalFrameId& key) const { return key.hash(); } |
| 64 }; | 70 }; |
| 65 | 71 |
| 66 } // namespace cc | 72 } // namespace cc |
| 67 | 73 |
| 68 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ | 74 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ |
| OLD | NEW |