Re-land "Support multiple shells in a single process. (#4932)" (#4998)

* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit 723c7d0143.
This commit is contained in:
Chinmay Garde
2018-04-13 13:48:15 -07:00
committed by GitHub
parent 37e5df0530
commit 58e84c8bf0
346 changed files with 12702 additions and 11197 deletions
+34 -44
View File
@@ -10,14 +10,12 @@ group("flutter") {
public_deps = [
"$flutter_root/lib/snapshot:generate_snapshot_bin",
"$flutter_root/lib/snapshot:kernel_platform_files",
"$flutter_root/shell/testing",
"$flutter_root/sky",
"$flutter_root/third_party/txt",
]
if (flutter_runtime_mode != "debug") {
public_deps += [
"$flutter_root/lib/snapshot:entry_points_json_files",
]
public_deps += [ "$flutter_root/lib/snapshot:entry_points_json_files" ]
}
if (!is_fuchsia && !is_fuchsia_host) {
@@ -45,20 +43,24 @@ group("flutter") {
"$flutter_root/shell/platform/embedder:flutter_embedder_framework",
]
}
public_deps += [
"$flutter_root/flow:flow_unittests",
"$flutter_root/fml:fml_unittests",
"$flutter_root/runtime:runtime_unittests",
"$flutter_root/shell/common:shell_unittests",
"$flutter_root/sky/engine/wtf:wtf_unittests",
"$flutter_root/synchronization:synchronization_unittests",
"$flutter_root/third_party/txt:txt_unittests",
"//garnet/public/lib/fxl:fxl_unittests",
]
if (!is_win) {
public_deps += [
"$flutter_root/shell/platform/embedder:embedder_unittests",
"$flutter_root/shell/platform/embedder:flutter_engine",
]
}
public_deps += [
"$flutter_root/flow:flow_unittests",
"$flutter_root/fml:fml_unittests",
"$flutter_root/sky/engine/wtf:wtf_unittests",
"$flutter_root/synchronization:synchronization_unittests",
"$flutter_root/third_party/txt:txt_unittests",
"//garnet/public/lib/fxl:fxl_unittests",
]
}
}
@@ -74,29 +76,23 @@ if (is_fuchsia) {
"$flutter_root/content_handler:aot",
]
if (flutter_runtime_mode != "release") {
deps += [
"//third_party/dart/runtime/observatory:embedded_archive_observatory",
]
deps += [ "//third_party/dart/runtime/observatory:embedded_archive_observatory" ]
}
binary = "flutter_aot_runner"
if (flutter_runtime_mode != "release") {
resources = [
{
path = rebase_path(
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
dest = "observatory.tar"
},
]
resources = [ {
path = rebase_path(
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
dest = "observatory.tar"
} ]
}
meta = [
{
path = rebase_path("content_handler/meta/sandbox")
dest = "sandbox"
},
]
meta = [ {
path = rebase_path("content_handler/meta/sandbox")
dest = "sandbox"
} ]
}
package("flutter_jit_runner") {
@@ -104,29 +100,23 @@ if (is_fuchsia) {
"$flutter_root/content_handler:jit",
]
if (flutter_runtime_mode != "release") {
deps += [
"//third_party/dart/runtime/observatory:embedded_archive_observatory",
]
deps += [ "//third_party/dart/runtime/observatory:embedded_archive_observatory" ]
}
binary = "flutter_jit_runner"
if (flutter_runtime_mode != "release") {
resources = [
{
path = rebase_path(
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
dest = "observatory.tar"
},
]
resources = [ {
path = rebase_path(
"$root_gen_dir/observatory/embedded_archive_observatory.tar")
dest = "observatory.tar"
} ]
}
meta = [
{
path = rebase_path("content_handler/meta/sandbox")
dest = "sandbox"
},
]
meta = [ {
path = rebase_path("content_handler/meta/sandbox")
dest = "sandbox"
} ]
}
} else {
group("dist") {
+1 -1
View File
@@ -115,7 +115,7 @@ allowed_hosts = [
]
deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '8dddd90bf943a8174913564353b30a3b11ee0f7a',
'src': 'https://github.com/flutter/buildroot.git' + '@' + '3cf97e01cdbd4bb920fa3d40282a56c4b2d62a58',
# Fuchsia compatibility
#
+6 -6
View File
@@ -4,16 +4,18 @@
source_set("assets") {
sources = [
"asset_provider.h",
"asset_manager.cc",
"asset_manager.h",
"asset_resolver.h",
"directory_asset_bundle.cc",
"directory_asset_bundle.h",
"unzipper_provider.cc",
"unzipper_provider.h",
"zip_asset_store.cc",
"zip_asset_store.h",
]
deps = [
"$flutter_root/common",
"$flutter_root/fml",
"$flutter_root/glue",
"//garnet/public/lib/fxl",
"//garnet/public/lib/zip",
@@ -23,7 +25,5 @@ source_set("assets") {
"//third_party/zlib:minizip",
]
public_configs = [
"$flutter_root:config",
]
public_configs = [ "$flutter_root:config" ]
}
+59
View File
@@ -0,0 +1,59 @@
// Copyright 2017 The Flutter 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/assets/asset_manager.h"
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/assets/zip_asset_store.h"
#include "flutter/glue/trace_event.h"
#include "lib/fxl/files/path.h"
#ifdef ERROR
#undef ERROR
#endif
namespace blink {
AssetManager::AssetManager() = default;
AssetManager::~AssetManager() = default;
void AssetManager::PushFront(std::unique_ptr<AssetResolver> resolver) {
if (resolver == nullptr || !resolver->IsValid()) {
return;
}
resolvers_.push_front(std::move(resolver));
}
void AssetManager::PushBack(std::unique_ptr<AssetResolver> resolver) {
if (resolver == nullptr || !resolver->IsValid()) {
return;
}
resolvers_.push_back(std::move(resolver));
}
// |blink::AssetResolver|
bool AssetManager::GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const {
if (asset_name.size() == 0) {
return false;
}
TRACE_EVENT0("flutter", "AssetManager::GetAsBuffer");
for (const auto& resolver : resolvers_) {
if (resolver->GetAsBuffer(asset_name, data)) {
return true;
}
}
FXL_DLOG(ERROR) << "Could not find asset: " << asset_name;
return false;
}
// |blink::AssetResolver|
bool AssetManager::IsValid() const {
return resolvers_.size() > 0;
}
} // namespace blink
+47
View File
@@ -0,0 +1,47 @@
// Copyright 2017 The Flutter 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_ASSETS_ASSET_MANAGER_H_
#define FLUTTER_ASSETS_ASSET_MANAGER_H_
#include <deque>
#include <memory>
#include <string>
#include "flutter/assets/asset_resolver.h"
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
namespace blink {
class AssetManager final : public AssetResolver,
public fxl::RefCountedThreadSafe<AssetManager> {
public:
void PushFront(std::unique_ptr<AssetResolver> resolver);
void PushBack(std::unique_ptr<AssetResolver> resolver);
// |blink::AssetResolver|
bool IsValid() const override;
// |blink::AssetResolver|
bool GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const override;
private:
std::deque<std::unique_ptr<AssetResolver>> resolvers_;
AssetManager();
~AssetManager();
FXL_DISALLOW_COPY_AND_ASSIGN(AssetManager);
FRIEND_MAKE_REF_COUNTED(AssetManager);
FRIEND_REF_COUNTED_THREAD_SAFE(AssetManager);
};
} // namespace blink
#endif // FLUTTER_ASSETS_ASSET_MANAGER_H_
-25
View File
@@ -1,25 +0,0 @@
// Copyright 2018 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_ASSETS_ASSET_PROVIDER_H_
#define FLUTTER_ASSETS_ASSET_PROVIDER_H_
#include <string>
#include <vector>
#include "lib/fxl/memory/ref_counted.h"
namespace blink {
class AssetProvider
: public fxl::RefCountedThreadSafe<AssetProvider>
{
public:
virtual bool GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) = 0;
virtual ~AssetProvider() = default;
};
} // namespace blink
#endif // FLUTTER_ASSETS_ASSET_PROVIDER_H
+32
View File
@@ -0,0 +1,32 @@
// Copyright 2017 The Flutter 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_ASSETS_ASSET_RESOLVER_H_
#define FLUTTER_ASSETS_ASSET_RESOLVER_H_
#include <string>
#include <vector>
#include "lib/fxl/macros.h"
namespace blink {
class AssetResolver {
public:
AssetResolver() = default;
virtual ~AssetResolver() = default;
virtual bool IsValid() const = 0;
virtual bool GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const = 0;
private:
FXL_DISALLOW_COPY_AND_ASSIGN(AssetResolver);
};
} // namespace blink
#endif // FLUTTER_ASSETS_ASSET_RESOLVER_H_
+35 -54
View File
@@ -3,73 +3,54 @@
// found in the LICENSE file.
#include "flutter/assets/directory_asset_bundle.h"
#include "lib/fxl/build_config.h"
#include <fcntl.h>
#include <utility>
#include "flutter/fml/file.h"
#include "flutter/fml/mapping.h"
#include "lib/fxl/files/eintr_wrapper.h"
#include "lib/fxl/files/file.h"
#include "lib/fxl/files/path.h"
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/portable_unistd.h"
namespace blink {
bool DirectoryAssetBundle::GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) {
if (fd_.is_valid()) {
#if defined(OS_WIN)
// This code path is not valid in a Windows environment.
return false;
#else
fxl::UniqueFD asset_file(openat(fd_.get(), asset_name.c_str(), O_RDONLY));
if (!asset_file.is_valid())
return false;
constexpr size_t kBufferSize = 1 << 16;
size_t offset = 0;
ssize_t bytes_read = 0;
do {
offset += bytes_read;
data->resize(offset + kBufferSize);
bytes_read = read(asset_file.get(), &(*data)[offset], kBufferSize);
} while (bytes_read > 0);
if (bytes_read < 0) {
FXL_LOG(ERROR) << "Reading " << asset_name << " failed";
data->clear();
return false;
}
data->resize(offset + bytes_read);
return true;
#endif
DirectoryAssetBundle::DirectoryAssetBundle(fml::UniqueFD descriptor)
: descriptor_(std::move(descriptor)) {
if (!fml::IsDirectory(descriptor_)) {
return;
}
std::string asset_path = GetPathForAsset(asset_name);
if (asset_path.empty())
return false;
return files::ReadFileToVector(asset_path, data);
is_valid_ = true;
}
DirectoryAssetBundle::~DirectoryAssetBundle() {}
DirectoryAssetBundle::~DirectoryAssetBundle() = default;
DirectoryAssetBundle::DirectoryAssetBundle(std::string directory)
: directory_(std::move(directory)), fd_() {}
// |blink::AssetResolver|
bool DirectoryAssetBundle::IsValid() const {
return is_valid_;
}
DirectoryAssetBundle::DirectoryAssetBundle(fxl::UniqueFD fd)
: fd_(std::move(fd)) {}
std::string DirectoryAssetBundle::GetPathForAsset(
const std::string& asset_name) {
std::string asset_path = files::SimplifyPath(directory_ + "/" + asset_name);
if (asset_path.find(directory_) != 0u) {
FXL_LOG(ERROR) << "Asset name '" << asset_name
<< "' attempted to traverse outside asset bundle.";
return std::string();
// |blink::AssetResolver|
bool DirectoryAssetBundle::GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const {
if (data == nullptr) {
return false;
}
return asset_path;
if (!is_valid_) {
FXL_DLOG(WARNING) << "Asset bundle was not valid.";
return false;
}
fml::FileMapping mapping(
fml::OpenFile(descriptor_, asset_name.c_str(), fml::OpenPermission::kRead,
false /* directory */),
false /* executable */);
if (mapping.GetMapping() == nullptr) {
return false;
}
data->resize(mapping.GetSize());
memmove(data->data(), mapping.GetMapping(), mapping.GetSize());
return true;
}
} // namespace blink
+16 -16
View File
@@ -5,31 +5,31 @@
#ifndef FLUTTER_ASSETS_DIRECTORY_ASSET_BUNDLE_H_
#define FLUTTER_ASSETS_DIRECTORY_ASSET_BUNDLE_H_
#include <string>
#include <vector>
#include "flutter/assets/asset_provider.h"
#include "lib/fxl/files/unique_fd.h"
#include "flutter/assets/asset_resolver.h"
#include "flutter/fml/unique_fd.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
namespace blink {
class DirectoryAssetBundle
: public AssetProvider {
class DirectoryAssetBundle : public AssetResolver {
public:
explicit DirectoryAssetBundle(std::string directory);
// Expects fd to be valid, otherwise the file descriptor is ignored.
explicit DirectoryAssetBundle(fxl::UniqueFD fd);
virtual ~DirectoryAssetBundle();
explicit DirectoryAssetBundle(fml::UniqueFD descriptor);
virtual bool GetAsBuffer(const std::string& asset_name, std::vector<uint8_t>* data);
std::string GetPathForAsset(const std::string& asset_name);
~DirectoryAssetBundle() override;
private:
const std::string directory_;
fxl::UniqueFD fd_;
const fml::UniqueFD descriptor_;
bool is_valid_ = false;
std::string GetPathForAsset(const std::string& asset_name) const;
// |blink::AssetResolver|
bool IsValid() const override;
// |blink::AssetResolver|
bool GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const override;
FXL_DISALLOW_COPY_AND_ASSIGN(DirectoryAssetBundle);
};
-21
View File
@@ -1,21 +0,0 @@
// 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/assets/unzipper_provider.h"
#include "lib/fxl/logging.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
namespace blink {
UnzipperProvider GetUnzipperProviderForPath(std::string zip_path) {
return [zip_path]() {
zip::UniqueUnzipper unzipper(unzOpen2(zip_path.c_str(), nullptr));
if (!unzipper.is_valid())
FXL_LOG(ERROR) << "Unable to open zip file: " << zip_path;
return unzipper;
};
}
} // namespace blink
-20
View File
@@ -1,20 +0,0 @@
// 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_ASSETS_UNZIP_PROVIDER_H_
#define FLUTTER_ASSETS_UNZIP_PROVIDER_H_
#include <functional>
#include "lib/zip/unique_unzipper.h"
namespace blink {
using UnzipperProvider = std::function<zip::UniqueUnzipper()>;
UnzipperProvider GetUnzipperProviderForPath(std::string zip_path);
} // namespace blink
#endif // FLUTTER_ASSETS_UNZIP_PROVIDER_H_
+16 -8
View File
@@ -15,21 +15,28 @@
#include <utility>
#include "flutter/glue/trace_event.h"
#include "lib/fxl/files/eintr_wrapper.h"
#include "lib/fxl/files/unique_fd.h"
#include "lib/zip/unique_unzipper.h"
namespace blink {
ZipAssetStore::ZipAssetStore(UnzipperProvider unzipper_provider)
: unzipper_provider_(std::move(unzipper_provider)) {
ZipAssetStore::ZipAssetStore(std::string file_path)
: file_path_(std::move(file_path)) {
BuildStatCache();
}
ZipAssetStore::~ZipAssetStore() = default;
zip::UniqueUnzipper ZipAssetStore::CreateUnzipper() const {
return zip::UniqueUnzipper{::unzOpen2(file_path_.c_str(), nullptr)};
}
// |blink::AssetResolver|
bool ZipAssetStore::IsValid() const {
return stat_cache_.size() > 0;
}
// |blink::AssetResolver|
bool ZipAssetStore::GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) {
std::vector<uint8_t>* data) const {
TRACE_EVENT0("flutter", "ZipAssetStore::GetAsBuffer");
auto found = stat_cache_.find(asset_name);
@@ -37,7 +44,7 @@ bool ZipAssetStore::GetAsBuffer(const std::string& asset_name,
return false;
}
auto unzipper = unzipper_provider_();
auto unzipper = CreateUnzipper();
if (!unzipper.is_valid()) {
return false;
@@ -73,7 +80,8 @@ bool ZipAssetStore::GetAsBuffer(const std::string& asset_name,
void ZipAssetStore::BuildStatCache() {
TRACE_EVENT0("flutter", "ZipAssetStore::BuildStatCache");
auto unzipper = unzipper_provider_();
auto unzipper = CreateUnzipper();
if (!unzipper.is_valid()) {
return;
+16 -8
View File
@@ -6,21 +6,20 @@
#define FLUTTER_ASSETS_ZIP_ASSET_STORE_H_
#include <map>
#include <vector>
#include "flutter/assets/unzipper_provider.h"
#include "flutter/assets/asset_resolver.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
#include "lib/zip/unique_unzipper.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
namespace blink {
class ZipAssetStore : public fxl::RefCountedThreadSafe<ZipAssetStore> {
class ZipAssetStore final : public AssetResolver {
public:
explicit ZipAssetStore(UnzipperProvider unzipper_provider);
~ZipAssetStore();
ZipAssetStore(std::string file_path);
bool GetAsBuffer(const std::string& asset_name, std::vector<uint8_t>* data);
~ZipAssetStore() override;
private:
struct CacheEntry {
@@ -30,11 +29,20 @@ class ZipAssetStore : public fxl::RefCountedThreadSafe<ZipAssetStore> {
: file_pos(p_file_pos), uncompressed_size(p_uncompressed_size) {}
};
UnzipperProvider unzipper_provider_;
std::map<std::string, CacheEntry> stat_cache_;
std::string file_path_;
mutable std::map<std::string, CacheEntry> stat_cache_;
// |blink::AssetResolver|
bool IsValid() const override;
// |blink::AssetResolver|
bool GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const override;
void BuildStatCache();
zip::UniqueUnzipper CreateUnzipper() const;
FXL_DISALLOW_COPY_AND_ASSIGN(ZipAssetStore);
};
+3 -2
View File
@@ -12,11 +12,12 @@ source_set("common") {
sources = [
"settings.cc",
"settings.h",
"threads.cc",
"threads.h",
"task_runners.cc",
"task_runners.h",
]
deps = [
"$flutter_root/fml",
"//garnet/public/lib/fxl",
]
+41 -17
View File
@@ -4,26 +4,50 @@
#include "flutter/common/settings.h"
#include <memory>
#include "lib/fxl/logging.h"
#include <sstream>
namespace blink {
namespace {
Settings* g_settings = nullptr;
} // namespace
const Settings& Settings::Get() {
FXL_CHECK(g_settings);
return *g_settings;
}
void Settings::Set(const Settings& settings) {
FXL_CHECK(!g_settings);
g_settings = new Settings();
*g_settings = settings;
std::string Settings::ToString() const {
std::stringstream stream;
stream << "Settings: " << std::endl;
stream << "aot_snapshot_path: " << aot_snapshot_path << std::endl;
stream << "script_snapshot_path: " << script_snapshot_path << std::endl;
stream << "aot_vm_snapshot_data_filename: " << aot_vm_snapshot_data_filename
<< std::endl;
stream << "aot_vm_snapshot_instr_filename: " << aot_vm_snapshot_instr_filename
<< std::endl;
stream << "aot_isolate_snapshot_data_filename: "
<< aot_isolate_snapshot_data_filename << std::endl;
stream << "aot_isolate_snapshot_instr_filename: "
<< aot_isolate_snapshot_instr_filename << std::endl;
stream << "application_library_path: " << application_library_path
<< std::endl;
stream << "main_dart_file_path: " << main_dart_file_path << std::endl;
stream << "packages_file_path: " << packages_file_path << std::endl;
stream << "temp_directory_path: " << temp_directory_path << std::endl;
stream << "dart_flags:" << std::endl;
for (const auto& dart_flag : dart_flags) {
stream << " " << dart_flag << std::endl;
}
stream << "start_paused: " << start_paused << std::endl;
stream << "trace_skia: " << trace_skia << std::endl;
stream << "trace_startup: " << trace_startup << std::endl;
stream << "endless_trace_buffer: " << endless_trace_buffer << std::endl;
stream << "enable_dart_profiling: " << enable_dart_profiling << std::endl;
stream << "dart_non_checked_mode: " << dart_non_checked_mode << std::endl;
stream << "enable_observatory: " << enable_observatory << std::endl;
stream << "observatory_port: " << observatory_port << std::endl;
stream << "ipv6: " << ipv6 << std::endl;
stream << "use_test_fonts: " << use_test_fonts << std::endl;
stream << "enable_software_rendering: " << enable_software_rendering
<< std::endl;
stream << "using_blink: " << using_blink << std::endl;
stream << "log_tag: " << log_tag << std::endl;
stream << "icu_data_path: " << icu_data_path << std::endl;
stream << "assets_dir: " << assets_dir << std::endl;
stream << "assets_path: " << assets_path << std::endl;
return stream.str();
}
} // namespace blink
+59 -17
View File
@@ -5,40 +5,82 @@
#ifndef FLUTTER_COMMON_SETTINGS_H_
#define FLUTTER_COMMON_SETTINGS_H_
#include <fcntl.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
#include "flutter/fml/unique_fd.h"
#include "lib/fxl/functional/closure.h"
namespace blink {
using TaskObserverAdd =
std::function<void(intptr_t /* key */, fxl::Closure /* callback */)>;
using TaskObserverRemove = std::function<void(intptr_t /* key */)>;
struct Settings {
bool enable_observatory = false;
// Port on target will be auto selected by the OS. A message will be printed
// on the target with the port after it has been selected.
uint32_t observatory_port = 0;
bool ipv6 = false;
bool start_paused = false;
bool trace_startup = false;
bool endless_trace_buffer = false;
bool enable_dart_profiling = false;
bool use_test_fonts = false;
bool dart_non_checked_mode = false;
bool enable_software_rendering = false;
bool using_blink = true;
std::string aot_shared_library_path;
// VM settings
std::string script_snapshot_path;
std::string kernel_snapshot_path;
std::string aot_snapshot_path;
std::string aot_vm_snapshot_data_filename;
std::string aot_vm_snapshot_instr_filename;
std::string aot_isolate_snapshot_data_filename;
std::string aot_isolate_snapshot_instr_filename;
std::string application_library_path;
std::string application_kernel_asset;
std::string main_dart_file_path;
std::string packages_file_path;
std::string temp_directory_path;
std::vector<std::string> dart_flags;
std::string log_tag = "flutter";
static const Settings& Get();
static void Set(const Settings& settings);
// Isolate settings
bool start_paused = false;
bool trace_skia = false;
bool trace_startup = false;
bool endless_trace_buffer = false;
bool enable_dart_profiling = false;
bool dart_non_checked_mode = false;
// Observatory settings
bool enable_observatory = false;
// Port on target will be auto selected by the OS. A message will be printed
// on the target with the port after it has been selected.
uint32_t observatory_port = 0;
bool ipv6 = false;
// Font settings
bool use_test_fonts = false;
// Engine settings
TaskObserverAdd task_observer_add;
TaskObserverRemove task_observer_remove;
// The main isolate is current when this callback is made. This is a good spot
// to perform native Dart bindings for libraries not built in.
fxl::Closure root_isolate_create_callback;
// The isolate is not current and may have already been destroyed when this
// call is made.
fxl::Closure root_isolate_shutdown_callback;
bool enable_software_rendering = false;
bool using_blink = false;
bool skia_deterministic_rendering_on_cpu = false;
std::string log_tag = "flutter";
std::string icu_data_path;
// Assets settings
fml::UniqueFD::element_type assets_dir =
fml::UniqueFD::traits_type::InvalidValue();
std::string assets_path;
std::string flx_path;
std::string ToString() const;
};
} // namespace blink
+48
View File
@@ -0,0 +1,48 @@
// Copyright 2017 The Flutter 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/common/task_runners.h"
#include <utility>
namespace blink {
TaskRunners::TaskRunners(std::string label,
fxl::RefPtr<fxl::TaskRunner> platform,
fxl::RefPtr<fxl::TaskRunner> gpu,
fxl::RefPtr<fxl::TaskRunner> ui,
fxl::RefPtr<fxl::TaskRunner> io)
: label_(std::move(label)),
platform_(std::move(platform)),
gpu_(std::move(gpu)),
ui_(std::move(ui)),
io_(std::move(io)) {}
TaskRunners::~TaskRunners() = default;
const std::string& TaskRunners::GetLabel() const {
return label_;
}
fxl::RefPtr<fxl::TaskRunner> TaskRunners::GetPlatformTaskRunner() const {
return platform_;
}
fxl::RefPtr<fxl::TaskRunner> TaskRunners::GetUITaskRunner() const {
return ui_;
}
fxl::RefPtr<fxl::TaskRunner> TaskRunners::GetIOTaskRunner() const {
return io_;
}
fxl::RefPtr<fxl::TaskRunner> TaskRunners::GetGPUTaskRunner() const {
return gpu_;
}
bool TaskRunners::IsValid() const {
return platform_ && gpu_ && ui_ && io_;
}
} // namespace blink
+46
View File
@@ -0,0 +1,46 @@
// Copyright 2017 The Flutter 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_COMMON_TASK_RUNNERS_H_
#define FLUTTER_COMMON_TASK_RUNNERS_H_
#include <string>
#include "lib/fxl/macros.h"
#include "lib/fxl/tasks/task_runner.h"
namespace blink {
class TaskRunners {
public:
TaskRunners(std::string label,
fxl::RefPtr<fxl::TaskRunner> platform,
fxl::RefPtr<fxl::TaskRunner> gpu,
fxl::RefPtr<fxl::TaskRunner> ui,
fxl::RefPtr<fxl::TaskRunner> io);
~TaskRunners();
const std::string& GetLabel() const;
fxl::RefPtr<fxl::TaskRunner> GetPlatformTaskRunner() const;
fxl::RefPtr<fxl::TaskRunner> GetUITaskRunner() const;
fxl::RefPtr<fxl::TaskRunner> GetIOTaskRunner() const;
fxl::RefPtr<fxl::TaskRunner> GetGPUTaskRunner() const;
bool IsValid() const;
private:
const std::string label_;
fxl::RefPtr<fxl::TaskRunner> platform_;
fxl::RefPtr<fxl::TaskRunner> gpu_;
fxl::RefPtr<fxl::TaskRunner> ui_;
fxl::RefPtr<fxl::TaskRunner> io_;
};
} // namespace blink
#endif // FLUTTER_COMMON_TASK_RUNNERS_H_
-56
View File
@@ -1,56 +0,0 @@
// 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/common/threads.h"
#include <utility>
namespace blink {
namespace {
Threads* g_threads = nullptr;
} // namespace
Threads::Threads() {}
Threads::Threads(fxl::RefPtr<fxl::TaskRunner> platform,
fxl::RefPtr<fxl::TaskRunner> gpu,
fxl::RefPtr<fxl::TaskRunner> ui,
fxl::RefPtr<fxl::TaskRunner> io)
: platform_(std::move(platform)),
gpu_(std::move(gpu)),
ui_(std::move(ui)),
io_(std::move(io)) {}
Threads::~Threads() {}
const fxl::RefPtr<fxl::TaskRunner>& Threads::Platform() {
return Get().platform_;
}
const fxl::RefPtr<fxl::TaskRunner>& Threads::Gpu() {
return Get().gpu_;
}
const fxl::RefPtr<fxl::TaskRunner>& Threads::UI() {
return Get().ui_;
}
const fxl::RefPtr<fxl::TaskRunner>& Threads::IO() {
return Get().io_;
}
const Threads& Threads::Get() {
FXL_CHECK(g_threads);
return *g_threads;
}
void Threads::Set(const Threads& threads) {
FXL_CHECK(!g_threads);
g_threads = new Threads();
*g_threads = threads;
}
} // namespace blink
-48
View File
@@ -1,48 +0,0 @@
// 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_COMMON_THREADS_H_
#define FLUTTER_COMMON_THREADS_H_
#include "lib/fxl/tasks/task_runner.h"
#define ASSERT_IS_PLATFORM_THREAD \
FXL_DCHECK(::blink::Threads::Platform()->RunsTasksOnCurrentThread());
#define ASSERT_IS_GPU_THREAD \
FXL_DCHECK(::blink::Threads::Gpu()->RunsTasksOnCurrentThread());
#define ASSERT_IS_UI_THREAD \
FXL_DCHECK(::blink::Threads::UI()->RunsTasksOnCurrentThread());
#define ASSERT_IS_IO_THREAD \
FXL_DCHECK(::blink::Threads::IO()->RunsTasksOnCurrentThread());
namespace blink {
class Threads {
public:
Threads();
Threads(fxl::RefPtr<fxl::TaskRunner> platform,
fxl::RefPtr<fxl::TaskRunner> gpu,
fxl::RefPtr<fxl::TaskRunner> ui,
fxl::RefPtr<fxl::TaskRunner> io);
~Threads();
static const fxl::RefPtr<fxl::TaskRunner>& Platform();
static const fxl::RefPtr<fxl::TaskRunner>& Gpu();
static const fxl::RefPtr<fxl::TaskRunner>& UI();
static const fxl::RefPtr<fxl::TaskRunner>& IO();
static void Set(const Threads& settings);
private:
static const Threads& Get();
fxl::RefPtr<fxl::TaskRunner> platform_;
fxl::RefPtr<fxl::TaskRunner> gpu_;
fxl::RefPtr<fxl::TaskRunner> ui_;
fxl::RefPtr<fxl::TaskRunner> io_;
};
} // namespace blink
#endif // FLUTTER_COMMON_THREADS_H_

Some files were not shown because too many files have changed in this diff Show More