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

Unified Diff: ash/common/cast_config_client_proxy.h

Issue 2525563003: mash: Change CastConfigDelegate to a mojoified CastConfigClient. (Closed)
Patch Set: Now for the external apitests as well. 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_client_proxy.h
diff --git a/ash/common/cast_config_client_proxy.h b/ash/common/cast_config_client_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..14cf7c43df8bb9eb587249cf2dcb8794081aab5a
--- /dev/null
+++ b/ash/common/cast_config_client_proxy.h
@@ -0,0 +1,57 @@
+// 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_CLIENT_PROXY_H_
+#define ASH_COMMON_CAST_CONFIG_CLIENT_PROXY_H_
+
+#include "ash/public/interfaces/cast_config.mojom.h"
+#include "base/macros.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
+
+namespace service_manager {
+class Connector;
+}
+
+namespace ash {
+
+// We want to establish our connection lazily and preferably only once, as
+// TrayCast instances will come and go.
+class CastConfigClientProxy : public ash::mojom::CastConfigClient {
+ public:
+ CastConfigClientProxy(service_manager::Connector* connector);
James Cook 2016/11/30 22:16:38 explicit
+ ~CastConfigClientProxy() override;
+
+ // Binds an AssociatedBinding to the associated group of our pipe, and passes
+ // the result to AddObserver().
+ void AddObserverBinding(
+ mojo::AssociatedBinding<mojom::CastConfigObserver>* observer_binding);
+
+ // Returns whether we can connect to the remote client. This is used to
+ // ensure that UI elements are hidden when no connection to the remote
+ // client is possible.
+ bool CanConnect();
+
+ // ash::mojom::CastConfigClient:
+ void RequestDeviceRefresh() override;
+ void CastToSink(mojom::CastSinkPtr sink) override;
+ void StopCasting(mojom::CastRoutePtr route) override;
+ void AddObserver(
+ mojom::CastConfigObserverAssociatedPtrInfo observer) override;
+
+ private:
+ // Ensures that we have a valid |client_| before we try to use it.
+ bool ConnectToClient();
+
+ // Clears |client_| when |client_| has a connection error.
+ void OnClientConnectionError();
+
+ service_manager::Connector* connector_;
+ mojom::CastConfigClientPtr client_;
+
+ DISALLOW_COPY_AND_ASSIGN(CastConfigClientProxy);
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_CAST_CONFIG_CLIENT_PROXY_H_

Powered by Google App Engine
This is Rietveld 408576698