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

Unified Diff: mojo/shell/android/mojo_main.cc

Issue 420143003: mojo: shell::Context should outlive the shell MessageLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix + verify android Created 6 years, 5 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/android/mojo_main.cc
diff --git a/mojo/shell/android/mojo_main.cc b/mojo/shell/android/mojo_main.cc
index a892317bde2e3393ae77db40d4fda9af07e92b2d..57c329d51470723d73fe71a07afdbb3dc2e3bb2a 100644
--- a/mojo/shell/android/mojo_main.cc
+++ b/mojo/shell/android/mojo_main.cc
@@ -37,11 +37,9 @@ LazyInstance<scoped_ptr<base::android::JavaHandlerThread> > g_shell_thread =
LAZY_INSTANCE_INITIALIZER;
void RunShell(std::vector<GURL> app_urls) {
- shell::Context* shell_context = new shell::Context();
- shell_context->set_ui_loop(g_java_message_loop.Get().get());
-
- g_context.Get().reset(shell_context);
- shell::Run(shell_context, app_urls);
+ g_context.Get()->Init();
+ g_context.Get()->set_ui_loop(g_java_message_loop.Get().get());
+ shell::Run(g_context.Get().get(), app_urls);
}
} // namespace
@@ -54,6 +52,11 @@ static void Init(JNIEnv* env, jclass clazz, jobject context) {
base::CommandLine::Init(0, 0);
mojo::shell::InitializeLogging();
+ // We want ~MessageLoop to happen prior to ~Context. Initializing
+ // LazyInstances is akin to stack-allocating objects; their destructors
+ // will be invoked first-in-last-out.
+ shell::Context* shell_context = new shell::Context();
+ g_context.Get().reset(shell_context);
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
base::MessageLoopForUI::current()->Start();
« no previous file with comments | « mojo/services/window_manager/window_manager_api_unittest.cc ('k') | mojo/shell/child_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698