Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 | |
| 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <unordered_set> | |
| 10 | |
| 11 #include "chrome/browser/media/router/media_route.h" | |
| 12 #include "chrome/browser/media/router/media_status.h" | |
| 13 #include "chrome/browser/media/router/mojo/media_controller.mojom.h" | |
| 14 #include "mojo/public/cpp/bindings/binding.h" | |
| 15 | |
| 16 namespace media_router { | |
| 17 | |
| 18 namespace mojom { | |
| 19 class MediaRouteProvider; | |
| 20 } | |
| 21 | |
| 22 class MediaRouteStatusObserver; | |
| 23 | |
| 24 // A controller for a MediaRoute. Forwards commands for controlling the route to | |
|
mark a. foltz
2017/03/06 20:06:19
This only controls media routes that are owned out
imcheng
2017/03/06 23:11:41
I think MediaRouteController is fine. The only par
takumif
2017/03/08 04:24:03
We can move the initialization to MRMojoImpl, and
mark a. foltz
2017/03/08 22:16:12
If the responsibility of the class is to implement
takumif
2017/03/09 19:45:30
I'm not sure if there is a need for this class to
| |
| 25 // the component-extension-side controller. Notifies its observers whenever | |
| 26 // there is a change in the route's MediaStatus. Gets destroyed when its | |
| 27 // connection to the extension-side controller is invalidated, the route is | |
|
mark a. foltz
2017/03/06 20:06:19
Will this prevent the controller from persisting a
imcheng
2017/03/06 23:11:41
The event page does not suspend when there is at l
| |
| 28 // terminated, or the last observer of |this| is removed. | |
|
mark a. foltz
2017/03/06 20:06:19
I still find the lifetime dependency between the c
imcheng
2017/03/06 23:11:41
This is a bit tricky because the controller can be
takumif
2017/03/08 04:24:02
The current design is that the event page is awake
mark a. foltz
2017/03/08 22:16:12
Okay, whichever design is settled upon, please upd
takumif
2017/03/09 19:45:30
Would it be better if we made the step to call the
mark a. foltz
2017/03/13 18:22:31
The API I was thinking of would always destroy the
| |
| 29 class MediaRouteController : public mojom::MediaStatusObserver { | |
|
mark a. foltz
2017/03/06 20:06:19
Shouldn't this implement mojo::MediaController?
W
imcheng
2017/03/06 23:11:41
The extension side implements mojo::MediaControlle
takumif
2017/03/08 04:24:02
Given that this only receives commands from within
| |
| 30 public: | |
| 31 // Attempts to establish a mojo connection with the extension-side controller | |
|
mark a. foltz
2017/03/06 20:06:19
s/extension-side controller/Media Route Provider/
takumif
2017/03/08 04:24:03
Removing mentions of extension/MRP.
| |
| 32 // for |route_id|. |destroyer_callback| will be called if it fails. | |
| 33 // |destroyer_callback| must destroy |this|. | |
| 34 MediaRouteController(MediaRoute::Id route_id, | |
| 35 mojom::MediaRouteProvider* provider, | |
|
dcheng
2017/03/08 01:08:20
It's a bit unusual to pass around raw pointers to
takumif
2017/03/08 04:24:02
Removing this in the new patch.
| |
| 36 base::Closure destroyer_callback); | |
| 37 ~MediaRouteController() override; | |
| 38 | |
| 39 // Called when |media_controller_| gets bound. Calls |destroyer_callback_| if | |
| 40 // |success| is false. | |
| 41 void OnControllerSet(bool success); | |
| 42 | |
| 43 // Media controller methods for forwarding commands to the extension-side | |
|
mark a. foltz
2017/03/06 20:06:19
...to the Media Route Provider.
takumif
2017/03/08 04:24:03
Removing mentions of extension/MRP.
| |
| 44 // controller. | |
| 45 void Play(); | |
| 46 void Pause(); | |
| 47 void Seek(uint32_t time); | |
| 48 void SetMute(bool mute); | |
| 49 void SetVolume(float volume); | |
| 50 | |
| 51 void AddObserver(MediaRouteStatusObserver* observer); | |
|
mark a. foltz
2017/03/06 20:06:19
Please document which of the API override/implemen
takumif
2017/03/08 04:24:02
OnMediaStatusUpdated() is the only method.
| |
| 52 // Calls |destroyer_callback_| if the last observer is removed. | |
| 53 void RemoveObserver(MediaRouteStatusObserver* observer); | |
| 54 | |
| 55 // mojom::MediaStatusObserver: | |
| 56 void OnMediaStatusUpdated(const MediaStatus& status) override; | |
| 57 | |
| 58 private: | |
| 59 // Gets called when |this| should no longer exist. Needs to destroy |this|. | |
| 60 base::Closure destroyer_callback_; | |
|
dcheng
2017/03/08 01:08:19
This is pretty unusual. Where's the code that actu
takumif
2017/03/08 04:24:02
This is used by MediaRouterMojoImpl which will own
dcheng
2017/03/17 06:15:14
Unless we need to use a base::Callback for flexibi
takumif
2017/03/20 22:10:45
Okay, passing MediaRouterBase* (superclass of MRMo
| |
| 61 | |
| 62 // The extension-side controller that |this| forwards commands to. | |
|
mark a. foltz
2017/03/06 20:06:19
Media Route Provider
takumif
2017/03/08 04:24:02
Removing mentions of extension/MRP.
| |
| 63 mojom::MediaControllerPtr media_controller_; | |
| 64 | |
| 65 // The binding to observe the extension-side provider of status updates. | |
|
mark a. foltz
2017/03/06 20:06:19
observe status updates from the Media Route Provid
takumif
2017/03/08 04:24:02
Removing mentions of extension/MRP.
| |
| 66 std::unique_ptr<mojo::Binding<mojom::MediaStatusObserver>> binding_; | |
|
dcheng
2017/03/08 01:08:20
unique_ptr is unnecessary here. In the initializer
takumif
2017/03/08 04:24:03
Done.
| |
| 67 | |
| 68 // Observers that |this| notifies of status updates. | |
| 69 std::unordered_set<MediaRouteStatusObserver*> observers_; | |
|
mark a. foltz
2017/03/06 20:06:19
base::ObserverList
takumif
2017/03/08 04:24:03
Done.
| |
| 70 | |
| 71 mojom::MediaRouteProvider* const provider_; | |
|
mark a. foltz
2017/03/06 20:06:19
Who owns this? Please document
takumif
2017/03/08 04:24:02
Removed the reference.
| |
| 72 | |
| 73 // The ID of the Media Route that |this| controls. | |
| 74 const MediaRoute::Id route_id_; | |
| 75 }; | |
| 76 | |
| 77 } // namespace media_router | |
| 78 | |
| 79 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ | |
| OLD | NEW |