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

Side by Side Diff: ash/common/cast_config_controller.h

Issue 2525563003: mash: Change CastConfigDelegate to a mojoified CastConfigClient. (Closed)
Patch Set: jamescook comments 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 unified diff | Download patch
OLDNEW
(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 // Clears |client_| when |client_| has a connection error.
57 void OnClientConnectionError();
58
59 // Bindings for the CastConfig interface.
60 mojo::BindingSet<mojom::CastConfig> bindings_;
61
62 mojom::CastConfigClientAssociatedPtr client_;
63
64 base::ObserverList<CastConfigControllerObserver> observers_;
65
66 DISALLOW_COPY_AND_ASSIGN(CastConfigController);
67 };
68
69 } // namespace ash
70
71 #endif // ASH_COMMON_CAST_CONFIG_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698