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

Side by Side Diff: ash/mus/window_manager_application.cc

Issue 2476063002: Service Manager: Rework Service and ServiceContext lifetime (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/touch_hud/mus/touch_hud_application.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ash/mus/window_manager_application.h" 5 #include "ash/mus/window_manager_application.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/mojo_interface_factory.h" 10 #include "ash/common/mojo_interface_factory.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/mus/native_widget_factory_mus.h" 12 #include "ash/mus/native_widget_factory_mus.h"
13 #include "ash/mus/window_manager.h" 13 #include "ash/mus/window_manager.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "services/service_manager/public/cpp/connection.h" 16 #include "services/service_manager/public/cpp/connection.h"
17 #include "services/service_manager/public/cpp/connector.h" 17 #include "services/service_manager/public/cpp/connector.h"
18 #include "services/service_manager/public/cpp/service_context.h"
18 #include "services/tracing/public/cpp/provider.h" 19 #include "services/tracing/public/cpp/provider.h"
19 #include "services/ui/common/event_matcher_util.h" 20 #include "services/ui/common/event_matcher_util.h"
20 #include "services/ui/public/cpp/gpu_service.h" 21 #include "services/ui/public/cpp/gpu_service.h"
21 #include "services/ui/public/cpp/window.h" 22 #include "services/ui/public/cpp/window.h"
22 #include "services/ui/public/cpp/window_tree_client.h" 23 #include "services/ui/public/cpp/window_tree_client.h"
23 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
24 #include "ui/events/event.h" 25 #include "ui/events/event.h"
25 #include "ui/message_center/message_center.h" 26 #include "ui/message_center/message_center.h"
26 #include "ui/views/mus/aura_init.h" 27 #include "ui/views/mus/aura_init.h"
27 #include "ui/views/mus/surface_context_factory.h" 28 #include "ui/views/mus/surface_context_factory.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 chromeos::NetworkConnect::Shutdown(); 111 chromeos::NetworkConnect::Shutdown();
111 network_connect_delegate_.reset(); 112 network_connect_delegate_.reset();
112 chromeos::NetworkHandler::Shutdown(); 113 chromeos::NetworkHandler::Shutdown();
113 bluez::BluezDBusManager::Shutdown(); 114 bluez::BluezDBusManager::Shutdown();
114 chromeos::DBusThreadManager::Shutdown(); 115 chromeos::DBusThreadManager::Shutdown();
115 #endif 116 #endif
116 message_center::MessageCenter::Shutdown(); 117 message_center::MessageCenter::Shutdown();
117 } 118 }
118 119
119 void WindowManagerApplication::OnStart( 120 void WindowManagerApplication::OnStart(
120 const service_manager::ServiceInfo& info) { 121 service_manager::ServiceContext* context) {
121 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, 122 context_ = context;
122 "ash_mus_resources.pak", 123 aura_init_ = base::MakeUnique<views::AuraInit>(
123 "ash_mus_resources_200.pak"); 124 context->connector(), context->identity(), "ash_mus_resources.pak",
124 gpu_service_ = ui::GpuService::Create(connector()); 125 "ash_mus_resources_200.pak");
126 gpu_service_ = ui::GpuService::Create(context->connector());
125 compositor_context_factory_.reset( 127 compositor_context_factory_.reset(
126 new views::SurfaceContextFactory(gpu_service_.get())); 128 new views::SurfaceContextFactory(gpu_service_.get()));
127 aura::Env::GetInstance()->set_context_factory( 129 aura::Env::GetInstance()->set_context_factory(
128 compositor_context_factory_.get()); 130 compositor_context_factory_.get());
129 window_manager_.reset(new WindowManager(connector())); 131 window_manager_.reset(new WindowManager(context->connector()));
130 132
131 MaterialDesignController::Initialize(); 133 MaterialDesignController::Initialize();
132 134
133 tracing_.Initialize(connector(), info.identity.name()); 135 tracing_.Initialize(context->connector(), context->identity().name());
134 136
135 std::unique_ptr<ui::WindowTreeClient> window_tree_client = 137 std::unique_ptr<ui::WindowTreeClient> window_tree_client =
136 base::MakeUnique<ui::WindowTreeClient>(window_manager_.get(), 138 base::MakeUnique<ui::WindowTreeClient>(window_manager_.get(),
137 window_manager_.get()); 139 window_manager_.get());
138 window_tree_client->ConnectAsWindowManager(connector()); 140 window_tree_client->ConnectAsWindowManager(context->connector());
139 141
140 const size_t kMaxNumberThreads = 3u; // Matches that of content. 142 const size_t kMaxNumberThreads = 3u; // Matches that of content.
141 const char kThreadNamePrefix[] = "MashBlocking"; 143 const char kThreadNamePrefix[] = "MashBlocking";
142 blocking_pool_ = new base::SequencedWorkerPool( 144 blocking_pool_ = new base::SequencedWorkerPool(
143 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); 145 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE);
144 InitWindowManager(std::move(window_tree_client), blocking_pool_); 146 InitWindowManager(std::move(window_tree_client), blocking_pool_);
145 } 147 }
146 148
147 bool WindowManagerApplication::OnConnect( 149 bool WindowManagerApplication::OnConnect(
148 const service_manager::ServiceInfo& remote_info, 150 const service_manager::ServiceInfo& remote_info,
149 service_manager::InterfaceRegistry* registry) { 151 service_manager::InterfaceRegistry* registry) {
150 // Register services used in both classic ash and mash. 152 // Register services used in both classic ash and mash.
151 mojo_interface_factory::RegisterInterfaces( 153 mojo_interface_factory::RegisterInterfaces(
152 registry, base::ThreadTaskRunnerHandle::Get()); 154 registry, base::ThreadTaskRunnerHandle::Get());
153 155
154 if (remote_info.identity.name() == "service:mash_session") { 156 if (remote_info.identity.name() == "service:mash_session") {
155 connector()->ConnectToInterface(remote_info.identity, &session_); 157 context_->connector()->ConnectToInterface(remote_info.identity, &session_);
156 session_->AddScreenlockStateListener( 158 session_->AddScreenlockStateListener(
157 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); 159 screenlock_state_listener_binding_.CreateInterfacePtrAndBind());
158 } 160 }
159 return true; 161 return true;
160 } 162 }
161 163
162 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { 164 void WindowManagerApplication::ScreenlockStateChanged(bool locked) {
163 window_manager_->SetScreenLocked(locked); 165 window_manager_->SetScreenLocked(locked);
164 } 166 }
165 167
166 } // namespace mus 168 } // namespace mus
167 } // namespace ash 169 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/touch_hud/mus/touch_hud_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698