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

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

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
« no previous file with comments | « ash/common/cast_config_controller.h ('k') | ash/common/cast_config_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ash/common/cast_config_controller.h"
6
7 #include <utility>
8 #include <vector>
9
10 #include "base/logging.h"
11 #include "content/public/common/service_names.mojom.h"
12 #include "services/service_manager/public/cpp/connector.h"
13
14 namespace ash {
15
16 CastConfigController::CastConfigController() {}
17
18 CastConfigController::~CastConfigController() {}
19
20 bool CastConfigController::Connected() {
21 return client_.is_bound();
22 }
23
24 void CastConfigController::AddObserver(CastConfigControllerObserver* observer) {
25 observers_.AddObserver(observer);
26 }
27
28 void CastConfigController::RemoveObserver(
29 CastConfigControllerObserver* observer) {
30 observers_.RemoveObserver(observer);
31 }
32
33 void CastConfigController::BindRequest(mojom::CastConfigRequest request) {
34 bindings_.AddBinding(this, std::move(request));
35 }
36
37 void CastConfigController::SetClient(
38 mojom::CastConfigClientAssociatedPtrInfo client) {
39 client_.Bind(std::move(client));
40
41 // If we added observers before we were connected to, run them now.
42 if (observers_.might_have_observers())
43 client_->RequestDeviceRefresh();
44 }
45
46 void CastConfigController::OnDevicesUpdated(
47 std::vector<mojom::SinkAndRoutePtr> devices) {
48 for (auto& observer : observers_) {
49 std::vector<mojom::SinkAndRoutePtr> devices_copy;
50 for (auto& item : devices)
51 devices_copy.push_back(item.Clone());
52 observer.OnDevicesUpdated(std::move(devices_copy));
53 }
54 }
55
56 void CastConfigController::RequestDeviceRefresh() {
57 if (client_)
58 client_->RequestDeviceRefresh();
59 }
60
61 void CastConfigController::CastToSink(ash::mojom::CastSinkPtr sink) {
62 if (client_)
63 client_->CastToSink(std::move(sink));
64 }
65
66 void CastConfigController::StopCasting(ash::mojom::CastRoutePtr route) {
67 if (client_)
68 client_->StopCasting(std::move(route));
69 }
70
71 void CastConfigController::OnClientConnectionError() {
James Cook 2016/12/02 20:35:20 Is this still used?
72 client_.reset();
73 }
74
75 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/cast_config_controller.h ('k') | ash/common/cast_config_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698