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..27acba50dc3087dad537513f04c4c5b099997b33 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. |
| @@ -67,8 +69,10 @@ class MediaRouteController : public mojom::MediaStatusObserver, |
| // 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); |
| + mojom::MediaControllerPtr media_controller, |
| + MediaRouter* media_router); |
| // Media controller methods for forwarding commands to a |
| // mojom::MediaControllerPtr held in |media_controller_|. |
| @@ -83,10 +87,15 @@ class MediaRouteController : public mojom::MediaStatusObserver, |
| 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. |
| + // longer valid. Notifies |media_router_| and |observers_| to dispose their |
| + // references to |this|. |this| gets destroyed when all the references are |
| + // disposed. |
| void Invalidate(); |
| + // Returns a mojo pointer bound to |this| by |binding_|. If |binding_| is |
| + // already set, then the previous binding gets invalidated. |
|
mark a. foltz
2017/03/30 23:03:28
When would this binding need to be reset? My unde
imcheng
2017/03/31 01:30:24
I think we should add a DCHECK(!binding_.is_bound(
takumif
2017/04/04 03:19:50
Done.
takumif
2017/04/04 03:19:50
This shouldn't be reset. Changing the comment.
|
| + mojom::MediaStatusObserverPtr BindObserverPtr(); |
| + |
| MediaRoute::Id route_id() const { return route_id_; } |
| private: |
| @@ -103,10 +112,19 @@ class MediaRouteController : public mojom::MediaStatusObserver, |
| // Handle to the mojom::MediaController that receives media commands. |
| mojom::MediaControllerPtr 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); |
| }; |