Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 ASH_COMMON_CAST_CONFIG_CLIENT_PROXY_H_ | |
| 6 #define ASH_COMMON_CAST_CONFIG_CLIENT_PROXY_H_ | |
| 7 | |
| 8 #include "ash/public/interfaces/cast_config.mojom.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "mojo/public/cpp/bindings/associated_binding.h" | |
| 11 | |
| 12 namespace service_manager { | |
| 13 class Connector; | |
| 14 } | |
| 15 | |
| 16 namespace ash { | |
| 17 | |
| 18 // We want to establish our connection lazily and preferably only once, as | |
| 19 // TrayCast instances will come and go. | |
| 20 class CastConfigClientProxy : public ash::mojom::CastConfigClient { | |
| 21 public: | |
| 22 CastConfigClientProxy(service_manager::Connector* connector); | |
|
James Cook
2016/11/30 22:16:38
explicit
| |
| 23 ~CastConfigClientProxy() override; | |
| 24 | |
| 25 // Binds an AssociatedBinding to the associated group of our pipe, and passes | |
| 26 // the result to AddObserver(). | |
| 27 void AddObserverBinding( | |
| 28 mojo::AssociatedBinding<mojom::CastConfigObserver>* observer_binding); | |
| 29 | |
| 30 // Returns whether we can connect to the remote client. This is used to | |
| 31 // ensure that UI elements are hidden when no connection to the remote | |
| 32 // client is possible. | |
| 33 bool CanConnect(); | |
| 34 | |
| 35 // ash::mojom::CastConfigClient: | |
| 36 void RequestDeviceRefresh() override; | |
| 37 void CastToSink(mojom::CastSinkPtr sink) override; | |
| 38 void StopCasting(mojom::CastRoutePtr route) override; | |
| 39 void AddObserver( | |
| 40 mojom::CastConfigObserverAssociatedPtrInfo observer) override; | |
| 41 | |
| 42 private: | |
| 43 // Ensures that we have a valid |client_| before we try to use it. | |
| 44 bool ConnectToClient(); | |
| 45 | |
| 46 // Clears |client_| when |client_| has a connection error. | |
| 47 void OnClientConnectionError(); | |
| 48 | |
| 49 service_manager::Connector* connector_; | |
| 50 mojom::CastConfigClientPtr client_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(CastConfigClientProxy); | |
| 53 }; | |
| 54 | |
| 55 } // namespace ash | |
| 56 | |
| 57 #endif // ASH_COMMON_CAST_CONFIG_CLIENT_PROXY_H_ | |
| OLD | NEW |