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

Side by Side Diff: services/service_manager/standalone/context.cc

Issue 2440903002: Make "all user" services work when packaged. (Closed)
Patch Set: Addressed latest comments and synced. 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/service_manager/service_manager.cc ('k') | services/service_manager/switches.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_manager/standalone/context.h" 5 #include "services/service_manager/standalone/context.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 std::unique_ptr<ServiceOverrides> service_overrides = 175 std::unique_ptr<ServiceOverrides> service_overrides =
176 base::MakeUnique<ServiceOverrides>(std::move(contents)); 176 base::MakeUnique<ServiceOverrides>(std::move(contents));
177 for (const auto& iter : service_overrides->entries()) { 177 for (const auto& iter : service_overrides->entries()) {
178 if (!iter.second.package_name.empty()) 178 if (!iter.second.package_name.empty())
179 catalog_->OverridePackageName(iter.first, iter.second.package_name); 179 catalog_->OverridePackageName(iter.first, iter.second.package_name);
180 } 180 }
181 service_manager_->SetServiceOverrides(std::move(service_overrides)); 181 service_manager_->SetServiceOverrides(std::move(service_overrides));
182 } 182 }
183 } 183 }
184 184
185 bool enable_stats_collection_bindings =
186 command_line.HasSwitch(tracing::kEnableStatsCollectionBindings);
185 187
186 Identity source_identity = CreateServiceManagerIdentity(); 188 if (enable_stats_collection_bindings ||
187 Identity tracing_identity("service:tracing", mojom::kRootUserID); 189 command_line.HasSwitch(switches::kEnableTracing)) {
188 tracing::mojom::FactoryPtr factory; 190 Identity source_identity = CreateServiceManagerIdentity();
189 ConnectToInterface(service_manager(), source_identity, tracing_identity, 191 Identity tracing_identity("service:tracing", mojom::kRootUserID);
190 &factory); 192 tracing::mojom::FactoryPtr factory;
191 provider_.InitializeWithFactory(&factory); 193 ConnectToInterface(service_manager(), source_identity, tracing_identity,
194 &factory);
195 provider_.InitializeWithFactory(&factory);
192 196
193 if (command_line.HasSwitch(tracing::kTraceStartup)) { 197 if (command_line.HasSwitch(tracing::kTraceStartup)) {
194 tracing::mojom::CollectorPtr coordinator; 198 tracing::mojom::CollectorPtr coordinator;
195 ConnectToInterface(service_manager(), source_identity, tracing_identity, 199 ConnectToInterface(service_manager(), source_identity, tracing_identity,
196 &coordinator); 200 &coordinator);
197 tracer_.StartCollectingFromTracingService(std::move(coordinator)); 201 tracer_.StartCollectingFromTracingService(std::move(coordinator));
198 } 202 }
199 203
200 // Record the service manager startup metrics used for performance testing. 204 // Record the service manager startup metrics used for performance testing.
201 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 205 if (enable_stats_collection_bindings) {
202 tracing::kEnableStatsCollectionBindings)) { 206 tracing::mojom::StartupPerformanceDataCollectorPtr collector;
203 tracing::mojom::StartupPerformanceDataCollectorPtr collector; 207 ConnectToInterface(service_manager(), source_identity, tracing_identity,
204 ConnectToInterface(service_manager(), source_identity, tracing_identity, 208 &collector);
205 &collector);
206 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) 209 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)
207 // CurrentProcessInfo::CreationTime is only defined on some platforms. 210 // CurrentProcessInfo::CreationTime is only defined on some platforms.
208 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); 211 const base::Time creation_time = base::CurrentProcessInfo::CreationTime();
209 collector->SetServiceManagerProcessCreationTime( 212 collector->SetServiceManagerProcessCreationTime(
210 creation_time.ToInternalValue()); 213 creation_time.ToInternalValue());
211 #endif 214 #endif
212 collector->SetServiceManagerMainEntryPointTime( 215 collector->SetServiceManagerMainEntryPointTime(
213 main_entry_time_.ToInternalValue()); 216 main_entry_time_.ToInternalValue());
217 }
214 } 218 }
215 } 219 }
216 220
217 void Context::Shutdown() { 221 void Context::Shutdown() {
218 // Actions triggered by Service Manager's destructor may require a current 222 // Actions triggered by Service Manager's destructor may require a current
219 // message loop, 223 // message loop,
220 // so we should destruct it explicitly now as ~Context() occurs post message 224 // so we should destruct it explicitly now as ~Context() occurs post message
221 // loop shutdown. 225 // loop shutdown.
222 service_manager_.reset(); 226 service_manager_.reset();
223 227
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 mojom::InterfaceProviderPtr local_interfaces; 267 mojom::InterfaceProviderPtr local_interfaces;
264 268
265 std::unique_ptr<ConnectParams> params(new ConnectParams); 269 std::unique_ptr<ConnectParams> params(new ConnectParams);
266 params->set_source(CreateServiceManagerIdentity()); 270 params->set_source(CreateServiceManagerIdentity());
267 params->set_target(Identity(name, mojom::kRootUserID)); 271 params->set_target(Identity(name, mojom::kRootUserID));
268 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); 272 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces));
269 service_manager_->Connect(std::move(params)); 273 service_manager_->Connect(std::move(params));
270 } 274 }
271 275
272 } // namespace service_manager 276 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/service_manager.cc ('k') | services/service_manager/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698