Chromium Code Reviews| 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 #include <tuple> | 9 #include <tuple> |
| 10 | 10 |
| 11 #include "base/hash.h" | 11 #include "base/hash.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class LocalFrameId { | 16 class LocalFrameId { |
| 17 public: | 17 public: |
| 18 constexpr LocalFrameId() : local_id_(0), nonce_(0) {} | 18 constexpr LocalFrameId() : local_id_(0), nonce_(0) {} |
| 19 | 19 |
| 20 constexpr LocalFrameId(const LocalFrameId& other) | 20 constexpr LocalFrameId(const LocalFrameId& other) |
| 21 : local_id_(other.local_id_), nonce_(other.nonce_) {} | 21 : local_id_(other.local_id_), nonce_(other.nonce_) {} |
| 22 | 22 |
| 23 constexpr LocalFrameId(uint32_t local_id, uint64_t nonce) | 23 constexpr LocalFrameId(uint32_t local_id, uint64_t nonce) |
| 24 : local_id_(local_id), nonce_(nonce) {} | 24 : local_id_(local_id), nonce_(nonce) {} |
| 25 | 25 |
| 26 constexpr bool is_valid() const { return local_id_ != 0; } | |
|
Fady Samuel
2016/10/20 12:15:36
I disagree with this. is_valid() means local_id_ !
Alex Z.
2016/11/08 21:38:19
Done.
| |
| 27 | |
| 26 constexpr bool is_null() const { return local_id_ == 0 && nonce_ == 0; } | 28 constexpr bool is_null() const { return local_id_ == 0 && nonce_ == 0; } |
|
Fady Samuel
2016/10/20 12:15:36
Ideally, I'd like to get rid of is_null() because
Alex Z.
2016/11/08 21:38:19
Done.
| |
| 27 | 29 |
| 28 constexpr uint32_t local_id() const { return local_id_; } | 30 constexpr uint32_t local_id() const { return local_id_; } |
| 29 | 31 |
| 30 constexpr uint64_t nonce() const { return nonce_; } | 32 constexpr uint64_t nonce() const { return nonce_; } |
| 31 | 33 |
| 32 bool operator==(const LocalFrameId& other) const { | 34 bool operator==(const LocalFrameId& other) const { |
| 33 return local_id_ == other.local_id_ && nonce_ == other.nonce_; | 35 return local_id_ == other.local_id_ && nonce_ == other.nonce_; |
| 34 } | 36 } |
| 35 | 37 |
| 36 bool operator!=(const LocalFrameId& other) const { return !(*this == other); } | 38 bool operator!=(const LocalFrameId& other) const { return !(*this == other); } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 52 uint64_t nonce_; | 54 uint64_t nonce_; |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 struct LocalFrameIdHash { | 57 struct LocalFrameIdHash { |
| 56 size_t operator()(const LocalFrameId& key) const { return key.hash(); } | 58 size_t operator()(const LocalFrameId& key) const { return key.hash(); } |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 } // namespace cc | 61 } // namespace cc |
| 60 | 62 |
| 61 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ | 63 #endif // CC_SURFACES_LOCAL_FRAME_ID_H_ |
| OLD | NEW |