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

Unified Diff: Source/bindings/v8/V8ScriptRunner.cpp

Issue 15294004: Implement V8ScriptRunner::compileAndRunInternalScript() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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/bindings/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8ScriptRunner.cpp
diff --git a/Source/bindings/v8/V8ScriptRunner.cpp b/Source/bindings/v8/V8ScriptRunner.cpp
index c4ddf18073efa8e4b7a8f09c38325c19449bc3a1..042183342f9ce6bc974218e895bbb294875d24a2 100644
--- a/Source/bindings/v8/V8ScriptRunner.cpp
+++ b/Source/bindings/v8/V8ScriptRunner.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "bindings/v8/V8ScriptRunner.h"
+#include "bindings/v8/ScopedPersistent.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8GCController.h"
#include "bindings/v8/V8RecursionScope.h"
@@ -62,4 +63,30 @@ v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> sc
return result;
}
+v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8::String> source, v8::Isolate* isolate)
+{
+ v8::HandleScope handleScope;
abarth-chromium 2013/05/17 16:21:12 There's a HandleScope here.
+ ScopedPersistent<v8::Context> context;
+ v8::Local<v8::Value> result;
abarth-chromium 2013/05/17 16:21:12 result is a local handle.
+ context.set(v8::Context::New(isolate));
+ if (context.isEmpty())
+ return result;
+
+ {
+ v8::Context::Scope scope(context.get());
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Script> script = v8::Script::Compile(source);
+ if (script.IsEmpty() || tryCatch.HasCaught())
+ return result;
+
+ V8RecursionScope::MicrotaskSuppression recursionScope;
+ result = script->Run();
+ if (tryCatch.HasCaught())
+ return result;
abarth-chromium 2013/05/17 16:21:12 ... and we return it.... Isn't that a memory corr
haraken 2013/05/17 16:23:41 Great catch... I have to use HandleScope::Close().
haraken 2013/05/20 00:32:59 Fixed the stale handlescope issue.
+ }
+
+ context.clear();
+ return result;
+}
+
} // namespace WebCore
« no previous file with comments | « Source/bindings/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698