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

Unified Diff: Source/core/testing/Internals.cpp

Issue 23254004: Implement ScriptPromise and ScriptFunction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Control shouldn't reach the end of a non-void function Created 7 years, 4 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
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 496ce9b74b23afd78761ea318afb578b5480d068..7d24d9141391aa8598e11aca4255f7cef39b854d 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -39,6 +39,8 @@
#include "RuntimeEnabledFeatures.h"
#include "TypeConversions.h"
#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/ScriptFunction.h"
+#include "bindings/v8/ScriptPromise.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8ThrowException.h"
#include "core/animation/DocumentTimeline.h"
@@ -2153,4 +2155,35 @@ bool Internals::loseSharedGraphicsContext3D()
return true;
}
+namespace {
+
+class AddOneFunction : public ScriptFunction {
+public:
+ static v8::Handle<v8::Function> create()
+ {
+ AddOneFunction* function = new AddOneFunction;
+ return function->releaseToV8Function();
abarth-chromium 2013/08/19 22:03:19 I'm not 100% happy with this line. I'd rather if
+ }
+
+private:
+ virtual ScriptValue call(ScriptValue value) OVERRIDE
+ {
+ v8::Local<v8::Value> v8Value = value.v8Value();
+ ASSERT(v8Value->IsNumber());
+ int intValue = v8Value.As<v8::Integer>()->Value();
+ ScriptValue result = ScriptValue(v8::Integer::New(intValue + 1));
+ return result;
+ }
+};
+
+}
+
+ScriptValue Internals::addOneToPromise(ScriptValue promise)
+{
+ ScriptValue result;
+ bool success = ScriptPromise(promise).then(AddOneFunction::create(), result);
+ RELEASE_ASSERT(success);
+ return result;
+}
+
}
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698