tab_group_id.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef COMPONENTS_TAB_GROUPS_TAB_GROUP_ID_H_
  5. #define COMPONENTS_TAB_GROUPS_TAB_GROUP_ID_H_
  6. #include "base/component_export.h"
  7. #include "base/token.h"
  8. namespace tab_groups {
  9. class COMPONENT_EXPORT(TAB_GROUPS) TabGroupId {
  10. public:
  11. static TabGroupId GenerateNew();
  12. // This should only called with |token| returned from a previous |token()|
  13. // call on a valid TabGroupId.
  14. static TabGroupId FromRawToken(base::Token token);
  15. // Should only be used if intending to populate the TabGroupId by reference,
  16. // using a valid existing ID. Primarily needed for the Tab Groups extensions
  17. // API.
  18. static TabGroupId CreateEmpty();
  19. TabGroupId(const TabGroupId& other);
  20. TabGroupId& operator=(const TabGroupId& other);
  21. bool operator==(const TabGroupId& other) const;
  22. bool operator!=(const TabGroupId& other) const;
  23. bool operator<(const TabGroupId& other) const;
  24. const base::Token& token() const { return token_; }
  25. bool is_empty() { return token_.is_zero(); }
  26. std::string ToString() const;
  27. private:
  28. explicit TabGroupId(base::Token token);
  29. base::Token token_;
  30. };
  31. } // namespace tab_groups
  32. #endif // COMPONENTS_TAB_GROUPS_TAB_GROUP_ID_H_