Skip to content

Commit

Permalink
Break the FXL from flutter/assets. (flutter#5316)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored May 19, 2018
1 parent 7fb9081 commit 5cba577
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 61 deletions.
3 changes: 1 addition & 2 deletions assets/asset_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/glue/trace_event.h"
#include "lib/fxl/files/path.h"

#ifdef ERROR
#undef ERROR
Expand Down Expand Up @@ -46,7 +45,7 @@ bool AssetManager::GetAsBuffer(const std::string& asset_name,
return true;
}
}
FXL_DLOG(WARNING) << "Could not find asset: " << asset_name;
FML_DLOG(WARNING) << "Could not find asset: " << asset_name;
return false;
}

Expand Down
13 changes: 6 additions & 7 deletions assets/asset_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#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"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_counted.h"

namespace blink {

class AssetManager final : public AssetResolver,
public fxl::RefCountedThreadSafe<AssetManager> {
public fml::RefCountedThreadSafe<AssetManager> {
public:
void PushFront(std::unique_ptr<AssetResolver> resolver);

Expand All @@ -37,9 +36,9 @@ class AssetManager final : public AssetResolver,

~AssetManager();

FXL_DISALLOW_COPY_AND_ASSIGN(AssetManager);
FRIEND_MAKE_REF_COUNTED(AssetManager);
FRIEND_REF_COUNTED_THREAD_SAFE(AssetManager);
FML_DISALLOW_COPY_AND_ASSIGN(AssetManager);
FML_FRIEND_MAKE_REF_COUNTED(AssetManager);
FML_FRIEND_REF_COUNTED_THREAD_SAFE(AssetManager);
};

} // namespace blink
Expand Down
4 changes: 2 additions & 2 deletions assets/asset_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <string>
#include <vector>

#include "lib/fxl/macros.h"
#include "flutter/fml/macros.h"

namespace blink {

Expand All @@ -24,7 +24,7 @@ class AssetResolver {
std::vector<uint8_t>* data) const = 0;

private:
FXL_DISALLOW_COPY_AND_ASSIGN(AssetResolver);
FML_DISALLOW_COPY_AND_ASSIGN(AssetResolver);
};

} // namespace blink
Expand Down
4 changes: 2 additions & 2 deletions assets/directory_asset_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include <utility>

#include "flutter/fml/eintr_wrapper.h"
#include "flutter/fml/file.h"
#include "flutter/fml/mapping.h"
#include "lib/fxl/files/eintr_wrapper.h"

