Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ FILE: ../../../flutter/fml/platform/darwin/scoped_nsobject.mm
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.h
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization_unittests.mm
FILE: ../../../flutter/fml/platform/fuchsia/message_loop_fuchsia.cc
FILE: ../../../flutter/fml/platform/fuchsia/message_loop_fuchsia.h
FILE: ../../../flutter/fml/platform/fuchsia/paths_fuchsia.cc
FILE: ../../../flutter/fml/platform/linux/message_loop_linux.cc
FILE: ../../../flutter/fml/platform/linux/message_loop_linux.h
Expand Down
36 changes: 25 additions & 11 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,28 @@ source_set("fml") {
}

if (is_fuchsia) {
sources += [ "platform/fuchsia/paths_fuchsia.cc" ]
sources += [
"platform/fuchsia/message_loop_fuchsia.cc",
"platform/fuchsia/message_loop_fuchsia.h",
"platform/fuchsia/paths_fuchsia.cc",
]

if (using_fuchsia_sdk) {
public_deps += [ "$fuchsia_sdk_root/pkg:trace" ]
public_deps += [
"$fuchsia_sdk_root/pkg:async-cpp",
"$fuchsia_sdk_root/pkg:async-loop-cpp",
"$fuchsia_sdk_root/pkg:async-loop-default",
"$fuchsia_sdk_root/pkg:trace",
"$fuchsia_sdk_root/pkg:zx",
]
} else {
public_deps += [ "//zircon/public/lib/trace" ]
public_deps += [
"//zircon/public/lib/async-cpp",
"//zircon/public/lib/async-loop-cpp",
"//zircon/public/lib/async-loop-default",
"//zircon/public/lib/trace",
"//zircon/public/lib/zx",
]
}
}

Expand Down Expand Up @@ -205,31 +221,29 @@ executable("fml_unittests") {
sources = [
"base32_unittest.cc",
"command_line_unittest.cc",
"gpu_thread_merger_unittests.cc",
"memory/ref_counted_unittest.cc",
"memory/weak_ptr_unittest.cc",
"message_loop_task_queues_merge_unmerge_unittests.cc",
"message_loop_task_queues_unittests.cc",
"message_loop_unittests.cc",
"message_unittests.cc",
"paths_unittests.cc",
"platform/darwin/string_range_sanitization_unittests.mm",
"synchronization/count_down_latch_unittests.cc",
"synchronization/semaphore_unittest.cc",
"synchronization/sync_switch_unittest.cc",
"synchronization/waitable_event_unittest.cc",
"thread_local_unittests.cc",
"thread_unittests.cc",
"time/time_delta_unittest.cc",
"time/time_point_unittest.cc",
"time/time_unittest.cc",
]

# TODO(gw280): Figure out why these tests don't work currently on Fuchsia
if (!is_fuchsia) {
sources += [
"file_unittest.cc",
"gpu_thread_merger_unittests.cc",
"message_loop_task_queues_unittests.cc",
"message_loop_unittests.cc",
"synchronization/count_down_latch_unittests.cc",
"thread_unittests.cc",
]
sources += [ "file_unittest.cc" ]
}

deps = [
Expand Down
4 changes: 4 additions & 0 deletions fml/message_loop_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "flutter/fml/platform/darwin/message_loop_darwin.h"
#elif OS_ANDROID
#include "flutter/fml/platform/android/message_loop_android.h"
#elif OS_FUCHSIA
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
#elif OS_LINUX
#include "flutter/fml/platform/linux/message_loop_linux.h"
#elif OS_WIN
Expand All @@ -30,6 +32,8 @@ fml::RefPtr<MessageLoopImpl> MessageLoopImpl::Create() {
return fml::MakeRefCounted<MessageLoopDarwin>();
#elif OS_ANDROID
return fml::MakeRefCounted<MessageLoopAndroid>();
#elif OS_FUCHSIA
return fml::MakeRefCounted<MessageLoopFuchsia>();
#elif OS_LINUX
return fml::MakeRefCounted<MessageLoopLinux>();
#elif OS_WIN
Expand Down
38 changes: 38 additions & 0 deletions fml/platform/fuchsia/message_loop_fuchsia.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2013 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/fml/platform/fuchsia/message_loop_fuchsia.h"

#include <lib/async-loop/default.h>
#include <lib/async/cpp/task.h>
#include <lib/zx/time.h>

namespace fml {

MessageLoopFuchsia::MessageLoopFuchsia()
: loop_(&kAsyncLoopConfigAttachToCurrentThread) {}

MessageLoopFuchsia::~MessageLoopFuchsia() = default;

void MessageLoopFuchsia::Run() {
loop_.Run();
}

void MessageLoopFuchsia::Terminate() {
loop_.Quit();
}

void MessageLoopFuchsia::WakeUp(fml::TimePoint time_point) {
fml::TimePoint now = fml::TimePoint::Now();
zx::duration due_time{0};
if (time_point > now) {
due_time = zx::nsec((time_point - now).ToNanoseconds());
}

FML_DCHECK(async::PostDelayedTask(
loop_.dispatcher(), [this]() { RunExpiredTasksNow(); },
due_time) == ZX_OK);
}

} // namespace fml
36 changes: 36 additions & 0 deletions fml/platform/fuchsia/message_loop_fuchsia.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2013 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_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
#define FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_

#include <lib/async-loop/cpp/loop.h>

#include "flutter/fml/macros.h"
#include "flutter/fml/message_loop_impl.h"

namespace fml {

class MessageLoopFuchsia : public MessageLoopImpl {
private:
MessageLoopFuchsia();

~MessageLoopFuchsia() override;

void Run() override;

void Terminate() override;

void WakeUp(fml::TimePoint time_point) override;

async::Loop loop_;

FML_FRIEND_MAKE_REF_COUNTED(MessageLoopFuchsia);
FML_FRIEND_REF_COUNTED_THREAD_SAFE(MessageLoopFuchsia);
FML_DISALLOW_COPY_AND_ASSIGN(MessageLoopFuchsia);
};

} // namespace fml

#endif // FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"services": [
"fuchsia.accessibility.semantics.SemanticsManager",
"fuchsia.intl.PropertyProvider",
"fuchsia.sys.Launcher"
"fuchsia.process.Launcher"
]
}
}
2 changes: 1 addition & 1 deletion testing/fuchsia/meta/fuchsia_test.cmx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"services": [
"fuchsia.accessibility.semantics.SemanticsManager",
"fuchsia.sys.Launcher"
"fuchsia.process.Launcher"
]
}
}