| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (!base::StringToUint(port_str, &port) || port > 65535) { | 118 if (!base::StringToUint(port_str, &port) || port > 65535) { |
| 119 LOG(ERROR) << "Invalid value for switch " | 119 LOG(ERROR) << "Invalid value for switch " |
| 120 << devtools_service::kRemoteDebuggingPort << ": '" << port_str | 120 << devtools_service::kRemoteDebuggingPort << ": '" << port_str |
| 121 << "' is not a valid port number."; | 121 << "' is not a valid port number."; |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 | 124 |
| 125 ServiceProviderPtr devtools_service_provider; | 125 ServiceProviderPtr devtools_service_provider; |
| 126 scoped_ptr<shell::ConnectToApplicationParams> params( | 126 scoped_ptr<shell::ConnectToApplicationParams> params( |
| 127 new shell::ConnectToApplicationParams); | 127 new shell::ConnectToApplicationParams); |
| 128 params->set_source(shell::Identity(GURL("mojo:shell"))); | 128 params->set_originator_identity(shell::Identity(GURL("mojo:shell"))); |
| 129 params->SetTargetURL(GURL("mojo:devtools_service")); | 129 params->set_originator_filter(shell::GetPermissiveCapabilityFilter()); |
| 130 params->SetURLInfo(GURL("mojo:devtools_service")); |
| 130 params->set_services(GetProxy(&devtools_service_provider)); | 131 params->set_services(GetProxy(&devtools_service_provider)); |
| 132 params->set_filter(shell::GetPermissiveCapabilityFilter()); |
| 131 manager->ConnectToApplication(params.Pass()); | 133 manager->ConnectToApplication(params.Pass()); |
| 132 | 134 |
| 133 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; | 135 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; |
| 134 devtools_service_provider->ConnectToService( | 136 devtools_service_provider->ConnectToService( |
| 135 devtools_service::DevToolsCoordinator::Name_, | 137 devtools_service::DevToolsCoordinator::Name_, |
| 136 GetProxy(&devtools_coordinator).PassMessagePipe()); | 138 GetProxy(&devtools_coordinator).PassMessagePipe()); |
| 137 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); | 139 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); |
| 138 } | 140 } |
| 139 | 141 |
| 140 class TracingServiceProvider : public ServiceProvider { | 142 class TracingServiceProvider : public ServiceProvider { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (command_line.HasSwitch(switches::kEnableMultiprocess)) | 200 if (command_line.HasSwitch(switches::kEnableMultiprocess)) |
| 199 runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); | 201 runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); |
| 200 else | 202 else |
| 201 runner_factory.reset(new InProcessNativeRunnerFactory(this)); | 203 runner_factory.reset(new InProcessNativeRunnerFactory(this)); |
| 202 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); | 204 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); |
| 203 application_manager_->set_native_runner_factory(runner_factory.Pass()); | 205 application_manager_->set_native_runner_factory(runner_factory.Pass()); |
| 204 | 206 |
| 205 ServiceProviderPtr service_provider_ptr; | 207 ServiceProviderPtr service_provider_ptr; |
| 206 ServiceProviderPtr tracing_service_provider_ptr; | 208 ServiceProviderPtr tracing_service_provider_ptr; |
| 207 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 209 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
| 210 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 211 request->url = mojo::String::From("mojo:tracing"); |
| 208 | 212 |
| 209 scoped_ptr<shell::ConnectToApplicationParams> params( | 213 scoped_ptr<shell::ConnectToApplicationParams> params( |
| 210 new shell::ConnectToApplicationParams); | 214 new shell::ConnectToApplicationParams); |
| 211 params->SetTargetURL(GURL("mojo:tracing")); | 215 params->SetURLInfo(request.Pass()); |
| 212 params->set_services(GetProxy(&service_provider_ptr)); | 216 params->set_services(GetProxy(&service_provider_ptr)); |
| 213 params->set_exposed_services(tracing_service_provider_ptr.Pass()); | 217 params->set_exposed_services(tracing_service_provider_ptr.Pass()); |
| 218 params->set_filter(shell::GetPermissiveCapabilityFilter()); |
| 214 application_manager_->ConnectToApplication(params.Pass()); | 219 application_manager_->ConnectToApplication(params.Pass()); |
| 215 | 220 |
| 216 // Record the shell startup metrics used for performance testing. | 221 // Record the shell startup metrics used for performance testing. |
| 217 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 222 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 218 tracing::kEnableStatsCollectionBindings)) { | 223 tracing::kEnableStatsCollectionBindings)) { |
| 219 tracing::StartupPerformanceDataCollectorPtr collector; | 224 tracing::StartupPerformanceDataCollectorPtr collector; |
| 220 service_provider_ptr->ConnectToService( | 225 service_provider_ptr->ConnectToService( |
| 221 tracing::StartupPerformanceDataCollector::Name_, | 226 tracing::StartupPerformanceDataCollector::Name_, |
| 222 GetProxy(&collector).PassMessagePipe()); | 227 GetProxy(&collector).PassMessagePipe()); |
| 223 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 228 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 252 task_runners_->shell_runner()); | 257 task_runners_->shell_runner()); |
| 253 base::MessageLoop::current()->Quit(); | 258 base::MessageLoop::current()->Quit(); |
| 254 } | 259 } |
| 255 | 260 |
| 256 void Context::Run(const GURL& url) { | 261 void Context::Run(const GURL& url) { |
| 257 DCHECK(app_complete_callback_.is_null()); | 262 DCHECK(app_complete_callback_.is_null()); |
| 258 ServiceProviderPtr services; | 263 ServiceProviderPtr services; |
| 259 ServiceProviderPtr exposed_services; | 264 ServiceProviderPtr exposed_services; |
| 260 | 265 |
| 261 app_urls_.insert(url); | 266 app_urls_.insert(url); |
| 267 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 268 request->url = mojo::String::From(url.spec()); |
| 262 | 269 |
| 263 scoped_ptr<shell::ConnectToApplicationParams> params( | 270 scoped_ptr<shell::ConnectToApplicationParams> params( |
| 264 new shell::ConnectToApplicationParams); | 271 new shell::ConnectToApplicationParams); |
| 265 params->SetTargetURL(url); | 272 params->SetURLInfo(request.Pass()); |
| 266 params->set_services(GetProxy(&services)); | 273 params->set_services(GetProxy(&services)); |
| 267 params->set_exposed_services(exposed_services.Pass()); | 274 params->set_exposed_services(exposed_services.Pass()); |
| 275 params->set_filter(shell::GetPermissiveCapabilityFilter()); |
| 268 params->set_on_application_end( | 276 params->set_on_application_end( |
| 269 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | 277 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
| 270 application_manager_->ConnectToApplication(params.Pass()); | 278 application_manager_->ConnectToApplication(params.Pass()); |
| 271 } | 279 } |
| 272 | 280 |
| 273 void Context::RunCommandLineApplication(const base::Closure& callback) { | 281 void Context::RunCommandLineApplication(const base::Closure& callback) { |
| 274 DCHECK(app_urls_.empty()); | 282 DCHECK(app_urls_.empty()); |
| 275 DCHECK(app_complete_callback_.is_null()); | 283 DCHECK(app_complete_callback_.is_null()); |
| 276 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 284 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 277 base::CommandLine::StringVector args = command_line->GetArgs(); | 285 base::CommandLine::StringVector args = command_line->GetArgs(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 295 base::MessageLoop::current()->Quit(); | 303 base::MessageLoop::current()->Quit(); |
| 296 } else { | 304 } else { |
| 297 app_complete_callback_.Run(); | 305 app_complete_callback_.Run(); |
| 298 } | 306 } |
| 299 } | 307 } |
| 300 } | 308 } |
| 301 } | 309 } |
| 302 | 310 |
| 303 } // namespace runner | 311 } // namespace runner |
| 304 } // namespace mojo | 312 } // namespace mojo |
| OLD | NEW |