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

Side by Side Diff: services/ui/service.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 | « services/ui/service.h ('k') | services/ui/test_wm/test_wm.cc » ('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 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 "services/ui/service.h" 5 #include "services/ui/service.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "mojo/public/cpp/bindings/strong_binding.h" 16 #include "mojo/public/cpp/bindings/strong_binding.h"
17 #include "services/catalog/public/cpp/resource_loader.h" 17 #include "services/catalog/public/cpp/resource_loader.h"
18 #include "services/service_manager/public/c/main.h" 18 #include "services/service_manager/public/c/main.h"
19 #include "services/service_manager/public/cpp/connection.h" 19 #include "services/service_manager/public/cpp/connection.h"
20 #include "services/service_manager/public/cpp/connector.h" 20 #include "services/service_manager/public/cpp/connector.h"
21 #include "services/service_manager/public/cpp/interface_registry.h"
22 #include "services/service_manager/public/cpp/service_context.h"
21 #include "services/tracing/public/cpp/provider.h" 23 #include "services/tracing/public/cpp/provider.h"
22 #include "services/ui/clipboard/clipboard_impl.h" 24 #include "services/ui/clipboard/clipboard_impl.h"
23 #include "services/ui/common/switches.h" 25 #include "services/ui/common/switches.h"
24 #include "services/ui/display/platform_screen.h" 26 #include "services/ui/display/platform_screen.h"
25 #include "services/ui/ime/ime_registrar_impl.h" 27 #include "services/ui/ime/ime_registrar_impl.h"
26 #include "services/ui/ime/ime_server_impl.h" 28 #include "services/ui/ime/ime_server_impl.h"
27 #include "services/ui/ws/accessibility_manager.h" 29 #include "services/ui/ws/accessibility_manager.h"
28 #include "services/ui/ws/display.h" 30 #include "services/ui/ws/display.h"
29 #include "services/ui/ws/display_binding.h" 31 #include "services/ui/ws/display_binding.h"
30 #include "services/ui/ws/display_manager.h" 32 #include "services/ui/ws/display_manager.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return it->second.get(); 130 return it->second.get();
129 user_id_to_user_state_[user_id] = base::WrapUnique(new UserState); 131 user_id_to_user_state_[user_id] = base::WrapUnique(new UserState);
130 return user_id_to_user_state_[user_id].get(); 132 return user_id_to_user_state_[user_id].get();
131 } 133 }
132 134
133 void Service::AddUserIfNecessary( 135 void Service::AddUserIfNecessary(
134 const service_manager::Identity& remote_identity) { 136 const service_manager::Identity& remote_identity) {
135 window_server_->user_id_tracker()->AddUserId(remote_identity.user_id()); 137 window_server_->user_id_tracker()->AddUserId(remote_identity.user_id());
136 } 138 }
137 139
138 void Service::OnStart(const service_manager::ServiceInfo& info) { 140 void Service::OnStart(service_manager::ServiceContext* context) {
139 base::PlatformThread::SetName("mus"); 141 base::PlatformThread::SetName("mus");
140 tracing_.Initialize(connector(), info.identity.name()); 142 tracing_.Initialize(context->connector(), context->identity().name());
141 TRACE_EVENT0("mus", "Service::Initialize started"); 143 TRACE_EVENT0("mus", "Service::Initialize started");
142 144
143 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 145 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
144 switches::kUseTestConfig); 146 switches::kUseTestConfig);
145 #if defined(USE_X11) 147 #if defined(USE_X11)
146 XInitThreads(); 148 XInitThreads();
147 if (test_config_) 149 if (test_config_)
148 ui::test::SetUseOverrideRedirectWindowByDefault(true); 150 ui::test::SetUseOverrideRedirectWindowByDefault(true);
149 #endif 151 #endif
150 152
151 InitializeResources(connector()); 153 InitializeResources(context->connector());
152 154
153 #if defined(USE_OZONE) 155 #if defined(USE_OZONE)
154 // The ozone platform can provide its own event source. So initialize the 156 // The ozone platform can provide its own event source. So initialize the
155 // platform before creating the default event source. 157 // platform before creating the default event source.
156 // Because GL libraries need to be initialized before entering the sandbox, 158 // Because GL libraries need to be initialized before entering the sandbox,
157 // in MUS, |InitializeForUI| will load the GL libraries. 159 // in MUS, |InitializeForUI| will load the GL libraries.
158 ui::OzonePlatform::InitParams params; 160 ui::OzonePlatform::InitParams params;
159 params.connector = connector(); 161 params.connector = context->connector();
160 params.single_process = false; 162 params.single_process = false;
161 ui::OzonePlatform::InitializeForUI(params); 163 ui::OzonePlatform::InitializeForUI(params);
162 164
163 // TODO(kylechar): We might not always want a US keyboard layout. 165 // TODO(kylechar): We might not always want a US keyboard layout.
164 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() 166 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()
165 ->SetCurrentLayoutByName("us"); 167 ->SetCurrentLayoutByName("us");
166 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); 168 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create();
167 ui::ClientNativePixmapFactory::SetInstance( 169 ui::ClientNativePixmapFactory::SetInstance(
168 client_native_pixmap_factory_.get()); 170 client_native_pixmap_factory_.get());
169 171
(...skipping 14 matching lines...) Expand all
184 186
185 // Gpu must be running before the PlatformScreen can be initialized. 187 // Gpu must be running before the PlatformScreen can be initialized.
186 window_server_.reset(new ws::WindowServer(this)); 188 window_server_.reset(new ws::WindowServer(this));
187 189
188 // DeviceDataManager must be initialized before TouchController. On non-Linux 190 // DeviceDataManager must be initialized before TouchController. On non-Linux
189 // platforms there is no DeviceDataManager so don't create touch controller. 191 // platforms there is no DeviceDataManager so don't create touch controller.
190 if (ui::DeviceDataManager::HasInstance()) 192 if (ui::DeviceDataManager::HasInstance())
191 touch_controller_.reset( 193 touch_controller_.reset(
192 new ws::TouchController(window_server_->display_manager())); 194 new ws::TouchController(window_server_->display_manager()));
193 195
194 ime_server_.Init(connector()); 196 ime_server_.Init(context->connector());
195 } 197 }
196 198
197 bool Service::OnConnect(const service_manager::ServiceInfo& remote_info, 199 bool Service::OnConnect(const service_manager::ServiceInfo& remote_info,
198 service_manager::InterfaceRegistry* registry) { 200 service_manager::InterfaceRegistry* registry) {
199 registry->AddInterface<mojom::AccessibilityManager>(this); 201 registry->AddInterface<mojom::AccessibilityManager>(this);
200 registry->AddInterface<mojom::Clipboard>(this); 202 registry->AddInterface<mojom::Clipboard>(this);
201 registry->AddInterface<mojom::DisplayManager>(this); 203 registry->AddInterface<mojom::DisplayManager>(this);
202 registry->AddInterface<mojom::GpuService>(this); 204 registry->AddInterface<mojom::GpuService>(this);
203 registry->AddInterface<mojom::IMERegistrar>(this); 205 registry->AddInterface<mojom::IMERegistrar>(this);
204 registry->AddInterface<mojom::IMEServer>(this); 206 registry->AddInterface<mojom::IMEServer>(this);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 mojom::WindowServerTestRequest request) { 362 mojom::WindowServerTestRequest request) {
361 if (!test_config_) 363 if (!test_config_)
362 return; 364 return;
363 mojo::MakeStrongBinding( 365 mojo::MakeStrongBinding(
364 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), 366 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()),
365 std::move(request)); 367 std::move(request));
366 } 368 }
367 369
368 370
369 } // namespace ui 371 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/service.h ('k') | services/ui/test_wm/test_wm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698