| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 197 request.Pass(), std::string(), GURL("mojo:shell"), | 197 nullptr, request.Pass(), std::string(), GURL("mojo:shell"), |
| 198 GetProxy(&devtools_service_provider), nullptr, base::Closure()); | 198 GetProxy(&devtools_service_provider), nullptr, nullptr, base::Closure()); |
| 199 | 199 |
| 200 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; | 200 devtools_service::DevToolsCoordinatorPtr devtools_coordinator; |
| 201 devtools_service_provider->ConnectToService( | 201 devtools_service_provider->ConnectToService( |
| 202 devtools_service::DevToolsCoordinator::Name_, | 202 devtools_service::DevToolsCoordinator::Name_, |
| 203 GetProxy(&devtools_coordinator).PassMessagePipe()); | 203 GetProxy(&devtools_coordinator).PassMessagePipe()); |
| 204 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); | 204 devtools_coordinator->Initialize(static_cast<uint16_t>(port)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 class TracingServiceProvider : public ServiceProvider { | 207 class TracingServiceProvider : public ServiceProvider { |
| 208 public: | 208 public: |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 switches::kDisableCache)); | 302 switches::kDisableCache)); |
| 303 | 303 |
| 304 InitContentHandlers(&application_manager_, command_line); | 304 InitContentHandlers(&application_manager_, command_line); |
| 305 InitNativeOptions(&application_manager_, command_line); | 305 InitNativeOptions(&application_manager_, command_line); |
| 306 | 306 |
| 307 ServiceProviderPtr tracing_service_provider_ptr; | 307 ServiceProviderPtr tracing_service_provider_ptr; |
| 308 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 308 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
| 309 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 309 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 310 request->url = mojo::String::From("mojo:tracing"); | 310 request->url = mojo::String::From("mojo:tracing"); |
| 311 application_manager_.ConnectToApplication( | 311 application_manager_.ConnectToApplication( |
| 312 request.Pass(), std::string(), GURL(""), nullptr, | 312 nullptr, request.Pass(), std::string(), GURL(""), nullptr, |
| 313 tracing_service_provider_ptr.Pass(), base::Closure()); | 313 tracing_service_provider_ptr.Pass(), nullptr, base::Closure()); |
| 314 | 314 |
| 315 InitDevToolsServiceIfNeeded(&application_manager_, command_line); | 315 InitDevToolsServiceIfNeeded(&application_manager_, command_line); |
| 316 | 316 |
| 317 return true; | 317 return true; |
| 318 } | 318 } |
| 319 | 319 |
| 320 void Context::Shutdown() { | 320 void Context::Shutdown() { |
| 321 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); | 321 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); |
| 322 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 322 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 323 task_runners_->shell_runner()); | 323 task_runners_->shell_runner()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 348 | 348 |
| 349 void Context::Run(const GURL& url) { | 349 void Context::Run(const GURL& url) { |
| 350 DCHECK(app_complete_callback_.is_null()); | 350 DCHECK(app_complete_callback_.is_null()); |
| 351 ServiceProviderPtr services; | 351 ServiceProviderPtr services; |
| 352 ServiceProviderPtr exposed_services; | 352 ServiceProviderPtr exposed_services; |
| 353 | 353 |
| 354 app_urls_.insert(url); | 354 app_urls_.insert(url); |
| 355 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 355 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 356 request->url = mojo::String::From(url.spec()); | 356 request->url = mojo::String::From(url.spec()); |
| 357 application_manager_.ConnectToApplication( | 357 application_manager_.ConnectToApplication( |
| 358 request.Pass(), std::string(), GURL(), GetProxy(&services), | 358 nullptr, request.Pass(), std::string(), GURL(), GetProxy(&services), |
| 359 exposed_services.Pass(), | 359 exposed_services.Pass(), nullptr, |
| 360 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | 360 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void Context::RunCommandLineApplication(const base::Closure& callback) { | 363 void Context::RunCommandLineApplication(const base::Closure& callback) { |
| 364 DCHECK(app_urls_.empty()); | 364 DCHECK(app_urls_.empty()); |
| 365 DCHECK(app_complete_callback_.is_null()); | 365 DCHECK(app_complete_callback_.is_null()); |
| 366 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 366 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 367 base::CommandLine::StringVector args = command_line->GetArgs(); | 367 base::CommandLine::StringVector args = command_line->GetArgs(); |
| 368 for (size_t i = 0; i < args.size(); ++i) { | 368 for (size_t i = 0; i < args.size(); ++i) { |
| 369 GURL possible_app(args[i]); | 369 GURL possible_app(args[i]); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 385 base::MessageLoop::current()->Quit(); | 385 base::MessageLoop::current()->Quit(); |
| 386 } else { | 386 } else { |
| 387 app_complete_callback_.Run(); | 387 app_complete_callback_.Run(); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 } // namespace runner | 393 } // namespace runner |
| 394 } // namespace mojo | 394 } // namespace mojo |
| OLD | NEW |