tab_group_id.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include "components/tab_groups/tab_group_id.h"
  5. namespace tab_groups {
  6. // static
  7. TabGroupId TabGroupId::GenerateNew() {
  8. return TabGroupId(base::Token::CreateRandom());
  9. }
  10. // static
  11. TabGroupId TabGroupId::FromRawToken(base::Token token) {
  12. return TabGroupId(token);
  13. }
  14. // static
  15. TabGroupId TabGroupId::CreateEmpty() {
  16. return TabGroupId(base::Token());
  17. }
  18. TabGroupId::TabGroupId(const TabGroupId& other) = default;
  19. TabGroupId& TabGroupId::operator=(const TabGroupId& other) = default;
  20. bool TabGroupId::operator==(const TabGroupId& other) const {
  21. return token_ == other.token_;
  22. }
  23. bool TabGroupId::operator!=(const TabGroupId& other) const {
  24. return !(*this == other);
  25. }
  26. bool TabGroupId::operator<(const TabGroupId& other) const {
  27. return token_ < other.token_;
  28. }
  29. std::string TabGroupId::ToString() const {
  30. return token_.ToString();
  31. }
  32. TabGroupId::TabGroupId(base::Token token) : token_(token) {}
  33. } // namespace tab_groups