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

Side by Side Diff: services/ui/ws/user_display_manager.cc

Issue 2505133003: Mojo C++ bindings: switch part of the services/ui/public/interfaces mojom target to use STL types. (Closed)
Patch Set: Merge branch 'master' into c139_wrappers_ui Created 4 years, 1 month 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 | « services/ui/public/interfaces/BUILD.gn ('k') | services/ui/ws/user_display_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/ws/user_display_manager.h" 5 #include "services/ui/ws/user_display_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "services/ui/display/platform_screen.h" 9 #include "services/ui/display/platform_screen.h"
10 #include "services/ui/ws/display.h" 10 #include "services/ui/ws/display.h"
(...skipping 21 matching lines...) Expand all
32 display_manager_observers_.ForAllPtrs([this]( 32 display_manager_observers_.ForAllPtrs([this](
33 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); 33 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); });
34 if (test_observer_) 34 if (test_observer_)
35 CallOnDisplays(test_observer_); 35 CallOnDisplays(test_observer_);
36 return; 36 return;
37 } 37 }
38 38
39 mojo::Array<mojom::WsDisplayPtr> displays = GetAllDisplays(); 39 mojo::Array<mojom::WsDisplayPtr> displays = GetAllDisplays();
40 display_manager_observers_.ForAllPtrs( 40 display_manager_observers_.ForAllPtrs(
41 [this, &displays](mojom::DisplayManagerObserver* observer) { 41 [this, &displays](mojom::DisplayManagerObserver* observer) {
42 observer->OnDisplaysChanged(displays.Clone()); 42 observer->OnDisplaysChanged(displays.Clone().PassStorage());
43 }); 43 });
44 if (test_observer_) 44 if (test_observer_)
45 test_observer_->OnDisplaysChanged(displays.Clone()); 45 test_observer_->OnDisplaysChanged(displays.Clone().PassStorage());
46 } 46 }
47 47
48 void UserDisplayManager::AddDisplayManagerBinding( 48 void UserDisplayManager::AddDisplayManagerBinding(
49 mojo::InterfaceRequest<mojom::DisplayManager> request) { 49 mojo::InterfaceRequest<mojom::DisplayManager> request) {
50 display_manager_bindings_.AddBinding(this, std::move(request)); 50 display_manager_bindings_.AddBinding(this, std::move(request));
51 } 51 }
52 52
53 void UserDisplayManager::OnDisplayUpdate(Display* display) { 53 void UserDisplayManager::OnDisplayUpdate(Display* display) {
54 if (!got_valid_frame_decorations_) 54 if (!got_valid_frame_decorations_)
55 return; 55 return;
56 56
57 mojo::Array<mojom::WsDisplayPtr> displays(1); 57 mojo::Array<mojom::WsDisplayPtr> displays(1);
58 displays[0] = GetWsDisplayPtr(*display); 58 displays[0] = GetWsDisplayPtr(*display);
59 59
60 display_manager_observers_.ForAllPtrs( 60 display_manager_observers_.ForAllPtrs(
61 [&displays](mojom::DisplayManagerObserver* observer) { 61 [&displays](mojom::DisplayManagerObserver* observer) {
62 observer->OnDisplaysChanged(displays.Clone()); 62 observer->OnDisplaysChanged(displays.Clone().PassStorage());
63 }); 63 });
64 if (test_observer_) 64 if (test_observer_)
65 test_observer_->OnDisplaysChanged(displays.Clone()); 65 test_observer_->OnDisplaysChanged(displays.Clone().PassStorage());
66 } 66 }
67 67
68 void UserDisplayManager::OnWillDestroyDisplay(Display* display) { 68 void UserDisplayManager::OnWillDestroyDisplay(Display* display) {
69 if (!got_valid_frame_decorations_) 69 if (!got_valid_frame_decorations_)
70 return; 70 return;
71 71
72 display_manager_observers_.ForAllPtrs( 72 display_manager_observers_.ForAllPtrs(
73 [&display](mojom::DisplayManagerObserver* observer) { 73 [&display](mojom::DisplayManagerObserver* observer) {
74 observer->OnDisplayRemoved(display->GetId()); 74 observer->OnDisplayRemoved(display->GetId());
75 }); 75 });
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 ++i; 152 ++i;
153 } 153 }
154 154
155 return display_ptrs; 155 return display_ptrs;
156 } 156 }
157 157
158 void UserDisplayManager::CallOnDisplays( 158 void UserDisplayManager::CallOnDisplays(
159 mojom::DisplayManagerObserver* observer) { 159 mojom::DisplayManagerObserver* observer) {
160 // TODO(kylechar): Pass internal display id to clients here. 160 // TODO(kylechar): Pass internal display id to clients here.
161 observer->OnDisplays( 161 observer->OnDisplays(
162 GetAllDisplays(), 162 GetAllDisplays().PassStorage(),
163 display::PlatformScreen::GetInstance()->GetPrimaryDisplayId(), 163 display::PlatformScreen::GetInstance()->GetPrimaryDisplayId(),
164 display::Display::kInvalidDisplayID); 164 display::Display::kInvalidDisplayID);
165 } 165 }
166 166
167 void UserDisplayManager::AddObserver( 167 void UserDisplayManager::AddObserver(
168 mojom::DisplayManagerObserverPtr observer) { 168 mojom::DisplayManagerObserverPtr observer) {
169 mojom::DisplayManagerObserver* observer_impl = observer.get(); 169 mojom::DisplayManagerObserver* observer_impl = observer.get();
170 display_manager_observers_.AddPtr(std::move(observer)); 170 display_manager_observers_.AddPtr(std::move(observer));
171 OnObserverAdded(observer_impl); 171 OnObserverAdded(observer_impl);
172 } 172 }
173 173
174 } // namespace ws 174 } // namespace ws
175 } // namespace ui 175 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/interfaces/BUILD.gn ('k') | services/ui/ws/user_display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698