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