Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(977)

Unified Diff: sky/engine/bindings-dart/core/dart/DartCallback.cpp

Issue 875013003: Import Dart bindings as of Blink r188698. This merely copies the files over and does not attach any… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/bindings-dart/core/dart/DartCallback.cpp
diff --git a/sky/engine/bindings/core/v8/custom/V8ErrorEventCustom.cpp b/sky/engine/bindings-dart/core/dart/DartCallback.cpp
similarity index 55%
copy from sky/engine/bindings/core/v8/custom/V8ErrorEventCustom.cpp
copy to sky/engine/bindings-dart/core/dart/DartCallback.cpp
index c68f1661132acfcdb0c42fdfc25eb527d832c1f4..ef8058a26c401fa5756abad21b402c01f6c40d66 100644
--- a/sky/engine/bindings/core/v8/custom/V8ErrorEventCustom.cpp
+++ b/sky/engine/bindings-dart/core/dart/DartCallback.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2006-2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,29 +28,49 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "sky/engine/config.h"
-#include "bindings/core/v8/V8ErrorEvent.h"
+#include "config.h"
+#include "bindings/core/dart/DartCallback.h"
-#include "bindings/core/v8/V8Event.h"
-#include "gen/sky/platform/RuntimeEnabledFeatures.h"
-#include "sky/engine/bindings/core/v8/DOMWrapperWorld.h"
-#include "sky/engine/bindings/core/v8/Dictionary.h"
-#include "sky/engine/bindings/core/v8/SerializedScriptValue.h"
-#include "sky/engine/bindings/core/v8/V8Binding.h"
-#include "sky/engine/bindings/core/v8/V8DOMWrapper.h"
-#include "sky/engine/bindings/core/v8/V8HiddenValue.h"
+#include "bindings/core/dart/DartController.h"
+#include "bindings/core/dart/DartDOMData.h"
+#include "bindings/core/dart/DartUtilities.h"
namespace blink {
-void V8ErrorEvent::errorAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
+DartCallback::DartCallback(Dart_Handle object, Dart_Handle& exception)
{
- v8::Handle<v8::Value> error = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::error(info.GetIsolate()));
- if (!error.IsEmpty()) {
- v8SetReturnValue(info, error);
+ if (!Dart_IsClosure(object)) {
+ exception = Dart_NewStringFromCString("Callback must be a function");
+ m_callback = 0;
return;
}
+ m_callback = Dart_NewPersistentHandle(object);
+}
+
+DartCallback::~DartCallback()
+{
+ if (!m_callback || !isIsolateAlive())
+ return;
+
+ DartIsolateScope scope(isolate());
+ Dart_DeletePersistentHandle(m_callback);
+}
- v8SetReturnValueNull(info);
+bool DartCallback::handleEvent(int argc, Dart_Handle* argv)
+{
+ ASSERT(isolate() == Dart_CurrentIsolate());
+ ASSERT(m_callback);
+
+ ExecutionContext* context = DartDOMData::current()->scriptExecutionContext();
+ DartController* dartController = DartController::retrieve(context);
+
+ Dart_Handle result = dartController->callFunction(Dart_HandleFromPersistent(m_callback), argc, argv);
+ if (Dart_IsError(result)) {
+ DartUtilities::reportProblem(context, result);
+ return false;
+ }
+
+ return true;
}
-} // namespace blink
+}
« no previous file with comments | « sky/engine/bindings-dart/core/dart/DartCallback.h ('k') | sky/engine/bindings-dart/core/dart/DartController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698