| 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 |
| 10 #include <iosfwd> |
| 11 #include <string> |
| 9 #include <tuple> | 12 #include <tuple> |
| 10 | 13 |
| 11 #include "base/hash.h" | 14 #include "base/hash.h" |
| 12 #include "base/strings/stringprintf.h" | |
| 13 #include "base/unguessable_token.h" | 15 #include "base/unguessable_token.h" |
| 14 | 16 |
| 15 namespace cc { | 17 namespace cc { |
| 16 | 18 |
| 17 class LocalFrameId { | 19 class LocalFrameId { |
| 18 public: | 20 public: |
| 19 constexpr LocalFrameId() : local_id_(0) {} | 21 constexpr LocalFrameId() : local_id_(0) {} |
| 20 | 22 |
| 21 constexpr LocalFrameId(const LocalFrameId& other) | 23 constexpr LocalFrameId(const LocalFrameId& other) |
| 22 : local_id_(other.local_id_), nonce_(other.nonce_) {} | 24 : local_id_(other.local_id_), nonce_(other.nonce_) {} |
| (...skipping 18 matching lines...) Expand all Loading... |
| 41 bool operator<(const LocalFrameId& other) const { | 43 bool operator<(const LocalFrameId& other) const { |
| 42 return std::tie(local_id_, nonce_) < | 44 return std::tie(local_id_, nonce_) < |
| 43 std::tie(other.local_id_, other.nonce_); | 45 std::tie(other.local_id_, other.nonce_); |
| 44 } | 46 } |
| 45 | 47 |
| 46 size_t hash() const { | 48 size_t hash() const { |
| 47 return base::HashInts( | 49 return base::HashInts( |
| 48 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); | 50 local_id_, static_cast<uint64_t>(base::UnguessableTokenHash()(nonce_))); |
| 49 } | 51 } |
| 50 | 52 |
| 51 std::string ToString() const { | 53 std::string ToString() const; |
| 52 return base::StringPrintf("LocalFrameId(%d, %s" PRIu64 ")", local_id_, | |
| 53 nonce_.ToString().c_str()); | |
| 54 } | |
| 55 | 54 |
| 56 private: | 55 private: |
| 57 uint32_t local_id_; | 56 uint32_t local_id_; |
| 58 base::UnguessableToken nonce_; | 57 base::UnguessableToken nonce_; |
| 59 }; | 58 }; |
| 60 | 59 |
| 60 std::ostream& operator<<(std::ostream& out, const LocalFrameId& local_frame_id); |
| 61 |
| 61 struct LocalFrameIdHash { | 62 struct LocalFrameIdHash { |
| 62 size_t operator()(const LocalFrameId& key) const { return key.hash(); } | 63 size_t operator()(const LocalFrameId& key) const { return key.hash(); } |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 } // namespace cc | 66 } // namespace cc |
| 66 | 67 |
| 67 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ | 68 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ |
| OLD | NEW |