mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add dart_invoke to tonic for calls into App code.
This patch adds utility functions which provide a single choke point for calling into sky application code. For now this is only serving the purpose of having a common trace event for calls into app code. R=abarth@chromium.org, abarth BUG= Review URL: https://codereview.chromium.org/941153003
This commit is contained in:
parent
f58bd3e40d
commit
e53bba60a5
@ -19,6 +19,7 @@
|
||||
#include "sky/engine/tonic/dart_api_scope.h"
|
||||
#include "sky/engine/tonic/dart_builtin.h"
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
#include "sky/engine/tonic/dart_isolate_scope.h"
|
||||
#include "sky/engine/tonic/dart_state.h"
|
||||
#include "sky/engine/tonic/dart_value.h"
|
||||
@ -154,7 +155,7 @@ static void ExecuteMicrotask(base::WeakPtr<DartState> dart_state,
|
||||
return;
|
||||
DartIsolateScope scope(dart_state->isolate());
|
||||
DartApiScope api_scope;
|
||||
LogIfError(Dart_InvokeClosure(callback->dart_value(), 0, nullptr));
|
||||
DartInvokeAppClosure(callback->dart_value(), 0, nullptr);
|
||||
}
|
||||
|
||||
void ScheduleMicrotask(Dart_NativeArguments args) {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
#include "sky/engine/tonic/dart_state.h"
|
||||
|
||||
namespace blink {
|
||||
@ -33,7 +34,7 @@ Dart_Isolate DartCallback::GetIsolate() const {
|
||||
}
|
||||
|
||||
bool DartCallback::handleEvent(int argc, Dart_Handle* argv) {
|
||||
LogIfError(Dart_InvokeClosure(callback_.value(), argc, argv));
|
||||
DartInvokeAppClosure(callback_.value(), argc, argv);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
#include "sky/engine/tonic/dart_exception_factory.h"
|
||||
#include "sky/engine/tonic/dart_gc_visitor.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
#include "sky/engine/tonic/dart_isolate_scope.h"
|
||||
|
||||
namespace blink {
|
||||
@ -51,7 +52,7 @@ void DartEventListener::handleEvent(ExecutionContext* context, Event* event) {
|
||||
DCHECK(event_handle);
|
||||
|
||||
Dart_Handle params[] = {event_handle};
|
||||
LogIfError(Dart_InvokeClosure(closure_handle, arraysize(params), params));
|
||||
DartInvokeAppClosure(closure_handle, arraysize(params), params);
|
||||
}
|
||||
|
||||
void DartEventListener::AcceptDartGCVisitor(DartGCVisitor& visitor) const {
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "sky/engine/tonic/dart_api_scope.h"
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
#include "sky/engine/tonic/dart_isolate_scope.h"
|
||||
|
||||
namespace blink {
|
||||
@ -24,7 +25,7 @@ void ScheduledAction::Execute(ExecutionContext*) {
|
||||
return;
|
||||
DartIsolateScope scope(closure_.dart_state()->isolate());
|
||||
DartApiScope api_scope;
|
||||
LogIfError(Dart_InvokeClosure(closure_.value(), 0, nullptr));
|
||||
DartInvokeAppClosure(closure_.value(), 0, nullptr);
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "sky/engine/core/dom/custom/custom_element_callback_scope.h"
|
||||
#include "sky/engine/core/dom/custom/custom_element_registry.h"
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
#include "sky/engine/tonic/dart_state.h"
|
||||
#include "sky/engine/wtf/text/AtomicString.h"
|
||||
|
||||
@ -42,7 +43,7 @@ void CallAttributeDidChangedCallback(RefPtr<Element> element,
|
||||
StringToDart(dart_state, oldValue),
|
||||
StringToDart(dart_state, newValue),
|
||||
};
|
||||
LogIfError(Dart_Invoke(wrapper, callback, arraysize(args), args));
|
||||
DartInvokeAppField(wrapper, callback, arraysize(args), args);
|
||||
}
|
||||
|
||||
void CallDidAttachedCallback(RefPtr<Element> element, RefPtr<Document> document) {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "sky/engine/tonic/dart_class_library.h"
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
#include "sky/engine/tonic/dart_gc_controller.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
#include "sky/engine/tonic/dart_isolate_scope.h"
|
||||
#include "sky/engine/tonic/dart_state.h"
|
||||
#include "sky/engine/tonic/dart_wrappable.h"
|
||||
@ -139,7 +140,7 @@ void DartController::ExecuteLibraryInModule(AbstractModule* module,
|
||||
// TODO(rmacnak): Dart_LookupFunction won't find re-exports, etc.
|
||||
Dart_Handle entry = Dart_LookupFunction(library, ToDart(name));
|
||||
if (module->isApplication()) {
|
||||
LogIfError(Dart_Invoke(library, ToDart(name), 0, nullptr));
|
||||
DartInvokeAppField(library, ToDart(name), 0, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,7 +150,7 @@ void DartController::ExecuteLibraryInModule(AbstractModule* module,
|
||||
Dart_Handle args[] = {
|
||||
ToDart(script),
|
||||
};
|
||||
LogIfError(Dart_Invoke(library, ToDart(name), arraysize(args), args));
|
||||
DartInvokeAppField(library, ToDart(name), arraysize(args), args);
|
||||
}
|
||||
|
||||
static void UnhandledExceptionCallback(Dart_Handle error) {
|
||||
|
||||
@ -23,6 +23,8 @@ source_set("tonic") {
|
||||
"dart_gc_controller.h",
|
||||
"dart_gc_visitor.cc",
|
||||
"dart_gc_visitor.h",
|
||||
"dart_invoke.cc",
|
||||
"dart_invoke.h",
|
||||
"dart_isolate_scope.cc",
|
||||
"dart_isolate_scope.h",
|
||||
"dart_persistent_value.cc",
|
||||
|
||||
29
engine/tonic/dart_invoke.cc
Normal file
29
engine/tonic/dart_invoke.cc
Normal file
@ -0,0 +1,29 @@
|
||||
// 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 "sky/engine/config.h"
|
||||
#include "sky/engine/tonic/dart_invoke.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "sky/engine/tonic/dart_error.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
bool DartInvokeAppField(Dart_Handle target, Dart_Handle name,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments) {
|
||||
TRACE_EVENT0("sky", "DartInvoke::DartInvokeAppField");
|
||||
return LogIfError(Dart_Invoke(target, name, number_of_arguments, arguments));
|
||||
}
|
||||
|
||||
bool DartInvokeAppClosure(Dart_Handle closure,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments) {
|
||||
TRACE_EVENT0("sky", "DartInvoke::DartInvokeAppClosure");
|
||||
return LogIfError(
|
||||
Dart_InvokeClosure(closure, number_of_arguments, arguments));
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
23
engine/tonic/dart_invoke.h
Normal file
23
engine/tonic/dart_invoke.h
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_TONIC_DART_INVOKE_H_
|
||||
#define SKY_ENGINE_TONIC_DART_INVOKE_H_
|
||||
|
||||
#include "dart/runtime/include/dart_api.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
bool DartInvokeAppField(Dart_Handle target, Dart_Handle name,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments);
|
||||
|
||||
bool DartInvokeAppClosure(Dart_Handle closure,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments);
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_TONIC_DART_INVOKE_H_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user