media_routes_observer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015 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_MEDIA_ROUTER_BROWSER_MEDIA_ROUTES_OBSERVER_H_
  5. #define COMPONENTS_MEDIA_ROUTER_BROWSER_MEDIA_ROUTES_OBSERVER_H_
  6. #include <vector>
  7. #include "base/memory/raw_ptr.h"
  8. #include "components/media_router/common/media_route.h"
  9. namespace media_router {
  10. class MediaRouter;
  11. // Base class for observing when the set of MediaRoutes and their associated
  12. // MediaSinks have been updated. When an object is instantiated with a
  13. // |source_id|, the observer expects that |routes| reported by
  14. // |OnRoutesUpdated| that match the route IDs contained in the
  15. // |joinable_route_ids| can be connected joined by the source. If no
  16. // |source_id| is supplied, then the idea of joinable routes no longer applies.
  17. class MediaRoutesObserver {
  18. public:
  19. explicit MediaRoutesObserver(MediaRouter* router);
  20. MediaRoutesObserver(const MediaRoutesObserver&) = delete;
  21. MediaRoutesObserver& operator=(const MediaRoutesObserver&) = delete;
  22. virtual ~MediaRoutesObserver();
  23. // Invoked when the list of routes and their associated sinks have been
  24. // updated.
  25. //
  26. // Implementations may not perform operations that modify the Media Router's
  27. // observer list. In particular, invoking this observer's destructor within
  28. // OnRoutesUpdated will result in undefined behavior.
  29. virtual void OnRoutesUpdated(const std::vector<MediaRoute>& routes) {}
  30. MediaRouter* router() const { return router_; }
  31. private:
  32. const raw_ptr<MediaRouter> router_;
  33. };
  34. } // namespace media_router
  35. #endif // COMPONENTS_MEDIA_ROUTER_BROWSER_MEDIA_ROUTES_OBSERVER_H_