| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 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 | 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. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "core/frame/FrameConsole.h" | 29 #include "core/frame/FrameConsole.h" |
| 30 | 30 |
| 31 #include "bindings/core/v8/SourceLocation.h" | 31 #include "bindings/core/v8/SourceLocation.h" |
| 32 #include "core/frame/FrameHost.h" | 32 #include "core/frame/FrameHost.h" |
| 33 #include "core/inspector/ConsoleMessage.h" | 33 #include "core/inspector/ConsoleMessage.h" |
| 34 #include "core/inspector/IdentifiersFactory.h" | |
| 35 #include "core/inspector/MainThreadDebugger.h" | 34 #include "core/inspector/MainThreadDebugger.h" |
| 36 #include "core/page/ChromeClient.h" | 35 #include "core/page/ChromeClient.h" |
| 37 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
| 38 #include "platform/network/ResourceError.h" | 37 #include "platform/network/ResourceError.h" |
| 39 #include "platform/network/ResourceResponse.h" | 38 #include "platform/network/ResourceResponse.h" |
| 40 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
| 41 #include <memory> | 40 #include <memory> |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 FrameConsole::FrameConsole(LocalFrame& frame) | 44 FrameConsole::FrameConsole(LocalFrame& frame) |
| 46 : m_frame(&frame) | 45 : m_frame(&frame) |
| 47 { | 46 { |
| 48 } | 47 } |
| 49 | 48 |
| 50 void FrameConsole::addMessage(ConsoleMessage* consoleMessage) | 49 void FrameConsole::addMessage(ConsoleMessage* consoleMessage) |
| 51 { | 50 { |
| 52 if (addMessageToStorage(consoleMessage)) | 51 if (addMessageToStorage(consoleMessage)) |
| 53 reportMessageToClient(consoleMessage); | 52 reportMessageToClient(consoleMessage); |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool FrameConsole::addMessageToStorage(ConsoleMessage* consoleMessage) | 55 bool FrameConsole::addMessageToStorage(ConsoleMessage* consoleMessage) |
| 57 { | 56 { |
| 58 // TODO(dgozman): drop this check, it's left here to preserve tests output. | 57 // TODO(dgozman): drop this check, it's left here to preserve tests output. |
| 59 if (!m_frame->document()) | 58 if (!m_frame->document()) |
| 60 return false; | 59 return false; |
| 61 MainThreadDebugger* debugger = MainThreadDebugger::instance(); | 60 return MainThreadDebugger::instance()->addConsoleMessage(m_frame, consoleMes
sage); |
| 62 return debugger->debugger()->addConsoleMessage( | |
| 63 debugger->contextGroupId(m_frame), | |
| 64 consoleMessage->source(), | |
| 65 consoleMessage->level(), | |
| 66 consoleMessage->message(), | |
| 67 consoleMessage->location()->url(), | |
| 68 consoleMessage->location()->lineNumber(), | |
| 69 consoleMessage->location()->columnNumber(), | |
| 70 consoleMessage->location()->cloneStackTrace(), | |
| 71 consoleMessage->location()->scriptId(), | |
| 72 IdentifiersFactory::requestId(consoleMessage->requestIdentifier()), | |
| 73 consoleMessage->workerId()); | |
| 74 } | 61 } |
| 75 | 62 |
| 76 void FrameConsole::reportMessageToClient(ConsoleMessage* consoleMessage) | 63 void FrameConsole::reportMessageToClient(ConsoleMessage* consoleMessage) |
| 77 { | 64 { |
| 78 if (consoleMessage->source() == NetworkMessageSource) | 65 if (consoleMessage->source() == NetworkMessageSource) |
| 79 return; | 66 return; |
| 80 | 67 |
| 81 String url = consoleMessage->location()->url(); | 68 String url = consoleMessage->location()->url(); |
| 82 String stackTrace; | 69 String stackTrace; |
| 83 if (consoleMessage->source() == ConsoleAPIMessageSource) { | 70 if (consoleMessage->source() == ConsoleAPIMessageSource) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 114 } |
| 128 addMessageToStorage(ConsoleMessage::createForRequest(NetworkMessageSource, E
rrorMessageLevel, message.toString(), error.failingURL(), requestIdentifier)); | 115 addMessageToStorage(ConsoleMessage::createForRequest(NetworkMessageSource, E
rrorMessageLevel, message.toString(), error.failingURL(), requestIdentifier)); |
| 129 } | 116 } |
| 130 | 117 |
| 131 DEFINE_TRACE(FrameConsole) | 118 DEFINE_TRACE(FrameConsole) |
| 132 { | 119 { |
| 133 visitor->trace(m_frame); | 120 visitor->trace(m_frame); |
| 134 } | 121 } |
| 135 | 122 |
| 136 } // namespace blink | 123 } // namespace blink |
| OLD | NEW |