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

Unified Diff: mojo/shell/context.cc

Issue 491443005: Get rid of KeepAlive. Quit shell when all urls run directly by Context are closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bring back ConnectToServiceViaNetwork Created 6 years, 4 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: mojo/shell/context.cc
diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc
index a733411a18346dd26e8219ee9e05b9ed6c2158de..42d90a3258455b297516726b816d1525e0bc5221 100644
--- a/mojo/shell/context.cc
+++ b/mojo/shell/context.cc
@@ -96,6 +96,14 @@ void InitContentHandlers(DynamicApplicationLoader* loader,
}
}
+class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> {
+ private:
+ virtual void ConnectToService(const mojo::String& service_name,
+ ScopedMessagePipeHandle client_handle)
+ MOJO_OVERRIDE {
+ }
+};
+
} // namespace
class Context::NativeViewportApplicationLoader
@@ -153,7 +161,12 @@ Context::Context() {
DCHECK(!base::MessageLoop::current());
}
+Context::~Context() {
+ DCHECK(!base::MessageLoop::current());
+}
+
void Context::Init() {
+ application_manager_.set_delegate(this);
setup.Get();
task_runners_.reset(
new TaskRunners(base::MessageLoop::current()->message_loop_proxy()));
@@ -229,8 +242,29 @@ void Context::Init() {
#endif
}
-Context::~Context() {
- DCHECK(!base::MessageLoop::current());
+void Context::OnServiceError(const GURL& gurl) {
+ if (app_urls_.find(gurl) != app_urls_.end()) {
+ app_urls_.erase(gurl);
+ if (app_urls_.empty() && base::MessageLoop::current()->is_running())
+ base::MessageLoop::current()->Quit();
+ }
+}
+
+void Context::Run(const GURL& url) {
+ EmptyServiceProvider* sp = new EmptyServiceProvider;
+ ServiceProviderPtr spp;
+ BindToProxy(sp, &spp);
+
+ app_urls_.insert(url);
+ application_manager_.ConnectToApplication(url, GURL(), spp.Pass());
+}
+
+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();
}
} // namespace shell

Powered by Google App Engine
This is Rietveld 408576698