| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #include "bindings/core/v8/ScriptFunctionCall.h" | 36 #include "bindings/core/v8/ScriptFunctionCall.h" |
| 37 #include "bindings/core/v8/V8Binding.h" | 37 #include "bindings/core/v8/V8Binding.h" |
| 38 #include "core/inspector/InjectedScriptHost.h" | 38 #include "core/inspector/InjectedScriptHost.h" |
| 39 #include "core/inspector/InspectorInstrumentation.h" | 39 #include "core/inspector/InspectorInstrumentation.h" |
| 40 #include "core/inspector/InspectorTraceEvents.h" | 40 #include "core/inspector/InspectorTraceEvents.h" |
| 41 #include "core/inspector/JSONParser.h" | 41 #include "core/inspector/JSONParser.h" |
| 42 #include "platform/JSONValues.h" | 42 #include "platform/JSONValues.h" |
| 43 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 44 | 44 |
| 45 // Includes added for Dart |
| 46 #include "bindings/core/dart/DartHandleProxy.h" |
| 47 #include "bindings/core/dart/DartInjectedScript.h" |
| 48 #include "bindings/core/dart/DartInjectedScriptManager.h" |
| 49 #include "bindings/core/dart/DartPersistentValue.h" |
| 50 #include "bindings/core/dart/DartScriptDebugServer.h" |
| 51 #include "bindings/core/v8/V8RecursionScope.h" |
| 52 |
| 53 #include <dart_api.h> |
| 54 // End of includes added for Dart |
| 55 |
| 45 using blink::TypeBuilder::Array; | 56 using blink::TypeBuilder::Array; |
| 46 using blink::TypeBuilder::Debugger::CallFrame; | 57 using blink::TypeBuilder::Debugger::CallFrame; |
| 47 using blink::TypeBuilder::Debugger::CollectionEntry; | 58 using blink::TypeBuilder::Debugger::CollectionEntry; |
| 48 using blink::TypeBuilder::Debugger::FunctionDetails; | 59 using blink::TypeBuilder::Debugger::FunctionDetails; |
| 49 using blink::TypeBuilder::Debugger::GeneratorObjectDetails; | 60 using blink::TypeBuilder::Debugger::GeneratorObjectDetails; |
| 50 using blink::TypeBuilder::Runtime::PropertyDescriptor; | 61 using blink::TypeBuilder::Runtime::PropertyDescriptor; |
| 51 using blink::TypeBuilder::Runtime::InternalPropertyDescriptor; | 62 using blink::TypeBuilder::Runtime::InternalPropertyDescriptor; |
| 52 using blink::TypeBuilder::Runtime::RemoteObject; | 63 using blink::TypeBuilder::Runtime::RemoteObject; |
| 53 | 64 |
| 54 namespace blink { | 65 namespace blink { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 ASSERT(!hadException); | 379 ASSERT(!hadException); |
| 369 RefPtr<JSONValue> result = toJSONValue(callFramesValue); | 380 RefPtr<JSONValue> result = toJSONValue(callFramesValue); |
| 370 if (result && result->type() == JSONValue::TypeArray) | 381 if (result && result->type() == JSONValue::TypeArray) |
| 371 return Array<CallFrame>::runtimeCast(result); | 382 return Array<CallFrame>::runtimeCast(result); |
| 372 return Array<CallFrame>::create(); | 383 return Array<CallFrame>::create(); |
| 373 } | 384 } |
| 374 | 385 |
| 375 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
ScriptValue& value, const String& groupName, bool generatePreview) const | 386 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const
ScriptValue& value, const String& groupName, bool generatePreview) const |
| 376 { | 387 { |
| 377 ASSERT(!isEmpty()); | 388 ASSERT(!isEmpty()); |
| 389 |
| 390 { |
| 391 // Start of Dart specific code. |
| 392 // This code is required to make objects logged to the console show up w
ith a Dart view. |
| 393 // This hack should go away once custom formatter code is available in C
hrome 47. |
| 394 |
| 395 ScriptState* state = value.scriptState(); |
| 396 v8::Context::Scope v8Scope(state->context()); |
| 397 |
| 398 v8::Handle<v8::Value> v8Handle = value.v8Value(); |
| 399 if (v8Handle->IsObject()) { |
| 400 if (DartHandleProxy::isDartProxy(v8Handle, state->isolate())) { |
| 401 DartPersistentValue* dartPersistentValue = DartHandleProxy::read
PointerFromProxy(v8Handle); |
| 402 // If the isolate is dead we fall back to the default JS view of
the Dart object. |
| 403 if (dartPersistentValue->isIsolateAlive()) { |
| 404 DartScopes scopes(v8Handle.As<v8::Object>()); |
| 405 DartScriptState* scriptState = DartUtilities::currentDartScr
iptState(); |
| 406 DartInjectedScript* dartInjectedScript = DartScriptDebugServ
er::shared().injectedScriptManager()->injectedScriptFor(scriptState); |
| 407 return dartInjectedScript->wrapDartObject(dartPersistentValu
e->value(), groupName, generatePreview); |
| 408 } |
| 409 } |
| 410 } |
| 411 } |
| 412 // End of Dart specific code. |
| 413 |
| 378 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); | 414 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); |
| 379 wrapFunction.appendArgument(value); | 415 wrapFunction.appendArgument(value); |
| 380 wrapFunction.appendArgument(groupName); | 416 wrapFunction.appendArgument(groupName); |
| 381 wrapFunction.appendArgument(canAccessInspectedWindow()); | 417 wrapFunction.appendArgument(canAccessInspectedWindow()); |
| 382 wrapFunction.appendArgument(generatePreview); | 418 wrapFunction.appendArgument(generatePreview); |
| 383 bool hadException = false; | 419 bool hadException = false; |
| 384 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); | 420 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); |
| 385 if (hadException) | 421 if (hadException) |
| 386 return nullptr; | 422 return nullptr; |
| 387 RefPtr<JSONObject> rawResult = toJSONValue(r)->asObject(); | 423 RefPtr<JSONObject> rawResult = toJSONValue(r)->asObject(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().se
tText(text); | 608 *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().se
tText(text); |
| 573 } else { | 609 } else { |
| 574 *result = toJSONValue(resultValue); | 610 *result = toJSONValue(resultValue); |
| 575 if (!*result) | 611 if (!*result) |
| 576 *result = JSONString::create(String::format("Object has too long ref
erence chain(must not be longer than %d)", JSONValue::maxDepth)); | 612 *result = JSONString::create(String::format("Object has too long ref
erence chain(must not be longer than %d)", JSONValue::maxDepth)); |
| 577 } | 613 } |
| 578 } | 614 } |
| 579 | 615 |
| 580 } // namespace blink | 616 } // namespace blink |
| 581 | 617 |
| OLD | NEW |