blob: 48037ff9c180f9878f8bfd8df33c621cae70bcf1 [file] [log] [blame]
Collin Baker3a933422019-05-29 22:41:351// 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 Wan866179b2019-12-18 21:39:335#include "components/tab_groups/tab_group_id.h"
6
7namespace tab_groups {
Collin Baker3a933422019-05-29 22:41:358
9// static
10TabGroupId TabGroupId::GenerateNew() {
11 return TabGroupId(base::Token::CreateRandom());
12}
13
Collin Baker81999fd2019-06-05 23:12:2714// static
15TabGroupId TabGroupId::FromRawToken(base::Token token) {
16 return TabGroupId(token);
17}
18
Connie Wan0cfb9adb2020-09-17 19:54:1819// static
20TabGroupId TabGroupId::CreateEmpty() {
21 return TabGroupId(base::Token());
22}
23
Collin Baker3a933422019-05-29 22:41:3524TabGroupId::TabGroupId(const TabGroupId& other) = default;
25
26TabGroupId& TabGroupId::operator=(const TabGroupId& other) = default;
27
28bool TabGroupId::operator==(const TabGroupId& other) const {
29 return token_ == other.token_;
30}
31
32bool TabGroupId::operator!=(const TabGroupId& other) const {
33 return !(*this == other);
34}
35
36bool TabGroupId::operator<(const TabGroupId& other) const {
37 return token_ < other.token_;
38}
39
40std::string TabGroupId::ToString() const {
41 return token_.ToString();
42}
43
44TabGroupId::TabGroupId(base::Token token) : token_(token) {}
Connie Wan866179b2019-12-18 21:39:3345
46} // namespace tab_groups