Factor runtime initialization into InitRuntime (flutter/engine#3009)
This makes the code easier to share between Fuchsia and stand-alone Flutter.
This commit is contained in:
@@ -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",
|
||||
]
|
||||
|
||||
17
engine/src/flutter/runtime/platform_impl.cc
Normal file
17
engine/src/flutter/runtime/platform_impl.cc
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright 2015 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/platform_impl.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
PlatformImpl::PlatformImpl() {}
|
||||
|
||||
PlatformImpl::~PlatformImpl() {}
|
||||
|
||||
std::string PlatformImpl::defaultLocale() {
|
||||
return "en-US";
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
27
engine/src/flutter/runtime/platform_impl.h
Normal file
27
engine/src/flutter/runtime/platform_impl.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2014 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_PLATFORM_IMPL_H_
|
||||
#define FLUTTER_RUNTIME_PLATFORM_IMPL_H_
|
||||
|
||||
#include "lib/ftl/macros.h"
|
||||
#include "flutter/sky/engine/public/platform/Platform.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class PlatformImpl : public Platform {
|
||||
public:
|
||||
explicit PlatformImpl();
|
||||
~PlatformImpl() override;
|
||||
|
||||
// blink::Platform methods:
|
||||
std::string defaultLocale() override;
|
||||
|
||||
private:
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_RUNTIME_PLATFORM_IMPL_H_
|
||||
29
engine/src/flutter/runtime/runtime_init.cc
Normal file
29
engine/src/flutter/runtime/runtime_init.cc
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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
|
||||
14
engine/src/flutter/runtime/runtime_init.h
Normal file
14
engine/src/flutter/runtime/runtime_init.h
Normal file
@@ -0,0 +1,14 @@
|
||||
// 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_
|
||||
Reference in New Issue
Block a user