| 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_CONTROLLER_H_ |
| 6 #define ASH_COMMON_CAST_CONFIG_CONTROLLER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "ash/public/interfaces/cast_config.mojom.h" |
| 11 #include "base/macros.h" |
| 12 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 13 #include "mojo/public/cpp/bindings/binding_set.h" |
| 14 |
| 15 namespace ash { |
| 16 |
| 17 // There is a single CastConfigController which receives device |
| 18 // information. This observer interface sends that information to all the |
| 19 // TrayCast items--there is one per display. |
| 20 class CastConfigControllerObserver { |
| 21 public: |
| 22 virtual void OnDevicesUpdated( |
| 23 std::vector<mojom::SinkAndRoutePtr> devices) = 0; |
| 24 |
| 25 protected: |
| 26 virtual ~CastConfigControllerObserver() {} |
| 27 }; |
| 28 |
| 29 // We want to establish our connection lazily and preferably only once, as |
| 30 // TrayCast instances will come and go. |
| 31 class CastConfigController : public ash::mojom::CastConfig, |
| 32 public ash::mojom::CastConfigClient { |
| 33 public: |
| 34 CastConfigController(); |
| 35 ~CastConfigController() override; |
| 36 |
| 37 // Returns whether our SetClient() method has been called and the client |
| 38 // object pointer is still live. |
| 39 bool Connected(); |
| 40 |
| 41 void AddObserver(CastConfigControllerObserver* observer); |
| 42 void RemoveObserver(CastConfigControllerObserver* observer); |
| 43 |
| 44 void BindRequest(mojom::CastConfigRequest request); |
| 45 |
| 46 // ash::mojom::CastConfig: |
| 47 void SetClient(mojom::CastConfigClientAssociatedPtrInfo client) override; |
| 48 void OnDevicesUpdated(std::vector<mojom::SinkAndRoutePtr> devices) override; |
| 49 |
| 50 // ash::mojom::CastConfigClient: |
| 51 void RequestDeviceRefresh() override; |
| 52 void CastToSink(mojom::CastSinkPtr sink) override; |
| 53 void StopCasting(mojom::CastRoutePtr route) override; |
| 54 |
| 55 private: |
| 56 // Bindings for the CastConfig interface. |
| 57 mojo::BindingSet<mojom::CastConfig> bindings_; |
| 58 |
| 59 mojom::CastConfigClientAssociatedPtr client_; |
| 60 |
| 61 base::ObserverList<CastConfigControllerObserver> observers_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(CastConfigController); |
| 64 }; |
| 65 |
| 66 } // namespace ash |
| 67 |
| 68 #endif // ASH_COMMON_CAST_CONFIG_CONTROLLER_H_ |
| OLD | NEW |