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 21 matching lines...) Expand all Loading... |
32 #endif | 32 #endif |
33 | 33 |
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 { |
| 43 scoped_ptr<mojo::InterfaceRequest<mojom::DisplayManager>> dm_request; |
| 44 scoped_ptr<mojo::InterfaceRequest<mojom::WindowManager>> wm_request; |
| 45 }; |
| 46 |
42 MandolineUIServicesApp::MandolineUIServicesApp() | 47 MandolineUIServicesApp::MandolineUIServicesApp() |
43 : app_impl_(nullptr) {} | 48 : app_impl_(nullptr) {} |
44 | 49 |
45 MandolineUIServicesApp::~MandolineUIServicesApp() { | 50 MandolineUIServicesApp::~MandolineUIServicesApp() { |
46 if (gpu_state_) | 51 if (gpu_state_) |
47 gpu_state_->StopThreads(); | 52 gpu_state_->StopThreads(); |
48 // Destroy |connection_manager_| first, since it depends on |event_source_|. | 53 // Destroy |connection_manager_| first, since it depends on |event_source_|. |
49 connection_manager_.reset(); | 54 connection_manager_.reset(); |
50 } | 55 } |
51 | 56 |
(...skipping 28 matching lines...) Expand all Loading... |
80 if (!gpu_state_.get()) | 85 if (!gpu_state_.get()) |
81 gpu_state_ = new GpuState(hardware_rendering_available); | 86 gpu_state_ = new GpuState(hardware_rendering_available); |
82 connection_manager_.reset(new ws::ConnectionManager(this, surfaces_state_)); | 87 connection_manager_.reset(new ws::ConnectionManager(this, surfaces_state_)); |
83 | 88 |
84 tracing_.Initialize(app); | 89 tracing_.Initialize(app); |
85 } | 90 } |
86 | 91 |
87 bool MandolineUIServicesApp::ConfigureIncomingConnection( | 92 bool MandolineUIServicesApp::ConfigureIncomingConnection( |
88 ApplicationConnection* connection) { | 93 ApplicationConnection* connection) { |
89 connection->AddService<Gpu>(this); | 94 connection->AddService<Gpu>(this); |
| 95 connection->AddService<mojom::DisplayManager>(this); |
90 connection->AddService<mojom::WindowManager>(this); | 96 connection->AddService<mojom::WindowManager>(this); |
91 connection->AddService<WindowTreeHostFactory>(this); | 97 connection->AddService<WindowTreeHostFactory>(this); |
92 return true; | 98 return true; |
93 } | 99 } |
94 | 100 |
95 void MandolineUIServicesApp::OnFirstRootConnectionCreated() { | 101 void MandolineUIServicesApp::OnFirstRootConnectionCreated() { |
96 WindowManagerRequests requests; | 102 PendingRequests requests; |
97 requests.swap(pending_window_manager_requests_); | 103 requests.swap(pending_requests_); |
98 for (auto& request : requests) | 104 for (auto& request : requests) { |
99 Create(nullptr, std::move(*request)); | 105 if (request->dm_request) |
| 106 Create(nullptr, std::move(*request->dm_request)); |
| 107 else |
| 108 Create(nullptr, std::move(*request->wm_request)); |
| 109 } |
100 } | 110 } |
101 | 111 |
102 void MandolineUIServicesApp::OnNoMoreRootConnections() { | 112 void MandolineUIServicesApp::OnNoMoreRootConnections() { |
103 app_impl_->Quit(); | 113 app_impl_->Quit(); |
104 } | 114 } |
105 | 115 |
106 ws::ClientConnection* | 116 ws::ClientConnection* |
107 MandolineUIServicesApp::CreateClientConnectionForEmbedAtWindow( | 117 MandolineUIServicesApp::CreateClientConnectionForEmbedAtWindow( |
108 ws::ConnectionManager* connection_manager, | 118 ws::ConnectionManager* connection_manager, |
109 mojo::InterfaceRequest<mojom::WindowTree> tree_request, | 119 mojo::InterfaceRequest<mojom::WindowTree> tree_request, |
110 ws::ServerWindow* root, | 120 ws::ServerWindow* root, |
111 uint32_t policy_bitmask, | 121 uint32_t policy_bitmask, |
112 mojom::WindowTreeClientPtr client) { | 122 mojom::WindowTreeClientPtr client) { |
113 scoped_ptr<ws::WindowTreeImpl> service( | 123 scoped_ptr<ws::WindowTreeImpl> service( |
114 new ws::WindowTreeImpl(connection_manager, root, policy_bitmask)); | 124 new ws::WindowTreeImpl(connection_manager, root, policy_bitmask)); |
115 return new ws::DefaultClientConnection(std::move(service), connection_manager, | 125 return new ws::DefaultClientConnection(std::move(service), connection_manager, |
116 std::move(tree_request), | 126 std::move(tree_request), |
117 std::move(client)); | 127 std::move(client)); |
118 } | 128 } |
119 | 129 |
120 void MandolineUIServicesApp::Create( | 130 void MandolineUIServicesApp::Create( |
121 mojo::ApplicationConnection* connection, | 131 mojo::ApplicationConnection* connection, |
| 132 mojo::InterfaceRequest<mojom::DisplayManager> request) { |
| 133 if (!connection_manager_->has_tree_host_connections()) { |
| 134 scoped_ptr<PendingRequest> pending_request(new PendingRequest); |
| 135 pending_request->dm_request.reset( |
| 136 new mojo::InterfaceRequest<mojom::DisplayManager>(std::move(request))); |
| 137 pending_requests_.push_back(std::move(pending_request)); |
| 138 return; |
| 139 } |
| 140 connection_manager_->AddDisplayManagerBinding(std::move(request)); |
| 141 } |
| 142 |
| 143 void MandolineUIServicesApp::Create( |
| 144 mojo::ApplicationConnection* connection, |
122 mojo::InterfaceRequest<mojom::WindowManager> request) { | 145 mojo::InterfaceRequest<mojom::WindowManager> request) { |
123 if (!connection_manager_->has_tree_host_connections()) { | 146 if (!connection_manager_->has_tree_host_connections()) { |
124 pending_window_manager_requests_.push_back(make_scoped_ptr( | 147 scoped_ptr<PendingRequest> pending_request(new PendingRequest); |
125 new mojo::InterfaceRequest<mojom::WindowManager>(std::move(request)))); | 148 pending_request->wm_request.reset( |
| 149 new mojo::InterfaceRequest<mojom::WindowManager>(std::move(request))); |
| 150 pending_requests_.push_back(std::move(pending_request)); |
126 return; | 151 return; |
127 } | 152 } |
128 if (!window_manager_impl_) { | 153 if (!window_manager_impl_) { |
129 window_manager_impl_.reset( | 154 window_manager_impl_.reset( |
130 new ws::ForwardingWindowManager(connection_manager_.get())); | 155 new ws::ForwardingWindowManager(connection_manager_.get())); |
131 } | 156 } |
132 window_manager_bindings_.AddBinding(window_manager_impl_.get(), | 157 window_manager_bindings_.AddBinding(window_manager_impl_.get(), |
133 std::move(request)); | 158 std::move(request)); |
134 } | 159 } |
135 | 160 |
(...skipping 22 matching lines...) Expand all Loading... |
158 std::move(host_client), connection_manager_.get(), app_impl_, gpu_state_, | 183 std::move(host_client), connection_manager_.get(), app_impl_, gpu_state_, |
159 surfaces_state_, std::move(window_manager)); | 184 surfaces_state_, std::move(window_manager)); |
160 | 185 |
161 // WindowTreeHostConnection manages its own lifetime. | 186 // WindowTreeHostConnection manages its own lifetime. |
162 host_impl->Init(new ws::WindowTreeHostConnectionImpl( | 187 host_impl->Init(new ws::WindowTreeHostConnectionImpl( |
163 std::move(host), make_scoped_ptr(host_impl), std::move(tree_client), | 188 std::move(host), make_scoped_ptr(host_impl), std::move(tree_client), |
164 connection_manager_.get())); | 189 connection_manager_.get())); |
165 } | 190 } |
166 | 191 |
167 } // namespace mus | 192 } // namespace mus |
OLD | NEW |