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

Side by Side Diff: services/ui/display/screen_manager_forwarding.cc

Issue 2835933005: Make ForwardingDisplayDelegate initially sync. (Closed)
Patch Set: Add comment explaining sync usage. Created 3 years, 8 months 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/display/screen_manager_forwarding.h" 5 #include "services/ui/display/screen_manager_forwarding.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "services/service_manager/public/cpp/binder_registry.h" 10 #include "services/service_manager/public/cpp/binder_registry.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void ScreenManagerForwarding::OnConfigurationChanged() { 62 void ScreenManagerForwarding::OnConfigurationChanged() {
63 if (observer_.is_bound()) 63 if (observer_.is_bound())
64 observer_->OnConfigurationChanged(); 64 observer_->OnConfigurationChanged();
65 } 65 }
66 66
67 void ScreenManagerForwarding::OnDisplaySnapshotsInvalidated() { 67 void ScreenManagerForwarding::OnDisplaySnapshotsInvalidated() {
68 snapshot_map_.clear(); 68 snapshot_map_.clear();
69 } 69 }
70 70
71 void ScreenManagerForwarding::Initialize( 71 void ScreenManagerForwarding::Initialize(
72 mojom::NativeDisplayObserverPtr observer) { 72 mojom::NativeDisplayObserverPtr observer,
73 const InitializeCallback& callback) {
73 DCHECK(!native_display_delegate_); 74 DCHECK(!native_display_delegate_);
74 observer_ = std::move(observer); 75 observer_ = std::move(observer);
75 76
76 native_display_delegate_ = 77 native_display_delegate_ =
77 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(); 78 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
78 native_display_delegate_->AddObserver(this); 79 native_display_delegate_->AddObserver(this);
79 native_display_delegate_->Initialize(); 80 native_display_delegate_->Initialize();
81
82 // Provide the list of display snapshots initially. ForwardingDisplayDelegate
83 // will wait synchronously for this.
84 native_display_delegate_->GetDisplays(
85 base::Bind(&ScreenManagerForwarding::ForwardGetDisplays,
86 base::Unretained(this), callback));
87
88 // When ForwardingDisplayDelegate receives this it will start asynchronous
89 // operation and redo any configuration that was skipped.
90 observer_->OnConfigurationChanged();
80 } 91 }
81 92
82 void ScreenManagerForwarding::TakeDisplayControl( 93 void ScreenManagerForwarding::TakeDisplayControl(
83 const TakeDisplayControlCallback& callback) { 94 const TakeDisplayControlCallback& callback) {
84 DCHECK(native_display_delegate_); 95 DCHECK(native_display_delegate_);
85 native_display_delegate_->TakeDisplayControl(callback); 96 native_display_delegate_->TakeDisplayControl(callback);
86 } 97 }
87 98
88 void ScreenManagerForwarding::RelinquishDisplayControl( 99 void ScreenManagerForwarding::RelinquishDisplayControl(
89 const RelinquishDisplayControlCallback& callback) { 100 const RelinquishDisplayControlCallback& callback) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 174 }
164 175
165 void ScreenManagerForwarding::Create( 176 void ScreenManagerForwarding::Create(
166 const service_manager::Identity& remote_identity, 177 const service_manager::Identity& remote_identity,
167 mojom::NativeDisplayDelegateRequest request) { 178 mojom::NativeDisplayDelegateRequest request) {
168 DCHECK(!binding_.is_bound()); 179 DCHECK(!binding_.is_bound());
169 binding_.Bind(std::move(request)); 180 binding_.Bind(std::move(request));
170 } 181 }
171 182
172 void ScreenManagerForwarding::ForwardGetDisplays( 183 void ScreenManagerForwarding::ForwardGetDisplays(
173 const mojom::NativeDisplayDelegate::GetDisplaysCallback& callback, 184 const GetDisplaysCallback& callback,
174 const std::vector<DisplaySnapshot*>& snapshots) { 185 const std::vector<DisplaySnapshot*>& snapshots) {
175 snapshot_map_.clear(); 186 snapshot_map_.clear();
176 187
177 // Convert the DisplaySnapshots to MojoDisplaySnapshots to allow sending 188 // Convert the DisplaySnapshots to MojoDisplaySnapshots to allow sending
178 // over Mojo. Also caches the snapshots for lookup later. 189 // over Mojo. Also caches the snapshots for lookup later.
179 std::vector<std::unique_ptr<DisplaySnapshotMojo>> mojo_snapshots; 190 std::vector<std::unique_ptr<DisplaySnapshotMojo>> mojo_snapshots;
180 for (auto* snapshot : snapshots) { 191 for (auto* snapshot : snapshots) {
181 snapshot_map_[snapshot->display_id()] = snapshot; 192 snapshot_map_[snapshot->display_id()] = snapshot;
182 mojo_snapshots.push_back(DisplaySnapshotMojo::CreateFrom(*snapshot)); 193 mojo_snapshots.push_back(DisplaySnapshotMojo::CreateFrom(*snapshot));
183 } 194 }
(...skipping 10 matching lines...) Expand all
194 if (status) { 205 if (status) {
195 // Modify display snapshot similar to how ConfigureDisplaysTask would. Ozone 206 // Modify display snapshot similar to how ConfigureDisplaysTask would. Ozone
196 // DRM needs these to be changed and ConfigureDisplaysTasks can't do it. 207 // DRM needs these to be changed and ConfigureDisplaysTasks can't do it.
197 snapshot->set_current_mode(mode); 208 snapshot->set_current_mode(mode);
198 snapshot->set_origin(origin); 209 snapshot->set_origin(origin);
199 } 210 }
200 callback.Run(status); 211 callback.Run(status);
201 } 212 }
202 213
203 } // namespace display 214 } // namespace display
OLDNEW
« no previous file with comments | « services/ui/display/screen_manager_forwarding.h ('k') | ui/display/manager/forwarding_display_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698