| 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/shell/context.h" | 5 #include "mojo/shell/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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 void Context::Shutdown() { | 279 void Context::Shutdown() { |
| 280 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); | 280 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); |
| 281 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 281 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 282 task_runners_->shell_runner()); | 282 task_runners_->shell_runner()); |
| 283 embedder::ShutdownIPCSupport(); | 283 embedder::ShutdownIPCSupport(); |
| 284 // We'll quit when we get OnShutdownComplete(). | 284 // We'll quit when we get OnShutdownComplete(). |
| 285 base::MessageLoop::current()->Run(); | 285 base::MessageLoop::current()->Run(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 GURL Context::ResolveURL(const GURL& url) { | |
| 289 return url_resolver_.ResolveMojoURL(url); | |
| 290 } | |
| 291 | |
| 292 GURL Context::ResolveMappings(const GURL& url) { | 288 GURL Context::ResolveMappings(const GURL& url) { |
| 293 return url_resolver_.ApplyMappings(url); | 289 return url_resolver_.ApplyMappings(url); |
| 294 } | 290 } |
| 295 | 291 |
| 292 GURL Context::ResolveMojoURL(const GURL& url) { |
| 293 return url_resolver_.ResolveMojoURL(url); |
| 294 } |
| 295 |
| 296 void Context::OnShutdownComplete() { | 296 void Context::OnShutdownComplete() { |
| 297 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 297 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 298 task_runners_->shell_runner()); | 298 task_runners_->shell_runner()); |
| 299 base::MessageLoop::current()->Quit(); | 299 base::MessageLoop::current()->Quit(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void Context::Run(const GURL& url) { | 302 void Context::Run(const GURL& url) { |
| 303 ServiceProviderPtr services; | 303 ServiceProviderPtr services; |
| 304 ServiceProviderPtr exposed_services; | 304 ServiceProviderPtr exposed_services; |
| 305 | 305 |
| 306 app_urls_.insert(url); | 306 app_urls_.insert(url); |
| 307 application_manager_.ConnectToApplication( | 307 application_manager_.ConnectToApplication( |
| 308 url, GURL(), GetProxy(&services), exposed_services.Pass(), | 308 url, GURL(), GetProxy(&services), exposed_services.Pass(), |
| 309 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | 309 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void Context::OnApplicationEnd(const GURL& url) { | 312 void Context::OnApplicationEnd(const GURL& url) { |
| 313 if (app_urls_.find(url) != app_urls_.end()) { | 313 if (app_urls_.find(url) != app_urls_.end()) { |
| 314 app_urls_.erase(url); | 314 app_urls_.erase(url); |
| 315 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 315 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
| 316 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 316 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 317 task_runners_->shell_runner()); | 317 task_runners_->shell_runner()); |
| 318 base::MessageLoop::current()->Quit(); | 318 base::MessageLoop::current()->Quit(); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace shell | 323 } // namespace shell |
| 324 } // namespace mojo | 324 } // namespace mojo |
| OLD | NEW |