| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 if (!base::StringToUint(port_str, &port) || port > 65535) { | 186 if (!base::StringToUint(port_str, &port) || port > 65535) { |
| 187 LOG(ERROR) << "Invalid value for switch " | 187 LOG(ERROR) << "Invalid value for switch " |
| 188 << devtools_service::kRemoteDebuggingPort << ": '" << port_str | 188 << devtools_service::kRemoteDebuggingPort << ": '" << port_str |
| 189 << "' is not a valid port number."; | 189 << "' is not a valid port number."; |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 ServiceProviderPtr devtools_service_provider; | 193 ServiceProviderPtr devtools_service_provider; |
| 194 URLRequestPtr request(URLRequest::New()); | 194 URLRequestPtr request(URLRequest::New()); |
| 195 request->url = "mojo:devtools_service"; | 195 request->url = "mojo:devtools_service"; |
| 196 manager->ConnectToApplication( | 196 manager->ConnectToApplication(nullptr, request.Pass(), std::string(), |
| 197 nullptr, request.Pass(), std::string(), GURL("mojo:shell"), | 197 GURL("mojo:shell"), |
| 198 GetProxy(&devtools_service_provider), nullptr, | 198 GetProxy(&devtools_service_provider), nullptr, |
| 199 shell::GetPermissiveCapabilityFilter(), base::Closure()); | 199 shell::GetPermissiveCapabilityFilter(), |
| 200 base::Closure(), shell::EmptyConnectCallback()); |
| 200 | 201 |
| 201 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; | 202 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; |
| 202 devtools_service_provider->ConnectToService( | 203 devtools_service_provider->ConnectToService( |
| 203 devtools_service::DevToolsCoordinator::Name_, | 204 devtools_service::DevToolsCoordinator::Name_, |
| 204 GetProxy(&devtools_coordinator).PassMessagePipe()); | 205 GetProxy(&devtools_coordinator).PassMessagePipe()); |
| 205 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); | 206 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); |
| 206 } | 207 } |
| 207 | 208 |
| 208 class TracingServiceProvider : public ServiceProvider { | 209 class TracingServiceProvider : public ServiceProvider { |
| 209 public: | 210 public: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 InitNativeOptions(&application_manager_, command_line); | 308 InitNativeOptions(&application_manager_, command_line); |
| 308 | 309 |
| 309 ServiceProviderPtr service_provider_ptr; | 310 ServiceProviderPtr service_provider_ptr; |
| 310 ServiceProviderPtr tracing_service_provider_ptr; | 311 ServiceProviderPtr tracing_service_provider_ptr; |
| 311 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 312 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
| 312 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 313 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 313 request->url = mojo::String::From("mojo:tracing"); | 314 request->url = mojo::String::From("mojo:tracing"); |
| 314 application_manager_.ConnectToApplication( | 315 application_manager_.ConnectToApplication( |
| 315 nullptr, request.Pass(), std::string(), GURL(), | 316 nullptr, request.Pass(), std::string(), GURL(), |
| 316 GetProxy(&service_provider_ptr), tracing_service_provider_ptr.Pass(), | 317 GetProxy(&service_provider_ptr), tracing_service_provider_ptr.Pass(), |
| 317 shell::GetPermissiveCapabilityFilter(), base::Closure()); | 318 shell::GetPermissiveCapabilityFilter(), base::Closure(), |
| 319 shell::EmptyConnectCallback()); |
| 318 | 320 |
| 319 // Record the shell startup metrics used for performance testing. | 321 // Record the shell startup metrics used for performance testing. |
| 320 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 322 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 321 tracing::kEnableStatsCollectionBindings)) { | 323 tracing::kEnableStatsCollectionBindings)) { |
| 322 tracing::StartupPerformanceDataCollectorPtr collector; | 324 tracing::StartupPerformanceDataCollectorPtr collector; |
| 323 service_provider_ptr->ConnectToService( | 325 service_provider_ptr->ConnectToService( |
| 324 tracing::StartupPerformanceDataCollector::Name_, | 326 tracing::StartupPerformanceDataCollector::Name_, |
| 325 GetProxy(&collector).PassMessagePipe()); | 327 GetProxy(&collector).PassMessagePipe()); |
| 326 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 328 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
| 327 // CurrentProcessInfo::CreationTime is only defined on some platforms. | 329 // CurrentProcessInfo::CreationTime is only defined on some platforms. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 DCHECK(app_complete_callback_.is_null()); | 376 DCHECK(app_complete_callback_.is_null()); |
| 375 ServiceProviderPtr services; | 377 ServiceProviderPtr services; |
| 376 ServiceProviderPtr exposed_services; | 378 ServiceProviderPtr exposed_services; |
| 377 | 379 |
| 378 app_urls_.insert(url); | 380 app_urls_.insert(url); |
| 379 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 381 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 380 request->url = mojo::String::From(url.spec()); | 382 request->url = mojo::String::From(url.spec()); |
| 381 application_manager_.ConnectToApplication( | 383 application_manager_.ConnectToApplication( |
| 382 nullptr, request.Pass(), std::string(), GURL(), GetProxy(&services), | 384 nullptr, request.Pass(), std::string(), GURL(), GetProxy(&services), |
| 383 exposed_services.Pass(), shell::GetPermissiveCapabilityFilter(), | 385 exposed_services.Pass(), shell::GetPermissiveCapabilityFilter(), |
| 384 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | 386 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url), |
| 387 shell::EmptyConnectCallback()); |
| 385 } | 388 } |
| 386 | 389 |
| 387 void Context::RunCommandLineApplication(const base::Closure& callback) { | 390 void Context::RunCommandLineApplication(const base::Closure& callback) { |
| 388 DCHECK(app_urls_.empty()); | 391 DCHECK(app_urls_.empty()); |
| 389 DCHECK(app_complete_callback_.is_null()); | 392 DCHECK(app_complete_callback_.is_null()); |
| 390 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 393 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 391 base::CommandLine::StringVector args = command_line->GetArgs(); | 394 base::CommandLine::StringVector args = command_line->GetArgs(); |
| 392 for (size_t i = 0; i < args.size(); ++i) { | 395 for (size_t i = 0; i < args.size(); ++i) { |
| 393 GURL possible_app(args[i]); | 396 GURL possible_app(args[i]); |
| 394 if (possible_app.SchemeIs("mojo")) { | 397 if (possible_app.SchemeIs("mojo")) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 409 base::MessageLoop::current()->Quit(); | 412 base::MessageLoop::current()->Quit(); |
| 410 } else { | 413 } else { |
| 411 app_complete_callback_.Run(); | 414 app_complete_callback_.Run(); |
| 412 } | 415 } |
| 413 } | 416 } |
| 414 } | 417 } |
| 415 } | 418 } |
| 416 | 419 |
| 417 } // namespace runner | 420 } // namespace runner |
| 418 } // namespace mojo | 421 } // namespace mojo |
| OLD | NEW |