提交 d7f807c9 编写于 作者: A Adam Barth 提交者: GitHub

Factor runtime initialization into InitRuntime (#3009)

This makes the code easier to share between Fuchsia and stand-alone
Flutter.
上级 737afe9b
......@@ -10,7 +10,7 @@
#include "flutter/common/settings.h"
#include "flutter/common/threads.h"
#include "flutter/content_handler/content_handler_impl.h"
#include "flutter/runtime/dart_init.h"
#include "flutter/runtime/runtime_init.h"
#include "lib/ftl/macros.h"
#include "lib/ftl/tasks/task_runner.h"
#include "lib/mtl/tasks/message_loop.h"
......@@ -53,7 +53,7 @@ class App : public mojo::ApplicationImplBase {
blink::Threads::Set(
blink::Threads(gpu_task_runner, ui_task_runner, io_task_runner));
blink::Settings::Set(blink::Settings());
blink::InitDartVM();
blink::InitRuntime();
}
bool OnAcceptConnection(
......
......@@ -48,10 +48,14 @@ source_set("runtime") {
"dart_service_isolate.h",
"embedder_resources.cc",
"embedder_resources.h",
"platform_impl.cc",
"platform_impl.h",
"runtime_controller.cc",
"runtime_controller.h",
"runtime_delegate.cc",
"runtime_delegate.h",
"runtime_init.cc",
"runtime_init.h",
"start_up.cc",
"start_up.h",
]
......
......@@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/sky/shell/ui/platform_impl.h"
#include "flutter/runtime/platform_impl.h"
#include "flutter/sky/shell/shell.h"
namespace sky {
namespace shell {
namespace blink {
PlatformImpl::PlatformImpl() {}
......@@ -17,5 +14,4 @@ std::string PlatformImpl::defaultLocale() {
return "en-US";
}
} // namespace shell
} // namespace sky
} // namespace blink
......@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_UI_PLATFORM_IMPL_H_
#define SKY_SHELL_UI_PLATFORM_IMPL_H_
#ifndef FLUTTER_RUNTIME_PLATFORM_IMPL_H_
#define FLUTTER_RUNTIME_PLATFORM_IMPL_H_
#include "lib/ftl/macros.h"
#include "flutter/sky/engine/public/platform/Platform.h"
namespace sky {
namespace shell {
namespace blink {
class PlatformImpl : public blink::Platform {
class PlatformImpl : public Platform {
public:
explicit PlatformImpl();
~PlatformImpl() override;
......@@ -23,7 +22,6 @@ class PlatformImpl : public blink::Platform {
FTL_DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
};
} // namespace shell
} // namespace sky
} // namespace blink
#endif // SKY_SHELL_UI_PLATFORM_IMPL_H_
#endif // FLUTTER_RUNTIME_PLATFORM_IMPL_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/runtime/runtime_init.h"
#include "flutter/glue/trace_event.h"
#include "flutter/runtime/dart_init.h"
#include "flutter/runtime/platform_impl.h"
#include "flutter/sky/engine/public/web/Sky.h"
#include "lib/ftl/logging.h"
namespace blink {
namespace {
PlatformImpl* g_platform_impl = nullptr;
} // namespace
void InitRuntime() {
TRACE_EVENT0("flutter", "InitRuntime");
FTL_CHECK(!g_platform_impl);
g_platform_impl = new PlatformImpl();
InitEngine(g_platform_impl);
InitDartVM();
}
} // namespace blink
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_RUNTIME_RUNTIME_INIT_H_
#define FLUTTER_RUNTIME_RUNTIME_INIT_H_
namespace blink {
void InitRuntime();
} // namespace blink
#endif // FLUTTER_RUNTIME_RUNTIME_INIT_H_
......@@ -38,14 +38,14 @@ namespace blink {
// Must be called on the thread that will be the main WebKit thread before
// using any other WebKit APIs. The provided Platform; must be
// non-null and must remain valid until the current thread calls shutdown.
BLINK_EXPORT void initialize(Platform*);
BLINK_EXPORT void InitEngine(Platform*);
// Once shutdown, the Platform passed to initialize will no longer
// be accessed. No other WebKit objects should be in use when this function is
// called. Any background threads created by WebKit are promised to be
// terminated by the time this function returns.
BLINK_EXPORT void shutdown();
BLINK_EXPORT void ShutdownEngine();
} // namespace blink
} // namespace blink
#endif // SKY_ENGINE_PUBLIC_WEB_SKY_H_
......@@ -112,8 +112,8 @@ void removeMessageLoopObservers() {
// Doing so may cause hard to reproduce crashes.
static bool s_webKitInitialized = false;
void initialize(Platform* platform) {
TRACE_EVENT0("flutter", "blink::initialize");
void InitEngine(Platform* platform) {
TRACE_EVENT0("flutter", "InitEngine");
ASSERT(!s_webKitInitialized);
s_webKitInitialized = true;
......@@ -141,7 +141,7 @@ void initialize(Platform* platform) {
#endif
}
void shutdown() {
void ShutdownEngine() {
#if !defined(OS_FUCHSIA)
removeMessageLoopObservers();
#endif
......
......@@ -40,8 +40,6 @@ source_set("common") {
"ui/engine.h",
"ui/flutter_font_selector.cc",
"ui/flutter_font_selector.h",
"ui/platform_impl.cc",
"ui/platform_impl.h",
"ui_delegate.cc",
"ui_delegate.h",
]
......
......@@ -17,10 +17,10 @@
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/runtime/dart_controller.h"
#include "flutter/runtime/dart_init.h"
#include "flutter/runtime/runtime_init.h"
#include "flutter/sky/engine/public/web/Sky.h"
#include "flutter/sky/shell/ui/animator.h"
#include "flutter/sky/shell/ui/flutter_font_selector.h"
#include "flutter/sky/shell/ui/platform_impl.h"
#include "lib/ftl/files/path.h"
#include "mojo/public/cpp/application/connect.h"
#include "third_party/skia/include/core/SkCanvas.h"
......@@ -46,8 +46,6 @@ std::string FindPackagesPath(const std::string& main_dart) {
return packages_path;
}
PlatformImpl* g_platform_impl = nullptr;
} // namespace
Engine::Engine(Rasterizer* rasterizer)
......@@ -64,12 +62,7 @@ ftl::WeakPtr<Engine> Engine::GetWeakPtr() {
}
void Engine::Init() {
TRACE_EVENT0("flutter", "Engine::Init");
DCHECK(!g_platform_impl);
g_platform_impl = new PlatformImpl();
blink::initialize(g_platform_impl);
blink::InitDartVM();
blink::InitRuntime();
}
void Engine::BeginFrame(ftl::TimePoint frame_time) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册