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_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 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.
| |
| 19 // TrayCast items--there is one per display. | |
|
James Cook
2016/12/02 04:15:52
Thanks for documenting the one-per-display thing.
| |
| 20 class CastConfigControllerObserver { | |
| 21 public: | |
| 22 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.
| |
| 23 virtual ~CastConfigControllerObserver() {} | |
|
James Cook
2016/12/02 04:15:52
protected?
Elliot Glaysher
2016/12/02 19:23:11
Done.
| |
| 24 | |
| 25 virtual void OnDevicesUpdated( | |
| 26 std::vector<mojom::SinkAndRoutePtr> devices) = 0; | |
| 27 | |
| 28 private: | |
| 29 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.
| |
| 30 }; | |
| 31 | |
| 32 // We want to establish our connection lazily and preferably only once, as | |
| 33 // TrayCast instances will come and go. | |
| 34 class CastConfigController : public ash::mojom::CastConfig, | |
| 35 public ash::mojom::CastConfigClient { | |
| 36 public: | |
| 37 CastConfigController(); | |
| 38 ~CastConfigController() override; | |
| 39 | |
| 40 // Returns whether our SetClient() method has been called and the client | |
| 41 // object pointer is still live. | |
| 42 bool Connected(); | |
| 43 | |
| 44 void AddObserver(CastConfigControllerObserver* observer); | |
| 45 void RemoveObserver(CastConfigControllerObserver* observer); | |
| 46 | |
| 47 void BindRequest(mojom::CastConfigRequest request); | |
| 48 | |
| 49 // ash::mojom::CastConfig: | |
| 50 void SetClient(mojom::CastConfigClientAssociatedPtrInfo client) override; | |
| 51 void OnDevicesUpdated(std::vector<mojom::SinkAndRoutePtr> devices) override; | |
| 52 | |
| 53 // ash::mojom::CastConfigClient: | |
| 54 void RequestDeviceRefresh() override; | |
| 55 void CastToSink(mojom::CastSinkPtr sink) override; | |
| 56 void StopCasting(mojom::CastRoutePtr route) override; | |
| 57 | |
| 58 private: | |
| 59 // Clears |client_| when |client_| has a connection error. | |
| 60 void OnClientConnectionError(); | |
| 61 | |
| 62 // Bindings for the CastConfig interface. | |
| 63 mojo::BindingSet<mojom::CastConfig> bindings_; | |
| 64 | |
| 65 mojom::CastConfigClientAssociatedPtr client_; | |
| 66 | |
| 67 base::ObserverList<CastConfigControllerObserver> observers_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(CastConfigController); | |
| 70 }; | |
| 71 | |
| 72 } // namespace ash | |
| 73 | |
| 74 #endif // ASH_COMMON_CAST_CONFIG_CONTROLLER_H_ | |
| OLD | NEW |