Chromium Code Reviews| Index: chrome/browser/media/router/mojo/media_route_controller.h |
| diff --git a/chrome/browser/media/router/mojo/media_route_controller.h b/chrome/browser/media/router/mojo/media_route_controller.h |
| index 81812e9918c592b7fd6cb81bf106366b92ac9d04..18668f716d402f345bbe43ce4ac95a9a663935d6 100644 |
| --- a/chrome/browser/media/router/mojo/media_route_controller.h |
| +++ b/chrome/browser/media/router/mojo/media_route_controller.h |
| @@ -15,6 +15,8 @@ |
| namespace media_router { |
| +class MediaRouter; |
| + |
| // A controller for a MediaRoute. Forwards commands for controlling the route to |
| // an out-of-process controller. Notifies its observers whenever there is a |
| // change in the route's MediaStatus. |
| @@ -65,13 +67,12 @@ class MediaRouteController : public mojom::MediaStatusObserver, |
| DISALLOW_COPY_AND_ASSIGN(Observer); |
| }; |
| - // Constructs a MediaRouteController that forwards media commands to |
| - // |media_controller|. |media_controller| must be bound to a message pipe. |
| + // |media_router| will be notified when the MediaRouteController is destroyed. |
| MediaRouteController(const MediaRoute::Id& route_id, |
| - mojom::MediaControllerPtr media_controller); |
| + MediaRouter* media_router); |
| // Media controller methods for forwarding commands to a |
| - // mojom::MediaControllerPtr held in |media_controller_|. |
| + // mojom::MediaControllerPtr held in |mojo_media_controller_|. |
| void Play(); |
| void Pause(); |
| void Seek(base::TimeDelta time); |
| @@ -82,11 +83,25 @@ class MediaRouteController : public mojom::MediaStatusObserver, |
| // Notifies |observers_| of a status update. |
| void OnMediaStatusUpdated(const MediaStatus& status) override; |
| - // Called when the connection between |this| and |media_controller_| is no |
| - // longer valid. Notifies |observers_| to dispose their references to |this|. |
| - // |this| gets destroyed when all the references are disposed. |
| + // Called when the connection between |this| and |mojo_media_controller_| is |
| + // no longer valid. Notifies |media_router_| and |observers_| to dispose their |
| + // references to |this|. |this| gets destroyed when all the references are |
| + // disposed. |
| void Invalidate(); |
| + // Called when the media route that |this| controls is invalidated. Notifies |
| + // |observers_| (but not |media_router_| to dispose their references to |
| + // |this|. |this| gets destroyed when all the references are disposed. |
| + void OnRouteInvalid(); |
| + |
| + // Returns a mojo pointer bound to |this| by |binding_|. This must only be |
| + // called at most once in the lifetime of |this|. |
|
imcheng
2017/04/06 21:14:04
Did you mean to revert the "must only be called on
takumif
2017/04/12 23:11:36
No, putting it back.
|
| + mojom::MediaStatusObserverPtr BindObserverPtr(); |
| + |
| + // Gets a Mojo request bound to |mojo_media_controller_|. This must only be |
| + // called at most once in the lifetime of |this|. |
| + mojom::MediaControllerRequest GetMediaControllerRequest(); |
| + |
| MediaRoute::Id route_id() const { return route_id_; } |
| private: |
| @@ -101,12 +116,21 @@ class MediaRouteController : public mojom::MediaStatusObserver, |
| const MediaRoute::Id route_id_; |
| // Handle to the mojom::MediaController that receives media commands. |
| - mojom::MediaControllerPtr media_controller_; |
| + mojom::MediaControllerPtr mojo_media_controller_; |
| + |
| + // |media_router_| will be notified when |this| is destroyed. |
| + MediaRouter* const media_router_; |
| + |
| + // The binding to observe the out-of-process provider of status updates. |
| + mojo::Binding<mojom::MediaStatusObserver> binding_; |
| // Observers that |this| notifies of status updates. The observers share the |
| // ownership of |this| through scoped_refptr. |
| base::ObserverList<Observer> observers_; |
| + // This becomes false when |this| is invalidated. |
| + bool is_valid_ = true; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MediaRouteController); |
| }; |