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

Unified Diff: Source/bindings/dart/DartHandleProxy.cpp

Issue 24989007: Model each Dart library as its own ScriptState when devtools are enabled. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 2 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/dart/DartHandleProxy.h ('k') | Source/bindings/dart/DartInjectedScriptHost.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartHandleProxy.cpp
diff --git a/Source/bindings/dart/DartHandleProxy.cpp b/Source/bindings/dart/DartHandleProxy.cpp
index 9cc0ed0a4c4b5617f94635ba583ee4a6b75c739b..a17fb8d6e2a0c65037cc6692a76d267cc8a50743 100644
--- a/Source/bindings/dart/DartHandleProxy.cpp
+++ b/Source/bindings/dart/DartHandleProxy.cpp
@@ -58,22 +58,24 @@ DartScriptValue* readPointerFromProxy(v8::Handle<v8::Value> proxy)
return static_cast<DartScriptValue*>(pointer);
}
-DartScopes::DartScopes(v8::Local<v8::Object> v8Handle) :
+DartScopes::DartScopes(v8::Local<v8::Object> v8Handle, bool disableBreak) :
scriptValue(readPointerFromProxy(v8Handle)),
- scope(scriptValue->isolate())
+ scope(scriptValue->isolate()),
+ disableBreak(disableBreak)
{
ASSERT(scriptValue->isIsolateAlive());
handle = scriptValue->value();
- previousPauseInfo = Dart_GetExceptionPauseInfo();
- // FIXME: it is not clear this is the right long term solution but for
- // now we prevent pausing on exceptions when executing Dart code to
- // avoid crashing when handling an exception triggers an exception.
- Dart_SetExceptionPauseInfo(kNoPauseOnExceptions);
+ if (disableBreak) {
+ previousPauseInfo = Dart_GetExceptionPauseInfo();
+ Dart_SetExceptionPauseInfo(kNoPauseOnExceptions);
+ }
}
DartScopes::~DartScopes()
{
- Dart_SetExceptionPauseInfo(previousPauseInfo);
+ if (disableBreak) {
+ Dart_SetExceptionPauseInfo(previousPauseInfo);
+ }
}
@@ -1085,4 +1087,52 @@ v8::Handle<v8::Value> DartHandleProxy::createLocalScopeProxy(Dart_Handle localVa
return proxy;
}
+v8::Handle<v8::Value> DartHandleProxy::evaluate(Dart_Handle target, Dart_Handle expression, Dart_Handle localVariables)
+{
+ ASSERT(Dart_IsList(localVariables) || Dart_IsNull(localVariables));
+ intptr_t localVariablesLength = 0;
+ Dart_ListLength(localVariables, &localVariablesLength);
+
+ Dart_Handle wrapExpressionArgs[2] = { expression, localVariables };
+ Dart_Handle exception = 0;
+ bool ret = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("isJsExpression", 1, &expression), exception);
+ ASSERT(!exception);
+ if (ret) {
+ // FIXME(dartbug.com/13468): remove this hacky fallback of invoking JS
+ // code when we believe a JS code fragment generated by the chrome
+ // developer tools was passed to us rather than a fragment of true
+ // Dart code.
+ ASSERT(!v8::Context::GetCurrent().IsEmpty());
+ v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(V8Converter::stringToV8(expression), v8::Isolate::GetCurrent());
+ return result;
+ }
+
+ Dart_Handle wrappedExpressionTuple =
+ DartUtilities::invokeUtilsMethod("wrapExpressionAsClosure", 2, wrapExpressionArgs);
+ ASSERT(Dart_IsList(wrappedExpressionTuple));
+ Dart_Handle wrappedExpression = Dart_ListGetAt(wrappedExpressionTuple, 0);
+ Dart_Handle wrappedExpressionArgs = Dart_ListGetAt(wrappedExpressionTuple, 1);
+
+ ASSERT(Dart_IsString(wrappedExpression));
+ Dart_Handle closure = Dart_EvaluateExpr(target, wrappedExpression);
+ // There was a parse error. FIXME: consider cleaning up the line numbers in
+ // the error message.
+ if (Dart_IsError(closure))
+ return V8ThrowException::throwError(v8::String::New(Dart_GetError(closure)));
+
+ // Invoke the closure passing in the expression arguments specified by
+ // wrappedExpressionTuple.
+ ASSERT(Dart_IsClosure(closure));
+ intptr_t length = 0;
+ Dart_ListLength(wrappedExpressionArgs, &length);
+ Vector<Dart_Handle> dartFunctionArgs;
+ for (uint32_t i = 0; i < length; i ++)
+ dartFunctionArgs.append(Dart_ListGetAt(wrappedExpressionArgs, i));
+
+ Dart_Handle result = Dart_InvokeClosure(closure, dartFunctionArgs.size(), dartFunctionArgs.data());
+ if (Dart_IsError(result))
+ return V8ThrowException::throwError(v8::String::New(Dart_GetError(result)));
+ return DartHandleProxy::create(result);
+}
+
}
« no previous file with comments | « Source/bindings/dart/DartHandleProxy.h ('k') | Source/bindings/dart/DartInjectedScriptHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698