Skip to content

Commit

Permalink
Commit from GitHub Actions (Run Code Linter)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 2, 2025
1 parent df18d07 commit f452a9d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions bridge/core/api/executing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ void ExecutingContextWebFMethods::AddRustFutureTask(ExecutingContext* context,
}

void ExecutingContextWebFMethods::RemoveRustFutureTask(ExecutingContext* context,
WebFNativeFunctionContext* callback_context,
NativeLibrartMetaData* meta_data,
SharedExceptionState* shared_exception_state) {
WebFNativeFunctionContext* callback_context,
NativeLibrartMetaData* meta_data,
SharedExceptionState* shared_exception_state) {
auto callback_impl = WebFNativeFunction::Create(callback_context, shared_exception_state);

context->RemoveRustFutureTask(callback_impl, meta_data);
Expand Down
2 changes: 1 addition & 1 deletion bridge/core/dart_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

#include <memory>
#include <thread>
#include "core/native/native_loader.h"
#include "foundation/native_string.h"
#include "foundation/native_value.h"
#include "include/dart_api.h"
#include "plugin_api/executing_context.h"
#include "core/native/native_loader.h"

#if defined(_WIN32)
#define WEBF_EXPORT_C extern "C" __declspec(dllexport)
Expand Down
14 changes: 9 additions & 5 deletions bridge/core/executing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,13 @@ void ExecutingContext::EnqueueMicrotask(MicrotaskCallback callback, void* data)
JS_FreeValue(ctx(), proxy_data);
}

void ExecutingContext::AddRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_future_task, NativeLibrartMetaData* meta_data) {
void ExecutingContext::AddRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_future_task,
NativeLibrartMetaData* meta_data) {
meta_data->callbacks.push_back(run_future_task);
}

void ExecutingContext::RemoveRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_future_task, NativeLibrartMetaData* meta_data) {
void ExecutingContext::RemoveRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_future_task,
NativeLibrartMetaData* meta_data) {
// Add the callback to the removed_callbacks list to avoid removing the callback during the iteration.
meta_data->removed_callbacks.push_back(run_future_task);
}
Expand All @@ -410,9 +412,11 @@ void ExecutingContext::RunRustFutureTasks() {
dart_isolate_context_->profiler()->FinishTrackAsyncEvaluation();
}
for (auto& removed_callback : meta_data->removed_callbacks) {
meta_data->callbacks.erase(std::remove_if(meta_data->callbacks.begin(), meta_data->callbacks.end(), [&](const std::shared_ptr<WebFNativeFunction>& callback) {
return callback->Matches(removed_callback);
}), meta_data->callbacks.end());
meta_data->callbacks.erase(std::remove_if(meta_data->callbacks.begin(), meta_data->callbacks.end(),
[&](const std::shared_ptr<WebFNativeFunction>& callback) {
return callback->Matches(removed_callback);
}),
meta_data->callbacks.end());
}
meta_data->removed_callbacks.clear();
if (meta_data->callbacks.empty() && meta_data->load_context != nullptr) {
Expand Down
6 changes: 4 additions & 2 deletions bridge/core/executing_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ class ExecutingContext {
void ReportError(JSValueConst error, char** rust_errmsg, uint32_t* rust_errmsg_length);
void DrainMicrotasks();
void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
static void AddRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_rust_future_tasks, NativeLibrartMetaData* meta_data);
static void RemoveRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_rust_future_tasks, NativeLibrartMetaData* meta_data);
static void AddRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_rust_future_tasks,
NativeLibrartMetaData* meta_data);
static void RemoveRustFutureTask(const std::shared_ptr<WebFNativeFunction>& run_rust_future_tasks,
NativeLibrartMetaData* meta_data);
void RunRustFutureTasks();
void RegisterNativeLibraryMetaData(NativeLibrartMetaData* meta_data);
void DefineGlobalProperty(const char* prop, JSValueConst value);
Expand Down
3 changes: 1 addition & 2 deletions bridge/core/native/native_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class WebFNativeFunction : public Function {
}

[[nodiscard]] bool Matches(const std::shared_ptr<WebFNativeFunction>& other) {
return other && other->callback_context_ &&
other->callback_context_->callback == callback_context_->callback;
return other && other->callback_context_ && other->callback_context_->callback == callback_context_->callback;
}

private:
Expand Down
3 changes: 2 additions & 1 deletion bridge/core/native/native_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ static void HandleNativeLibraryLoad(PluginLibraryEntryPoint entry_point,
return;

context->dartIsolateContext()->dispatcher()->PostToJs(context->isDedicated(), context_id, ExecuteNativeLibrary,
entry_point, lib_name, p_native_library_load_context, imported_data);
entry_point, lib_name, p_native_library_load_context,
imported_data);
}

ScriptPromise NativeLoader::loadNativeLibrary(const AtomicString& lib_name,
Expand Down

0 comments on commit f452a9d

Please sign in to comment.