From f4e359f19d763a77e26ddd6b1e84db0ae4687c82 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 30 Jul 2015 10:53:23 -0700 Subject: [PATCH] Refactor common startup code into shell.cc Also, make the initialization order the same on every platform. --- sky/shell/android/sky_main.cc | 5 ----- sky/shell/linux/main.cc | 5 ++--- sky/shell/mac/platform_mac.mm | 21 ++++++--------------- sky/shell/shell.cc | 6 ++++++ 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/sky/shell/android/sky_main.cc b/sky/shell/android/sky_main.cc index 98118282d..0712c369e 100644 --- a/sky/shell/android/sky_main.cc +++ b/sky/shell/android/sky_main.cc @@ -10,7 +10,6 @@ #include "base/at_exit.h" #include "base/bind.h" #include "base/command_line.h" -#include "base/i18n/icu_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/macros.h" @@ -20,7 +19,6 @@ #include "jni/SkyMain_jni.h" #include "sky/shell/service_provider.h" #include "sky/shell/shell.h" -#include "ui/gl/gl_surface_egl.h" using base::LazyInstance; @@ -55,9 +53,6 @@ static void Init(JNIEnv* env, jclass clazz, jobject context) { g_java_message_loop.Get().reset(new base::MessageLoopForUI); base::MessageLoopForUI::current()->Start(); - base::i18n::InitializeICU(); - gfx::GLSurface::InitializeOneOff(); - Shell::Init(make_scoped_ptr(new ServiceProviderContext( g_java_message_loop.Get()->task_runner()))); } diff --git a/sky/shell/linux/main.cc b/sky/shell/linux/main.cc index 06759977a..66446c99a 100644 --- a/sky/shell/linux/main.cc +++ b/sky/shell/linux/main.cc @@ -36,8 +36,6 @@ void Init() { blink::WebRuntimeFeatures::enableObservatory( !command_line.HasSwitch(switches::kNonInteractive)); - Shell::Init(make_scoped_ptr(new ServiceProviderContext( - base::MessageLoop::current()->task_runner()))); // Explicitly boot the shared test runner. TestRunner& runner = TestRunner::Shared(); @@ -80,7 +78,8 @@ int main(int argc, const char* argv[]) { base::MessageLoop message_loop; - base::i18n::InitializeICU(); + sky::shell::Shell::Init(make_scoped_ptr( + new sky::shell::ServiceProviderContext(message_loop.task_runner()))); message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); message_loop.Run(); diff --git a/sky/shell/mac/platform_mac.mm b/sky/shell/mac/platform_mac.mm index 2b6d6e897..47bf328b2 100644 --- a/sky/shell/mac/platform_mac.mm +++ b/sky/shell/mac/platform_mac.mm @@ -45,38 +45,29 @@ int PlatformMacMain(int argc, RedirectIOConnectionsToSyslog(); - auto result = false; + bool result = false; result = base::CommandLine::Init(argc, argv); DLOG_ASSERT(result); InitializeLogging(); - result = base::i18n::InitializeICU(); - DLOG_ASSERT(result); - - result = gfx::GLSurface::InitializeOneOff(); - DLOG_ASSERT(result); - - scoped_ptr main_message_loop( - new base::MessageLoopForUI()); + scoped_ptr message_loop(new base::MessageLoopForUI()); #if TARGET_OS_IPHONE // One cannot start the message loop on the platform main thread. Instead, // we attach to the CFRunLoop - main_message_loop->Attach(); + message_loop->Attach(); #endif - auto service_provider_context = make_scoped_ptr( - new sky::shell::ServiceProviderContext(main_message_loop->task_runner())); - - sky::shell::Shell::Init(service_provider_context.Pass()); + sky::shell::Shell::Init(make_scoped_ptr( + new sky::shell::ServiceProviderContext(message_loop->task_runner())); result = callback(); #if !TARGET_OS_IPHONE if (result == EXIT_SUCCESS) { - main_message_loop->QuitNow(); + message_loop->QuitNow(); } #endif diff --git a/sky/shell/shell.cc b/sky/shell/shell.cc index 1147b3ee1..45db55a65 100644 --- a/sky/shell/shell.cc +++ b/sky/shell/shell.cc @@ -5,11 +5,13 @@ #include "sky/shell/shell.h" #include "base/bind.h" +#include "base/i18n/icu_util.h" #include "base/single_thread_task_runner.h" #include "mojo/common/message_pump_mojo.h" #include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/simple_platform_support.h" #include "sky/shell/ui/engine.h" +#include "ui/gl/gl_surface.h" namespace sky { namespace shell { @@ -45,6 +47,10 @@ Shell::~Shell() { } void Shell::Init(scoped_ptr service_provider_context) { + CHECK(base::i18n::InitializeICU()); +#if !defined(OS_LINUX) + CHECK(gfx::GLSurface::InitializeOneOff()); +#endif g_shell = new Shell(service_provider_context.Pass()); } -- GitLab