browser_tabs_metadata_fetcher.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 ASH_COMPONENTS_PHONEHUB_BROWSER_TABS_METADATA_FETCHER_H_
  5. #define ASH_COMPONENTS_PHONEHUB_BROWSER_TABS_METADATA_FETCHER_H_
  6. #include <vector>
  7. #include "ash/components/phonehub/browser_tabs_model.h"
  8. #include "base/callback.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. namespace sync_sessions {
  11. struct SyncedSession;
  12. } // namespace sync_sessions
  13. namespace ash {
  14. namespace phonehub {
  15. // Used to collect the most recently visited tab metadata from a
  16. // sync_sessions::SyncedSession, fetch their respective favicon images, and
  17. // return a list of BrowserTabMetadata to its caller.
  18. class BrowserTabsMetadataFetcher {
  19. public:
  20. virtual ~BrowserTabsMetadataFetcher() = default;
  21. BrowserTabsMetadataFetcher(const BrowserTabsMetadataFetcher&) = delete;
  22. BrowserTabsMetadataFetcher& operator=(const BrowserTabsMetadataFetcher&) =
  23. delete;
  24. using BrowserTabsMetadataResponse =
  25. absl::optional<std::vector<BrowserTabsModel::BrowserTabMetadata>>;
  26. // Fetches the metadata of the most recently visited tabs. Only one fetch is
  27. // possible at a given time, and if a new fetch is started when another is
  28. // already in progress, the previous fetch will be passed a absl::nullopt.
  29. virtual void Fetch(
  30. const sync_sessions::SyncedSession* session,
  31. base::OnceCallback<void(BrowserTabsMetadataResponse)> callback) = 0;
  32. protected:
  33. BrowserTabsMetadataFetcher() = default;
  34. };
  35. } // namespace phonehub
  36. } // namespace ash
  37. #endif // ASH_COMPONENTS_PHONEHUB_BROWSER_TABS_METADATA_FETCHER_H_