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:
Adam Barth
2016-09-07 22:19:50 -07:00
committed by GitHub
parent e9f614d9bb
commit bb6d32b498
5 changed files with 91 additions and 0 deletions

View File

@@ -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",
]

View 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

View 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_

View 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

View 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_