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

Unified Diff: shell/context.cc

Issue 983113002: ApplicationManager: Use callback to get notified on application shutdown. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: shell/context.cc
diff --git a/shell/context.cc b/shell/context.cc
index fda814201e392e45fa7f236d35f96aeb507e3dd9..192c4218e6cde6955d46d84f351e74a22576f8f6 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -292,7 +292,7 @@ bool Context::Init() {
new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr));
application_manager_.ConnectToApplication(
GURL("mojo:tracing"), GURL(""), nullptr,
- tracing_service_provider_ptr.Pass());
+ tracing_service_provider_ptr.Pass(), base::Closure());
if (listener_)
listener_->WaitForListening();
@@ -308,17 +308,6 @@ void Context::Shutdown() {
base::MessageLoop::current()->Run();
}
-void Context::OnApplicationError(const GURL& url) {
- if (app_urls_.find(url) != app_urls_.end()) {
- app_urls_.erase(url);
- if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
- DCHECK_EQ(base::MessageLoop::current()->task_runner(),
- task_runners_->shell_runner());
- base::MessageLoop::current()->Quit();
- }
- }
-}
-
GURL Context::ResolveURL(const GURL& url) {
return url_resolver_.ResolveMojoURL(url);
}
@@ -338,17 +327,28 @@ void Context::Run(const GURL& url) {
ServiceProviderPtr exposed_services;
app_urls_.insert(url);
- application_manager_.ConnectToApplication(url, GURL(), GetProxy(&services),
- exposed_services.Pass());
+ application_manager_.ConnectToApplication(
+ url, GURL(), GetProxy(&services), exposed_services.Pass(),
+ base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url));
}
ScopedMessagePipeHandle Context::ConnectToServiceByName(
const GURL& application_url,
const std::string& service_name) {
- app_urls_.insert(application_url);
return application_manager_.ConnectToServiceByName(application_url,
service_name).Pass();
}
+void Context::OnApplicationEnd(const GURL& url) {
+ if (app_urls_.find(url) != app_urls_.end()) {
+ app_urls_.erase(url);
+ if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
+ DCHECK_EQ(base::MessageLoop::current()->task_runner(),
+ task_runners_->shell_runner());
+ base::MessageLoop::current()->Quit();
+ }
+ }
+}
+
} // namespace shell
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698