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

Side by Side Diff: mojo/runner/context.cc

Issue 1538823002: Convert Pass()→std::move() in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « mojo/runner/child/test_native_main.cc ('k') | mojo/runner/host/child_process.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 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 "mojo/runner/context.h" 5 #include "mojo/runner/context.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/i18n/icu_util.h" 13 #include "base/i18n/icu_util.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/path_service.h" 17 #include "base/path_service.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 135
135 ServiceProviderPtr devtools_service_provider; 136 ServiceProviderPtr devtools_service_provider;
136 scoped_ptr<shell::ConnectToApplicationParams> params( 137 scoped_ptr<shell::ConnectToApplicationParams> params(
137 new shell::ConnectToApplicationParams); 138 new shell::ConnectToApplicationParams);
138 params->set_source(shell::Identity(GURL("mojo:shell"), std::string(), 139 params->set_source(shell::Identity(GURL("mojo:shell"), std::string(),
139 shell::GetPermissiveCapabilityFilter())); 140 shell::GetPermissiveCapabilityFilter()));
140 params->SetTarget(shell::Identity(GURL("mojo:devtools_service"), 141 params->SetTarget(shell::Identity(GURL("mojo:devtools_service"),
141 std::string(), 142 std::string(),
142 shell::GetPermissiveCapabilityFilter())); 143 shell::GetPermissiveCapabilityFilter()));
143 params->set_services(GetProxy(&devtools_service_provider)); 144 params->set_services(GetProxy(&devtools_service_provider));
144 manager->ConnectToApplication(params.Pass()); 145 manager->ConnectToApplication(std::move(params));
145 146
146 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; 147 devtools_service::DevToolsCoordinatorPtr devtools_coordinator;
147 devtools_service_provider->ConnectToService( 148 devtools_service_provider->ConnectToService(
148 devtools_service::DevToolsCoordinator::Name_, 149 devtools_service::DevToolsCoordinator::Name_,
149 GetProxy(&devtools_coordinator).PassMessagePipe()); 150 GetProxy(&devtools_coordinator).PassMessagePipe());
150 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); 151 devtools_coordinator->Initialize(static_cast<uint16_t>(port));
151 } 152 }
152 153
153 class TracingServiceProvider : public ServiceProvider { 154 class TracingServiceProvider : public ServiceProvider {
154 public: 155 public:
155 TracingServiceProvider(Tracer* tracer, 156 TracingServiceProvider(Tracer* tracer,
156 InterfaceRequest<ServiceProvider> request) 157 InterfaceRequest<ServiceProvider> request)
157 : tracer_(tracer), binding_(this, request.Pass()) {} 158 : tracer_(tracer), binding_(this, std::move(request)) {}
158 ~TracingServiceProvider() override {} 159 ~TracingServiceProvider() override {}
159 160
160 void ConnectToService(const mojo::String& service_name, 161 void ConnectToService(const mojo::String& service_name,
161 ScopedMessagePipeHandle client_handle) override { 162 ScopedMessagePipeHandle client_handle) override {
162 if (tracer_ && service_name == tracing::TraceProvider::Name_) { 163 if (tracer_ && service_name == tracing::TraceProvider::Name_) {
163 tracer_->ConnectToProvider( 164 tracer_->ConnectToProvider(
164 MakeRequest<tracing::TraceProvider>(client_handle.Pass())); 165 MakeRequest<tracing::TraceProvider>(std::move(client_handle)));
165 } 166 }
166 } 167 }
167 168
168 private: 169 private:
169 Tracer* tracer_; 170 Tracer* tracer_;
170 StrongBinding<ServiceProvider> binding_; 171 StrongBinding<ServiceProvider> binding_;
171 172
172 DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider); 173 DISALLOW_COPY_AND_ASSIGN(TracingServiceProvider);
173 }; 174 };
174 175
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } else { 227 } else {
227 #if defined(COMPONENT_BUILD) 228 #if defined(COMPONENT_BUILD)
228 LOG(ERROR) << "Running Mojo in single process component build, which isn't " 229 LOG(ERROR) << "Running Mojo in single process component build, which isn't "
229 << "supported because statics in apps interact. Use static build" 230 << "supported because statics in apps interact. Use static build"
230 << " or don't pass --single-process."; 231 << " or don't pass --single-process.";
231 #endif 232 #endif
232 runner_factory.reset( 233 runner_factory.reset(
233 new InProcessNativeRunnerFactory(task_runners_->blocking_pool())); 234 new InProcessNativeRunnerFactory(task_runners_->blocking_pool()));
234 } 235 }
235 application_manager_.reset(new shell::ApplicationManager( 236 application_manager_.reset(new shell::ApplicationManager(
236 make_scoped_ptr(package_manager_), runner_factory.Pass(), 237 make_scoped_ptr(package_manager_), std::move(runner_factory),
237 task_runners_->blocking_pool())); 238 task_runners_->blocking_pool()));
238 239
239 ServiceProviderPtr tracing_services; 240 ServiceProviderPtr tracing_services;
240 ServiceProviderPtr tracing_exposed_services; 241 ServiceProviderPtr tracing_exposed_services;
241 new TracingServiceProvider(&tracer_, GetProxy(&tracing_exposed_services)); 242 new TracingServiceProvider(&tracer_, GetProxy(&tracing_exposed_services));
242 243
243 scoped_ptr<shell::ConnectToApplicationParams> params( 244 scoped_ptr<shell::ConnectToApplicationParams> params(
244 new shell::ConnectToApplicationParams); 245 new shell::ConnectToApplicationParams);
245 params->set_source(shell::Identity(GURL("mojo:shell"), std::string(), 246 params->set_source(shell::Identity(GURL("mojo:shell"), std::string(),
246 shell::GetPermissiveCapabilityFilter())); 247 shell::GetPermissiveCapabilityFilter()));
247 params->SetTarget(shell::Identity(GURL("mojo:tracing"), std::string(), 248 params->SetTarget(shell::Identity(GURL("mojo:tracing"), std::string(),
248 shell::GetPermissiveCapabilityFilter())); 249 shell::GetPermissiveCapabilityFilter()));
249 params->set_services(GetProxy(&tracing_services)); 250 params->set_services(GetProxy(&tracing_services));
250 params->set_exposed_services(tracing_exposed_services.Pass()); 251 params->set_exposed_services(std::move(tracing_exposed_services));
251 application_manager_->ConnectToApplication(params.Pass()); 252 application_manager_->ConnectToApplication(std::move(params));
252 253
253 if (command_line.HasSwitch(tracing::kTraceStartup)) { 254 if (command_line.HasSwitch(tracing::kTraceStartup)) {
254 tracing::TraceCollectorPtr coordinator; 255 tracing::TraceCollectorPtr coordinator;
255 auto coordinator_request = GetProxy(&coordinator); 256 auto coordinator_request = GetProxy(&coordinator);
256 tracing_services->ConnectToService(tracing::TraceCollector::Name_, 257 tracing_services->ConnectToService(tracing::TraceCollector::Name_,
257 coordinator_request.PassMessagePipe()); 258 coordinator_request.PassMessagePipe());
258 tracer_.StartCollectingFromTracingService(coordinator.Pass()); 259 tracer_.StartCollectingFromTracingService(std::move(coordinator));
259 } 260 }
260 261
261 // Record the shell startup metrics used for performance testing. 262 // Record the shell startup metrics used for performance testing.
262 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 263 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
263 tracing::kEnableStatsCollectionBindings)) { 264 tracing::kEnableStatsCollectionBindings)) {
264 tracing::StartupPerformanceDataCollectorPtr collector; 265 tracing::StartupPerformanceDataCollectorPtr collector;
265 tracing_services->ConnectToService( 266 tracing_services->ConnectToService(
266 tracing::StartupPerformanceDataCollector::Name_, 267 tracing::StartupPerformanceDataCollector::Name_,
267 GetProxy(&collector).PassMessagePipe()); 268 GetProxy(&collector).PassMessagePipe());
268 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) 269 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 ServiceProviderPtr services; 306 ServiceProviderPtr services;
306 ServiceProviderPtr exposed_services; 307 ServiceProviderPtr exposed_services;
307 308
308 app_urls_.insert(url); 309 app_urls_.insert(url);
309 310
310 scoped_ptr<shell::ConnectToApplicationParams> params( 311 scoped_ptr<shell::ConnectToApplicationParams> params(
311 new shell::ConnectToApplicationParams); 312 new shell::ConnectToApplicationParams);
312 params->SetTarget(shell::Identity(url, std::string(), 313 params->SetTarget(shell::Identity(url, std::string(),
313 shell::GetPermissiveCapabilityFilter())); 314 shell::GetPermissiveCapabilityFilter()));
314 params->set_services(GetProxy(&services)); 315 params->set_services(GetProxy(&services));
315 params->set_exposed_services(exposed_services.Pass()); 316 params->set_exposed_services(std::move(exposed_services));
316 params->set_on_application_end( 317 params->set_on_application_end(
317 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); 318 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url));
318 application_manager_->ConnectToApplication(params.Pass()); 319 application_manager_->ConnectToApplication(std::move(params));
319 } 320 }
320 321
321 void Context::RunCommandLineApplication(const base::Closure& callback) { 322 void Context::RunCommandLineApplication(const base::Closure& callback) {
322 DCHECK(app_urls_.empty()); 323 DCHECK(app_urls_.empty());
323 DCHECK(app_complete_callback_.is_null()); 324 DCHECK(app_complete_callback_.is_null());
324 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 325 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
325 base::CommandLine::StringVector args = command_line->GetArgs(); 326 base::CommandLine::StringVector args = command_line->GetArgs();
326 for (size_t i = 0; i < args.size(); ++i) { 327 for (size_t i = 0; i < args.size(); ++i) {
327 GURL possible_app(args[i]); 328 GURL possible_app(args[i]);
328 if (possible_app.SchemeIs("mojo")) { 329 if (possible_app.SchemeIs("mojo")) {
(...skipping 14 matching lines...) Expand all
343 base::MessageLoop::current()->QuitWhenIdle(); 344 base::MessageLoop::current()->QuitWhenIdle();
344 } else { 345 } else {
345 app_complete_callback_.Run(); 346 app_complete_callback_.Run();
346 } 347 }
347 } 348 }
348 } 349 }
349 } 350 }
350 351
351 } // namespace runner 352 } // namespace runner
352 } // namespace mojo 353 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/child/test_native_main.cc ('k') | mojo/runner/host/child_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698