OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions |
| 6 * are met: |
| 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. |
| 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 14 * its contributors may be used to endorse or promote products derived |
| 15 * from this software without specific prior written permission. |
| 16 * |
| 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
| 28 |
| 29 #include "config.h" |
| 30 #include "bindings/core/dart/DartInspectorConsoleMessage.h" |
| 31 |
| 32 #include "bindings/common/ScriptValue.h" |
| 33 #include "bindings/core/dart/DartDOMData.h" |
| 34 #include "bindings/core/dart/DartHandleProxy.h" |
| 35 #include "bindings/core/dart/DartInjectedScript.h" |
| 36 #include "bindings/core/dart/DartInjectedScriptManager.h" |
| 37 #include "bindings/core/dart/DartUtilities.h" |
| 38 #include "core/inspector/ConsoleMessage.h" |
| 39 #include "core/inspector/IdentifiersFactory.h" |
| 40 #include "core/inspector/InjectedScriptManager.h" |
| 41 #include "core/inspector/InspectorConsoleAgent.h" |
| 42 #include "core/inspector/ScriptCallStack.h" |
| 43 |
| 44 namespace blink { |
| 45 |
| 46 void DartInspectorConsoleMessage::addToFrontend(InspectorFrontend::Console* fron
tend, InjectedScriptManager* injectedScriptManager, bool generatePreview, Consol
eMessage* consoleMessage, PassRefPtr<TypeBuilder::Console::ConsoleMessage> jsonO
bj) |
| 47 { |
| 48 DartScriptState* scriptState = DartUtilities::currentScriptState(); |
| 49 ASSERT(scriptState != 0); |
| 50 |
| 51 DartInjectedScriptManager* dartInjectedScriptManager = injectedScriptManager
->dartInjectedScriptManager(); |
| 52 jsonObj->setExecutionContextId(dartInjectedScriptManager->injectedScriptIdFo
r(scriptState)); |
| 53 if (consoleMessage->source() == NetworkMessageSource && consoleMessage->requ
estIdentifier()) |
| 54 jsonObj->setNetworkRequestId(IdentifiersFactory::requestId(consoleMessag
e->requestIdentifier())); |
| 55 if (consoleMessage->scriptArguments() && consoleMessage->scriptArguments()->
argumentCount()) { |
| 56 DartInjectedScript* injectedScript = dartInjectedScriptManager->injected
ScriptFor(scriptState); |
| 57 ASSERT(injectedScript != 0); |
| 58 |
| 59 if (injectedScript) { |
| 60 RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > json
Args = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create(); |
| 61 if (consoleMessage->type() == TableMessageType && generatePreview &&
consoleMessage->scriptArguments()->argumentCount()) { |
| 62 ScriptValue table = consoleMessage->scriptArguments()->argumentA
t(0); |
| 63 ScriptValue columns = consoleMessage->scriptArguments()->argumen
tCount() > 1 ? consoleMessage->scriptArguments()->argumentAt(1) : ScriptValue(); |
| 64 RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = inje
ctedScript->wrapTable(table, columns); |
| 65 if (!inspectorValue) { |
| 66 ASSERT_NOT_REACHED(); |
| 67 return; |
| 68 } |
| 69 jsonArgs->addItem(inspectorValue); |
| 70 } else { |
| 71 for (unsigned i = 0; i < consoleMessage->scriptArguments()->argu
mentCount(); ++i) { |
| 72 ScriptValue value = consoleMessage->scriptArguments()->argum
entAt(i); |
| 73 |
| 74 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 75 |
| 76 RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue; |
| 77 v8::Handle<v8::Value> v8Value = value.v8ValueUnsafe(); |
| 78 |
| 79 if (DartHandleProxy::isDartProxy(v8Value)) { |
| 80 Dart_Handle dartValue = DartHandleProxy::unwrapValue(v8V
alue); |
| 81 inspectorValue = injectedScript->wrapDartObject(dartValu
e, "console", generatePreview); |
| 82 } else { |
| 83 inspectorValue = injectedScript->wrapObject(consoleMessa
ge->scriptArguments()->argumentAt(i), "console", generatePreview); |
| 84 } |
| 85 if (!inspectorValue) { |
| 86 ASSERT_NOT_REACHED(); |
| 87 return; |
| 88 } |
| 89 jsonArgs->addItem(inspectorValue); |
| 90 } |
| 91 } |
| 92 jsonObj->setParameters(jsonArgs); |
| 93 } |
| 94 } |
| 95 if (consoleMessage->callStack()) { |
| 96 // FIXMEDART: is the call stack right? |
| 97 jsonObj->setStackTrace(consoleMessage->callStack()->buildInspectorArray(
)); |
| 98 } |
| 99 frontend->messageAdded(jsonObj); |
| 100 frontend->flush(); |
| 101 } |
| 102 |
| 103 } // namespace blink |
OLD | NEW |