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

Unified Diff: ash/common/cast_config_controller.h

Issue 2525563003: mash: Change CastConfigDelegate to a mojoified CastConfigClient. (Closed)
Patch Set: Add more RunAllPendingInMessageLoop to the tray tests. Created 4 years 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: ash/common/cast_config_controller.h
diff --git a/ash/common/cast_config_controller.h b/ash/common/cast_config_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..4e99a34c0b0eca144bf714d6a50d40acc1296d72
--- /dev/null
+++ b/ash/common/cast_config_controller.h
@@ -0,0 +1,74 @@
+// Copyright 2016 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 ASH_COMMON_CAST_CONFIG_CONTROLLER_H_
+#define ASH_COMMON_CAST_CONFIG_CONTROLLER_H_
+
+#include <vector>
+
+#include "ash/public/interfaces/cast_config.mojom.h"
+#include "base/macros.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+
+namespace ash {
+
+// There is a single CastConfigController which receives device
+// information. This observer interface send that information to all the
James Cook 2016/12/02 04:15:52 nit: sends
Elliot Glaysher 2016/12/02 19:23:11 Done.
+// TrayCast items--there is one per display.
James Cook 2016/12/02 04:15:52 Thanks for documenting the one-per-display thing.
+class CastConfigControllerObserver {
+ public:
+ CastConfigControllerObserver() {}
James Cook 2016/12/02 04:15:52 We don't usually provide constructor implementatio
Elliot Glaysher 2016/12/02 19:23:11 Removing the DISALLOW... fixed this.
+ virtual ~CastConfigControllerObserver() {}
James Cook 2016/12/02 04:15:52 protected?
Elliot Glaysher 2016/12/02 19:23:11 Done.
+
+ virtual void OnDevicesUpdated(
+ std::vector<mojom::SinkAndRoutePtr> devices) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CastConfigControllerObserver);
James Cook 2016/12/02 04:15:52 not needed since it's pure virtual
Elliot Glaysher 2016/12/02 19:23:11 Done.
+};
+
+// We want to establish our connection lazily and preferably only once, as
+// TrayCast instances will come and go.
+class CastConfigController : public ash::mojom::CastConfig,
+ public ash::mojom::CastConfigClient {
+ public:
+ CastConfigController();
+ ~CastConfigController() override;
+
+ // Returns whether our SetClient() method has been called and the client
+ // object pointer is still live.
+ bool Connected();
+
+ void AddObserver(CastConfigControllerObserver* observer);
+ void RemoveObserver(CastConfigControllerObserver* observer);
+
+ void BindRequest(mojom::CastConfigRequest request);
+
+ // ash::mojom::CastConfig:
+ void SetClient(mojom::CastConfigClientAssociatedPtrInfo client) override;
+ void OnDevicesUpdated(std::vector<mojom::SinkAndRoutePtr> devices) override;
+
+ // ash::mojom::CastConfigClient:
+ void RequestDeviceRefresh() override;
+ void CastToSink(mojom::CastSinkPtr sink) override;
+ void StopCasting(mojom::CastRoutePtr route) override;
+
+ private:
+ // Clears |client_| when |client_| has a connection error.
+ void OnClientConnectionError();
+
+ // Bindings for the CastConfig interface.
+ mojo::BindingSet<mojom::CastConfig> bindings_;
+
+ mojom::CastConfigClientAssociatedPtr client_;
+
+ base::ObserverList<CastConfigControllerObserver> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(CastConfigController);
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_CAST_CONFIG_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698