route_message_observer.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2016 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_ROUTE_MESSAGE_OBSERVER_H_
  5. #define COMPONENTS_MEDIA_ROUTER_BROWSER_ROUTE_MESSAGE_OBSERVER_H_
  6. #include <stdint.h>
  7. #include <vector>
  8. #include "base/memory/raw_ptr.h"
  9. #include "components/media_router/common/media_route.h"
  10. #include "components/media_router/common/mojom/media_router.mojom.h"
  11. namespace media_router {
  12. class MediaRouter;
  13. // Observes messages originating from the MediaSink connected to a MediaRoute.
  14. // Messages are received from MediaRouter via |OnMessagesReceived|.
  15. // TODO(imcheng): Rename to PresentationConnectionMessageObserver.
  16. class RouteMessageObserver {
  17. public:
  18. // |route_id|: ID of MediaRoute to listen for messages.
  19. RouteMessageObserver(MediaRouter* router, const MediaRoute::Id& route_id);
  20. RouteMessageObserver(const RouteMessageObserver&) = delete;
  21. RouteMessageObserver& operator=(const RouteMessageObserver&) = delete;
  22. virtual ~RouteMessageObserver();
  23. // Invoked by |router_| whenever messages are received from the route sink.
  24. // |messages| is guaranteed to be non-empty.
  25. virtual void OnMessagesReceived(
  26. std::vector<mojom::RouteMessagePtr> messages) = 0;
  27. const MediaRoute::Id& route_id() const { return route_id_; }
  28. private:
  29. const raw_ptr<MediaRouter> router_;
  30. const MediaRoute::Id route_id_;
  31. };
  32. } // namespace media_router
  33. #endif // COMPONENTS_MEDIA_ROUTER_BROWSER_ROUTE_MESSAGE_OBSERVER_H_