| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/mus/mus_app.h" | 5 #include "components/mus/mus_app.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "components/mus/common/args.h" | 9 #include "components/mus/common/args.h" |
| 10 #include "components/mus/gles2/gpu_impl.h" | 10 #include "components/mus/gles2/gpu_impl.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 using mojo::ApplicationConnection; | 34 using mojo::ApplicationConnection; |
| 35 using mojo::ApplicationImpl; | 35 using mojo::ApplicationImpl; |
| 36 using mojo::InterfaceRequest; | 36 using mojo::InterfaceRequest; |
| 37 using mus::mojom::WindowTreeHostFactory; | 37 using mus::mojom::WindowTreeHostFactory; |
| 38 using mus::mojom::Gpu; | 38 using mus::mojom::Gpu; |
| 39 | 39 |
| 40 namespace mus { | 40 namespace mus { |
| 41 | 41 |
| 42 struct MandolineUIServicesApp::PendingRequest { | 42 struct MandolineUIServicesApp::PendingRequest { |
| 43 scoped_ptr<mojo::InterfaceRequest<mojom::DisplayManager>> dm_request; | 43 scoped_ptr<mojo::InterfaceRequest<mojom::DisplayManager>> dm_request; |
| 44 scoped_ptr<mojo::InterfaceRequest<mojom::WindowManager>> wm_request; | 44 scoped_ptr<mojo::InterfaceRequest<mojom::WindowManagerDeprecated>> wm_request; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 MandolineUIServicesApp::MandolineUIServicesApp() | 47 MandolineUIServicesApp::MandolineUIServicesApp() |
| 48 : app_impl_(nullptr) {} | 48 : app_impl_(nullptr) {} |
| 49 | 49 |
| 50 MandolineUIServicesApp::~MandolineUIServicesApp() { | 50 MandolineUIServicesApp::~MandolineUIServicesApp() { |
| 51 if (gpu_state_) | 51 if (gpu_state_) |
| 52 gpu_state_->StopThreads(); | 52 gpu_state_->StopThreads(); |
| 53 // Destroy |connection_manager_| first, since it depends on |event_source_|. | 53 // Destroy |connection_manager_| first, since it depends on |event_source_|. |
| 54 connection_manager_.reset(); | 54 connection_manager_.reset(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 gpu_state_ = new GpuState(hardware_rendering_available); | 86 gpu_state_ = new GpuState(hardware_rendering_available); |
| 87 connection_manager_.reset(new ws::ConnectionManager(this, surfaces_state_)); | 87 connection_manager_.reset(new ws::ConnectionManager(this, surfaces_state_)); |
| 88 | 88 |
| 89 tracing_.Initialize(app); | 89 tracing_.Initialize(app); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool MandolineUIServicesApp::ConfigureIncomingConnection( | 92 bool MandolineUIServicesApp::ConfigureIncomingConnection( |
| 93 ApplicationConnection* connection) { | 93 ApplicationConnection* connection) { |
| 94 connection->AddService<Gpu>(this); | 94 connection->AddService<Gpu>(this); |
| 95 connection->AddService<mojom::DisplayManager>(this); | 95 connection->AddService<mojom::DisplayManager>(this); |
| 96 connection->AddService<mojom::WindowManager>(this); | 96 connection->AddService<mojom::WindowManagerDeprecated>(this); |
| 97 connection->AddService<WindowTreeHostFactory>(this); | 97 connection->AddService<WindowTreeHostFactory>(this); |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void MandolineUIServicesApp::OnFirstRootConnectionCreated() { | 101 void MandolineUIServicesApp::OnFirstRootConnectionCreated() { |
| 102 PendingRequests requests; | 102 PendingRequests requests; |
| 103 requests.swap(pending_requests_); | 103 requests.swap(pending_requests_); |
| 104 for (auto& request : requests) { | 104 for (auto& request : requests) { |
| 105 if (request->dm_request) | 105 if (request->dm_request) |
| 106 Create(nullptr, std::move(*request->dm_request)); | 106 Create(nullptr, std::move(*request->dm_request)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 135 pending_request->dm_request.reset( | 135 pending_request->dm_request.reset( |
| 136 new mojo::InterfaceRequest<mojom::DisplayManager>(std::move(request))); | 136 new mojo::InterfaceRequest<mojom::DisplayManager>(std::move(request))); |
| 137 pending_requests_.push_back(std::move(pending_request)); | 137 pending_requests_.push_back(std::move(pending_request)); |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 connection_manager_->AddDisplayManagerBinding(std::move(request)); | 140 connection_manager_->AddDisplayManagerBinding(std::move(request)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void MandolineUIServicesApp::Create( | 143 void MandolineUIServicesApp::Create( |
| 144 mojo::ApplicationConnection* connection, | 144 mojo::ApplicationConnection* connection, |
| 145 mojo::InterfaceRequest<mojom::WindowManager> request) { | 145 mojo::InterfaceRequest<mojom::WindowManagerDeprecated> request) { |
| 146 if (!connection_manager_->has_tree_host_connections()) { | 146 if (!connection_manager_->has_tree_host_connections()) { |
| 147 scoped_ptr<PendingRequest> pending_request(new PendingRequest); | 147 scoped_ptr<PendingRequest> pending_request(new PendingRequest); |
| 148 pending_request->wm_request.reset( | 148 pending_request->wm_request.reset( |
| 149 new mojo::InterfaceRequest<mojom::WindowManager>(std::move(request))); | 149 new mojo::InterfaceRequest<mojom::WindowManagerDeprecated>( |
| 150 std::move(request))); |
| 150 pending_requests_.push_back(std::move(pending_request)); | 151 pending_requests_.push_back(std::move(pending_request)); |
| 151 return; | 152 return; |
| 152 } | 153 } |
| 153 if (!window_manager_impl_) { | 154 if (!window_manager_impl_) { |
| 154 window_manager_impl_.reset( | 155 window_manager_impl_.reset( |
| 155 new ws::ForwardingWindowManager(connection_manager_.get())); | 156 new ws::ForwardingWindowManager(connection_manager_.get())); |
| 156 } | 157 } |
| 157 window_manager_bindings_.AddBinding(window_manager_impl_.get(), | 158 window_manager_bindings_.AddBinding(window_manager_impl_.get(), |
| 158 std::move(request)); | 159 std::move(request)); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void MandolineUIServicesApp::Create( | 162 void MandolineUIServicesApp::Create( |
| 162 ApplicationConnection* connection, | 163 ApplicationConnection* connection, |
| 163 InterfaceRequest<WindowTreeHostFactory> request) { | 164 InterfaceRequest<WindowTreeHostFactory> request) { |
| 164 factory_bindings_.AddBinding(this, std::move(request)); | 165 factory_bindings_.AddBinding(this, std::move(request)); |
| 165 } | 166 } |
| 166 | 167 |
| 167 void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection, | 168 void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection, |
| 168 mojo::InterfaceRequest<Gpu> request) { | 169 mojo::InterfaceRequest<Gpu> request) { |
| 169 DCHECK(gpu_state_); | 170 DCHECK(gpu_state_); |
| 170 new GpuImpl(std::move(request), gpu_state_); | 171 new GpuImpl(std::move(request), gpu_state_); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void MandolineUIServicesApp::CreateWindowTreeHost( | 174 void MandolineUIServicesApp::CreateWindowTreeHost( |
| 174 mojo::InterfaceRequest<mojom::WindowTreeHost> host, | 175 mojo::InterfaceRequest<mojom::WindowTreeHost> host, |
| 175 mojom::WindowTreeHostClientPtr host_client, | 176 mojom::WindowTreeHostClientPtr host_client, |
| 176 mojom::WindowTreeClientPtr tree_client, | 177 mojom::WindowTreeClientPtr tree_client, |
| 177 mojom::WindowManagerPtr window_manager) { | 178 mojom::WindowManagerDeprecatedPtr window_manager) { |
| 178 DCHECK(connection_manager_); | 179 DCHECK(connection_manager_); |
| 179 | 180 |
| 180 // TODO(fsamuel): We need to make sure that only the window manager can create | 181 // TODO(fsamuel): We need to make sure that only the window manager can create |
| 181 // new roots. | 182 // new roots. |
| 182 ws::WindowTreeHostImpl* host_impl = new ws::WindowTreeHostImpl( | 183 ws::WindowTreeHostImpl* host_impl = new ws::WindowTreeHostImpl( |
| 183 std::move(host_client), connection_manager_.get(), app_impl_, gpu_state_, | 184 std::move(host_client), connection_manager_.get(), app_impl_, gpu_state_, |
| 184 surfaces_state_, std::move(window_manager)); | 185 surfaces_state_, std::move(window_manager)); |
| 185 | 186 |
| 186 // WindowTreeHostConnection manages its own lifetime. | 187 // WindowTreeHostConnection manages its own lifetime. |
| 187 host_impl->Init(new ws::WindowTreeHostConnectionImpl( | 188 host_impl->Init(new ws::WindowTreeHostConnectionImpl( |
| 188 std::move(host), make_scoped_ptr(host_impl), std::move(tree_client), | 189 std::move(host), make_scoped_ptr(host_impl), std::move(tree_client), |
| 189 connection_manager_.get())); | 190 connection_manager_.get())); |
| 190 } | 191 } |
| 191 | 192 |
| 192 } // namespace mus | 193 } // namespace mus |
| OLD | NEW |