mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #375 from abarth/cleanup_startup
Refactor common startup code into shell.cc
This commit is contained in:
commit
c5dca7ba60
@ -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())));
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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<base::MessageLoopForUI> main_message_loop(
|
||||
new base::MessageLoopForUI());
|
||||
scoped_ptr<base::MessageLoopForUI> 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
|
||||
|
||||
|
||||
@ -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<ServiceProviderContext> service_provider_context) {
|
||||
CHECK(base::i18n::InitializeICU());
|
||||
#if !defined(OS_LINUX)
|
||||
CHECK(gfx::GLSurface::InitializeOneOff());
|
||||
#endif
|
||||
g_shell = new Shell(service_provider_context.Pass());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user