| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 struct MandolineUIServicesApp::UserState { | 64 struct MandolineUIServicesApp::UserState { |
| 65 scoped_ptr<ws::WindowTreeFactory> window_tree_factory; | 65 scoped_ptr<ws::WindowTreeFactory> window_tree_factory; |
| 66 scoped_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 66 scoped_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 MandolineUIServicesApp::MandolineUIServicesApp() {} | 69 MandolineUIServicesApp::MandolineUIServicesApp() {} |
| 70 | 70 |
| 71 MandolineUIServicesApp::~MandolineUIServicesApp() { | 71 MandolineUIServicesApp::~MandolineUIServicesApp() { |
| 72 // Destroy |window_server_| first, since it depends on |event_source_|. |
| 73 // WindowServer (or more correctly its Displays) may have state that needs to |
| 74 // be destroyed before GpuState as well. |
| 75 window_server_.reset(); |
| 76 |
| 72 if (platform_display_init_params_.gpu_state) | 77 if (platform_display_init_params_.gpu_state) |
| 73 platform_display_init_params_.gpu_state->StopThreads(); | 78 platform_display_init_params_.gpu_state->StopThreads(); |
| 74 // Destroy |window_server_| first, since it depends on |event_source_|. | |
| 75 window_server_.reset(); | |
| 76 } | 79 } |
| 77 | 80 |
| 78 void MandolineUIServicesApp::InitializeResources(mojo::Connector* connector) { | 81 void MandolineUIServicesApp::InitializeResources(mojo::Connector* connector) { |
| 79 if (ui::ResourceBundle::HasSharedInstance()) | 82 if (ui::ResourceBundle::HasSharedInstance()) |
| 80 return; | 83 return; |
| 81 | 84 |
| 82 std::set<std::string> resource_paths; | 85 std::set<std::string> resource_paths; |
| 83 resource_paths.insert(kResourceFileStrings); | 86 resource_paths.insert(kResourceFileStrings); |
| 84 resource_paths.insert(kResourceFile100); | 87 resource_paths.insert(kResourceFile100); |
| 85 resource_paths.insert(kResourceFile200); | 88 resource_paths.insert(kResourceFile200); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 177 } |
| 175 | 178 |
| 176 void MandolineUIServicesApp::OnFirstDisplayReady() { | 179 void MandolineUIServicesApp::OnFirstDisplayReady() { |
| 177 PendingRequests requests; | 180 PendingRequests requests; |
| 178 requests.swap(pending_requests_); | 181 requests.swap(pending_requests_); |
| 179 for (auto& request : requests) | 182 for (auto& request : requests) |
| 180 Create(request->connection, std::move(*request->wtf_request)); | 183 Create(request->connection, std::move(*request->wtf_request)); |
| 181 } | 184 } |
| 182 | 185 |
| 183 void MandolineUIServicesApp::OnNoMoreDisplays() { | 186 void MandolineUIServicesApp::OnNoMoreDisplays() { |
| 184 base::MessageLoop::current()->QuitWhenIdle(); | 187 // We may get here from the destructor, in which case there is no messageloop. |
| 188 if (base::MessageLoop::current()) |
| 189 base::MessageLoop::current()->QuitWhenIdle(); |
| 185 } | 190 } |
| 186 | 191 |
| 187 scoped_ptr<ws::WindowTreeBinding> | 192 scoped_ptr<ws::WindowTreeBinding> |
| 188 MandolineUIServicesApp::CreateWindowTreeBindingForEmbedAtWindow( | 193 MandolineUIServicesApp::CreateWindowTreeBindingForEmbedAtWindow( |
| 189 ws::WindowServer* window_server, | 194 ws::WindowServer* window_server, |
| 190 ws::WindowTree* tree, | 195 ws::WindowTree* tree, |
| 191 mojom::WindowTreeRequest tree_request, | 196 mojom::WindowTreeRequest tree_request, |
| 192 mojom::WindowTreeClientPtr client) { | 197 mojom::WindowTreeClientPtr client) { |
| 193 return make_scoped_ptr(new ws::DefaultWindowTreeBinding( | 198 return make_scoped_ptr(new ws::DefaultWindowTreeBinding( |
| 194 tree, window_server, std::move(tree_request), std::move(client))); | 199 tree, window_server, std::move(tree_request), std::move(client))); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 user_state->window_tree_host_factory->AddBinding(std::move(request)); | 259 user_state->window_tree_host_factory->AddBinding(std::move(request)); |
| 255 } | 260 } |
| 256 | 261 |
| 257 void MandolineUIServicesApp::Create(mojo::Connection* connection, | 262 void MandolineUIServicesApp::Create(mojo::Connection* connection, |
| 258 mojom::GpuRequest request) { | 263 mojom::GpuRequest request) { |
| 259 DCHECK(platform_display_init_params_.gpu_state); | 264 DCHECK(platform_display_init_params_.gpu_state); |
| 260 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); | 265 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); |
| 261 } | 266 } |
| 262 | 267 |
| 263 } // namespace mus | 268 } // namespace mus |
| OLD | NEW |