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

Unified Diff: shell/context.cc

Issue 939353002: Fix mojo::shell::Context shutdown. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 0707cefe6e7018d40dd6cbc65ece41096b358dec..c3efa8948069caa457c4d3017e15ce2e2eb8ea51 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -15,6 +15,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/path_service.h"
+#include "base/run_loop.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
@@ -55,8 +56,6 @@ class Setup {
DISALLOW_COPY_AND_ASSIGN(Setup);
};
-static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER;
-
void InitContentHandlers(NativeApplicationLoader* loader,
base::CommandLine* command_line) {
// Default content handlers.
@@ -194,7 +193,9 @@ Context::~Context() {
DCHECK(!base::MessageLoop::current());
}
+// static
void Context::EnsureEmbedderIsInitialized() {
+ static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER;
setup.Get();
}
@@ -276,14 +277,21 @@ bool Context::Init() {
}
void Context::Shutdown() {
+ DCHECK_EQ(base::MessageLoop::current()->task_runner(),
+ task_runners_->shell_runner());
embedder::ShutdownIPCSupport();
+ // We'll quit when we get OnShutdownComplete().
+ 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())
- Shutdown();
+ if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
+ DCHECK_EQ(base::MessageLoop::current()->task_runner(),
+ task_runners_->shell_runner());
+ base::MessageLoop::current()->Quit();
+ }
}
}
« no previous file with comments | « shell/context.h ('k') | shell/desktop/mojo_main.cc » ('j') | shell/desktop/mojo_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698