tile_group.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2020 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_QUERY_TILES_INTERNAL_TILE_GROUP_H_
  5. #define COMPONENTS_QUERY_TILES_INTERNAL_TILE_GROUP_H_
  6. #include <map>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. #include "base/time/time.h"
  11. #include "components/query_tiles/tile.h"
  12. namespace query_tiles {
  13. // A group of query tiles and metadata.
  14. struct TileGroup {
  15. TileGroup();
  16. TileGroup(const TileGroup& other);
  17. TileGroup(TileGroup&& other);
  18. ~TileGroup();
  19. TileGroup& operator=(const TileGroup& other);
  20. TileGroup& operator=(TileGroup&& other);
  21. bool operator==(const TileGroup& other) const;
  22. bool operator!=(const TileGroup& other) const;
  23. // Called when a tile was clicked, need to recalculate |tile_stats|.
  24. void OnTileClicked(const std::string& tile_id);
  25. // Remove a tile from |tiles| given by its ID.
  26. void RemoveTiles(const std::vector<std::string>& tile_ids);
  27. // Find a tile with the given ID;
  28. Tile* FindTile(const std::string& tile_id);
  29. // Unique id for the group.
  30. std::string id;
  31. // Locale setting of this group.
  32. std::string locale;
  33. // Last updated timestamp in milliseconds.
  34. base::Time last_updated_ts;
  35. // Top level tiles.
  36. std::vector<std::unique_ptr<Tile>> tiles;
  37. // Map from tile id to its stats.
  38. std::map<std::string, TileStats> tile_stats;
  39. // Print pretty formatted content in TileGroup struct.
  40. std::string DebugString();
  41. };
  42. } // namespace query_tiles
  43. #endif // COMPONENTS_QUERY_TILES_INTERNAL_TILE_GROUP_H_