namespace blink {

Expand All @@ -35,7 +35,7 @@ bool DirectoryAssetBundle::GetAsBuffer(const std::string& asset_name,
}

if (!is_valid_) {
FXL_DLOG(WARNING) << "Asset bundle was not valid.";
FML_DLOG(WARNING) << "Asset bundle was not valid.";
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions assets/directory_asset_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#define FLUTTER_ASSETS_DIRECTORY_ASSET_BUNDLE_H_

#include "flutter/assets/asset_resolver.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/unique_fd.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"

namespace blink {

Expand All @@ -31,7 +31,7 @@ class DirectoryAssetBundle : public AssetResolver {
bool GetAsBuffer(const std::string& asset_name,
std::vector<uint8_t>* data) const override;

FXL_DISALLOW_COPY_AND_ASSIGN(DirectoryAssetBundle);
FML_DISALLOW_COPY_AND_ASSIGN(DirectoryAssetBundle);
};

} // namespace blink
Expand Down
2 changes: 1 addition & 1 deletion shell/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fml::WeakPtr<Engine> Engine::GetWeakPtr() const {
}

bool Engine::UpdateAssetManager(
fxl::RefPtr<blink::AssetManager> new_asset_manager) {
fml::RefPtr<blink::AssetManager> new_asset_manager) {
if (asset_manager_ == new_asset_manager) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions shell/common/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Engine final : public blink::RuntimeDelegate {
FXL_WARN_UNUSED_RESULT
bool Restart(RunConfiguration configuration);

bool UpdateAssetManager(fxl::RefPtr<blink::AssetManager> asset_manager);
bool UpdateAssetManager(fml::RefPtr<blink::AssetManager> asset_manager);

void BeginFrame(fxl::TimePoint frame_time);

Expand Down Expand Up @@ -105,7 +105,7 @@ class Engine final : public blink::RuntimeDelegate {
tonic::DartErrorHandleType load_script_error_;
std::string initial_route_;
blink::ViewportMetrics viewport_metrics_;
fxl::RefPtr<blink::AssetManager> asset_manager_;
fml::RefPtr<blink::AssetManager> asset_manager_;
bool activity_running_;
bool have_surface_;
fml::WeakPtrFactory<Engine> weak_factory_;
Expand Down
9 changes: 5 additions & 4 deletions shell/common/isolate_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration {
public:
KernelListIsolateConfiguration(
std::vector<std::unique_ptr<fml::Mapping>> kernel_pieces)
: kernel_pieces_(std::move(kernel_pieces)) {}
: kernel_pieces_(std::move(kernel_pieces)) {}

// |shell::IsolateConfiguration|
bool DoPrepareIsolate(blink::DartIsolate& isolate) override {
Expand All @@ -119,7 +119,7 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration {

std::unique_ptr<IsolateConfiguration> IsolateConfiguration::InferFromSettings(
const blink::Settings& settings,
fxl::RefPtr<blink::AssetManager> asset_manager) {
fml::RefPtr<blink::AssetManager> asset_manager) {
// Running in AOT mode.
if (blink::DartVM::IsRunningPrecompiledCode()) {
return CreateForPrecompiledCode();
Expand Down Expand Up @@ -174,8 +174,9 @@ std::unique_ptr<IsolateConfiguration> IsolateConfiguration::InferFromSettings(
piece_path_end++;
}

std::string piece_path(reinterpret_cast<const char*>(&kernel_list[piece_path_start]),
piece_path_end - piece_path_start);
std::string piece_path(
reinterpret_cast<const char*>(&kernel_list[piece_path_start]),
piece_path_end - piece_path_start);
std::vector<uint8_t> piece;
if (!asset_manager->GetAsBuffer(piece_path, &piece)) {
FXL_LOG(ERROR) << "Failed to load: " << piece_path;
Expand Down
2 changes: 1 addition & 1 deletion shell/common/isolate_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IsolateConfiguration {
public:
static std::unique_ptr<IsolateConfiguration> InferFromSettings(
const blink::Settings& settings,
fxl::RefPtr<blink::AssetManager> asset_manager);
fml::RefPtr<blink::AssetManager> asset_manager);

static std::unique_ptr<IsolateConfiguration> CreateForPrecompiledCode();

Expand Down
8 changes: 4 additions & 4 deletions shell/common/run_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace shell {

RunConfiguration RunConfiguration::InferFromSettings(
const blink::Settings& settings) {
auto asset_manager = fxl::MakeRefCounted<blink::AssetManager>();
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();

asset_manager->PushBack(std::make_unique<blink::DirectoryAssetBundle>(
fml::Duplicate(settings.assets_dir)));
Expand All @@ -30,11 +30,11 @@ RunConfiguration RunConfiguration::InferFromSettings(
RunConfiguration::RunConfiguration(
std::unique_ptr<IsolateConfiguration> configuration)
: RunConfiguration(std::move(configuration),
fxl::MakeRefCounted<blink::AssetManager>()) {}
fml::MakeRefCounted<blink::AssetManager>()) {}

RunConfiguration::RunConfiguration(
std::unique_ptr<IsolateConfiguration> configuration,
fxl::RefPtr<blink::AssetManager> asset_manager)
fml::RefPtr<blink::AssetManager> asset_manager)
: isolate_configuration_(std::move(configuration)),
asset_manager_(std::move(asset_manager)) {}

Expand All @@ -60,7 +60,7 @@ void RunConfiguration::SetEntrypoint(std::string entrypoint) {
entrypoint_ = std::move(entrypoint);
}

fxl::RefPtr<blink::AssetManager> RunConfiguration::GetAssetManager() const {
fml::RefPtr<blink::AssetManager> RunConfiguration::GetAssetManager() const {
return asset_manager_;
}

Expand Down
6 changes: 3 additions & 3 deletions shell/common/run_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RunConfiguration {
RunConfiguration(std::unique_ptr<IsolateConfiguration> configuration);

RunConfiguration(std::unique_ptr<IsolateConfiguration> configuration,
fxl::RefPtr<blink::AssetManager> asset_manager);
fml::RefPtr<blink::AssetManager> asset_manager);

RunConfiguration(RunConfiguration&&);

Expand All @@ -37,15 +37,15 @@ class RunConfiguration {

void SetEntrypoint(std::string entrypoint);

fxl::RefPtr<blink::AssetManager> GetAssetManager() const;
fml::RefPtr<blink::AssetManager> GetAssetManager() const;

const std::string& GetEntrypoint() const;

std::unique_ptr<IsolateConfiguration> TakeIsolateConfiguration();

private:
std::unique_ptr<IsolateConfiguration> isolate_configuration_;
fxl::RefPtr<blink::AssetManager> asset_manager_;
fml::RefPtr<blink::AssetManager> asset_manager_;
std::string entrypoint_ = "main";

FXL_DISALLOW_COPY_AND_ASSIGN(RunConfiguration);
Expand Down
23 changes: 18 additions & 5 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/fml/file.h"
#include "flutter/fml/icu_util.h"
#include "flutter/fml/log_settings.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/message_loop.h"
#include "flutter/glue/trace_event.h"
#include "flutter/runtime/dart_vm.h"
Expand Down Expand Up @@ -166,10 +168,21 @@ static void PerformInitializationTasks(const blink::Settings& settings) {
std::call_once(gShellSettingsInitialization, [&settings] {
RecordStartupTimestamp();

fxl::LogSettings log_settings;
log_settings.min_log_level =
settings.verbose_logging ? fxl::LOG_INFO : fxl::LOG_ERROR;
fxl::SetLogSettings(log_settings);
// TODO(chinmaygarde): There are currently two loggers till the transition
// away from FXL is ongoing. Remove FXL when done.
{
fxl::LogSettings log_settings;
log_settings.min_log_level =
settings.verbose_logging ? fxl::LOG_INFO : fxl::LOG_ERROR;
fxl::SetLogSettings(log_settings);
}

{
fml::LogSettings log_settings;
log_settings.min_log_level =
settings.verbose_logging ? fml::LOG_INFO : fml::LOG_ERROR;
fml::SetLogSettings(log_settings);
}

if (settings.trace_skia) {
InitSkiaEventTracer(settings.trace_skia);
Expand Down Expand Up @@ -909,7 +922,7 @@ bool Shell::OnServiceProtocolSetAssetBundlePath(
auto& allocator = response.GetAllocator();
response.SetObject();

auto asset_manager = fxl::MakeRefCounted<blink::AssetManager>();
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();

asset_manager->PushFront(std::make_unique<blink::DirectoryAssetBundle>(
fml::OpenFile(params.at("assetDirectory").ToString().c_str(),
Expand Down
38 changes: 18 additions & 20 deletions shell/platform/android/android_shell_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,23 @@ AndroidShellHolder::AndroidShellHolder(
is_valid_ = shell_ != nullptr;

if (is_valid_) {
task_runners.GetGPUTaskRunner()->PostTask(
[]() {
// Android describes -8 as "most important display threads, for
// compositing the screen and retrieving input events". Conservatively
// set the GPU thread to slightly lower priority than it.
if (::setpriority(PRIO_PROCESS, gettid(), -5) != 0) {
// Defensive fallback. Depending on the OEM, it may not be possible
// to set priority to -5.
if (::setpriority(PRIO_PROCESS, gettid(), -2) != 0) {
FXL_LOG(ERROR) << "Failed to set GPU task runner priority";
}
}
});
task_runners.GetUITaskRunner()->PostTask(
[]() {
if (::setpriority(PRIO_PROCESS, gettid(), -1) != 0) {
FXL_LOG(ERROR) << "Failed to set UI task runner priority";
}
});
task_runners.GetGPUTaskRunner()->PostTask([]() {
// Android describes -8 as "most important display threads, for
// compositing the screen and retrieving input events". Conservatively
// set the GPU thread to slightly lower priority than it.
if (::setpriority(PRIO_PROCESS, gettid(), -5) != 0) {
// Defensive fallback. Depending on the OEM, it may not be possible
// to set priority to -5.
if (::setpriority(PRIO_PROCESS, gettid(), -2) != 0) {
FXL_LOG(ERROR) << "Failed to set GPU task runner priority";
}
}
});
task_runners.GetUITaskRunner()->PostTask([]() {
if (::setpriority(PRIO_PROCESS, gettid(), -1) != 0) {
FXL_LOG(ERROR) << "Failed to set UI task runner priority";
}
});
}
}

Expand Down Expand Up @@ -184,7 +182,7 @@ fml::WeakPtr<PlatformViewAndroid> AndroidShellHolder::GetPlatformView() {
}

void AndroidShellHolder::UpdateAssetManager(
fxl::RefPtr<blink::AssetManager> asset_manager) {
fml::RefPtr<blink::AssetManager> asset_manager) {
if (!IsValid() || !asset_manager) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/android_shell_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AndroidShellHolder {
Rasterizer::Screenshot Screenshot(Rasterizer::ScreenshotType type,
bool base64_encode);

void UpdateAssetManager(fxl::RefPtr<blink::AssetManager> asset_manager);
void UpdateAssetManager(fml::RefPtr<blink::AssetManager> asset_manager);

private:
const blink::Settings settings_;
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static void RunBundleAndSnapshot(
jstring jEntrypoint,
jboolean /* reuse runtime controller (unused) */,
jobject jAssetManager) {
auto asset_manager = fxl::MakeRefCounted<blink::AssetManager>();
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();

const auto bundlepath = fml::jni::JavaStringToString(env, jbundlepath);

Expand Down Expand Up @@ -253,7 +253,7 @@ static void RunBundleAndSource(JNIEnv* env,
jstring jBundlePath,
jstring main,
jstring packages) {
auto asset_manager = fxl::MakeRefCounted<blink::AssetManager>();
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();

const auto bundlepath = fml::jni::JavaStringToString(env, jBundlePath);

Expand Down Expand Up @@ -304,7 +304,7 @@ void SetAssetBundlePathOnUI(JNIEnv* env,
return;
}

auto asset_manager = fxl::MakeRefCounted<blink::AssetManager>();
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();
asset_manager->PushBack(std::move(directory_asset_bundle));

ANDROID_SHELL_HOLDER->UpdateAssetManager(std::move(asset_manager));
Expand Down
2 changes: 1 addition & 1 deletion shell/testing/tester_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int RunTester(const blink::Settings& settings, bool run_forever) {
return EXIT_FAILURE;
}

auto asset_manager = fxl::MakeRefCounted<blink::AssetManager>();
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();
asset_manager->PushBack(std::make_unique<blink::DirectoryAssetBundle>(
fml::Duplicate(settings.assets_dir)));
asset_manager->PushBack(
Expand Down

0 comments on commit 5cba577

Please sign in to comment.