Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: chrome/browser/media/router/mojo/media_route_controller.h

Issue 2727123002: [Media Router] Custom Controls 1 - Add MediaStatus, MediaRouteController, and mojo interfaces (Closed)
Patch Set: Address Mark, Devlin, Derek, and Daniel's comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..db0535c40349824d897ca100a3e15464284ea06d
--- /dev/null
+++ b/chrome/browser/media/router/mojo/media_route_controller.h
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_
+#define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_
+
+#include <memory>
+#include <unordered_set>
+
+#include "base/observer_list.h"
+#include "chrome/browser/media/router/media_route.h"
+#include "chrome/browser/media/router/media_status.h"
+#include "chrome/browser/media/router/mojo/media_controller.mojom.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+namespace base {
+class TimeDelta;
+}
+
+namespace media_router {
+
+class MediaRouteStatusObserver;
+
+// 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. Gets destroyed when the route is
+// terminated or the last observer of |this| is removed.
+class MediaRouteController : public mojom::MediaStatusObserver {
mark a. foltz 2017/03/13 18:22:31 What would use this class? I thought that the con
+ public:
+ // |this| will forward media commands to |media_controller|.
+ // |destroyer_callback| will be called when the last observer of |this| is
+ // removed. |destroyer_callback| must destroy |this|.
+ MediaRouteController(mojom::MediaControllerPtr media_controller,
+ base::Closure destroyer_callback);
+ ~MediaRouteController() override;
+
+ // Media controller methods for forwarding commands to |media_controller_|.
+ void Play();
+ void Pause();
+ void Seek(base::TimeDelta time);
+ void SetMute(bool mute);
+ void SetVolume(float volume);
+
+ void AddObserver(MediaRouteStatusObserver* observer);
+ // Calls |destroyer_callback_| if the last observer is removed.
+ void RemoveObserver(MediaRouteStatusObserver* observer);
+
+ // mojom::MediaStatusObserver:
+ void OnMediaStatusUpdated(const MediaStatus& status) override;
+
+ // Returns a mojo pointer bound to |this| by |binding_|. If |binding_| is
+ // already set, then the previous binding gets invalidated.
+ mojom::MediaStatusObserverPtr GetObserverPtr();
+
+ private:
+ // Gets called when |this| should no longer exist. Needs to destroy |this|.
+ base::Closure destroyer_callback_;
+
+ // The out-of-process controller that |this| forwards commands to.
+ mojom::MediaControllerPtr media_controller_;
+
+ // The binding to observe the out-of-process provider of status updates.
+ mojo::Binding<mojom::MediaStatusObserver> binding_;
+
+ // Observers that |this| notifies of status updates.
+ base::ObserverList<MediaRouteStatusObserver> observers_;
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698