Collin Baker | 3a93342 | 2019-05-29 22:41:35 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 5 | #include "components/tab_groups/tab_group_id.h" |
| 6 | |
| 7 | namespace tab_groups { |
Collin Baker | 3a93342 | 2019-05-29 22:41:35 | [diff] [blame] | 8 | |
| 9 | // static |
| 10 | TabGroupId TabGroupId::GenerateNew() { |
| 11 | return TabGroupId(base::Token::CreateRandom()); |
| 12 | } |
| 13 | |
Collin Baker | 81999fd | 2019-06-05 23:12:27 | [diff] [blame] | 14 | // static |
| 15 | TabGroupId TabGroupId::FromRawToken(base::Token token) { |
| 16 | return TabGroupId(token); |
| 17 | } |
| 18 | |
Connie Wan | 0cfb9adb | 2020-09-17 19:54:18 | [diff] [blame] | 19 | // static |
| 20 | TabGroupId TabGroupId::CreateEmpty() { |
| 21 | return TabGroupId(base::Token()); |
| 22 | } |
| 23 | |
Collin Baker | 3a93342 | 2019-05-29 22:41:35 | [diff] [blame] | 24 | TabGroupId::TabGroupId(const TabGroupId& other) = default; |
| 25 | |
| 26 | TabGroupId& TabGroupId::operator=(const TabGroupId& other) = default; |
| 27 | |
| 28 | bool TabGroupId::operator==(const TabGroupId& other) const { |
| 29 | return token_ == other.token_; |
| 30 | } |
| 31 | |
| 32 | bool TabGroupId::operator!=(const TabGroupId& other) const { |
| 33 | return !(*this == other); |
| 34 | } |
| 35 | |
| 36 | bool TabGroupId::operator<(const TabGroupId& other) const { |
| 37 | return token_ < other.token_; |
| 38 | } |
| 39 | |
| 40 | std::string TabGroupId::ToString() const { |
| 41 | return token_.ToString(); |
| 42 | } |
| 43 | |
| 44 | TabGroupId::TabGroupId(base::Token token) : token_(token) {} |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 45 | |
| 46 | } // namespace tab_groups |