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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 int muteCount = 0; | 50 int muteCount = 0; |
51 | 51 |
52 } | 52 } |
53 | 53 |
54 FrameConsole::FrameConsole(LocalFrame& frame) | 54 FrameConsole::FrameConsole(LocalFrame& frame) |
55 : m_frame(frame) | 55 : m_frame(&frame) |
56 { | 56 { |
57 } | 57 } |
58 | 58 |
59 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameConsole); | 59 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameConsole); |
60 | 60 |
61 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM
essage) | 61 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM
essage) |
62 { | 62 { |
63 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; | 63 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; |
64 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource) | 64 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource) |
65 return; | 65 return; |
66 | 66 |
67 // FIXME: This should not need to reach for the main-frame. | 67 // FIXME: This should not need to reach for the main-frame. |
68 // Inspector code should just take the current frame and know how to walk it
self. | 68 // Inspector code should just take the current frame and know how to walk it
self. |
69 ExecutionContext* context = m_frame.document(); | 69 ExecutionContext* context = m_frame->document(); |
70 if (!context) | 70 if (!context) |
71 return; | 71 return; |
72 | 72 |
73 String messageURL; | 73 String messageURL; |
74 unsigned lineNumber = 0; | 74 unsigned lineNumber = 0; |
75 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) { | 75 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) { |
76 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); | 76 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); |
77 messageURL = consoleMessage->callStack()->at(0).sourceURL(); | 77 messageURL = consoleMessage->callStack()->at(0).sourceURL(); |
78 } else { | 78 } else { |
79 lineNumber = consoleMessage->lineNumber(); | 79 lineNumber = consoleMessage->lineNumber(); |
80 messageURL = consoleMessage->url(); | 80 messageURL = consoleMessage->url(); |
81 } | 81 } |
82 | 82 |
83 messageStorage()->reportMessage(consoleMessage); | 83 messageStorage()->reportMessage(consoleMessage); |
84 | 84 |
85 if (consoleMessage->source() == CSSMessageSource || consoleMessage->source()
== NetworkMessageSource) | 85 if (consoleMessage->source() == CSSMessageSource || consoleMessage->source()
== NetworkMessageSource) |
86 return; | 86 return; |
87 | 87 |
88 RefPtrWillBeRawPtr<ScriptCallStack> reportedCallStack = nullptr; | 88 RefPtrWillBeRawPtr<ScriptCallStack> reportedCallStack = nullptr; |
89 if (consoleMessage->source() != ConsoleAPIMessageSource) { | 89 if (consoleMessage->source() != ConsoleAPIMessageSource) { |
90 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDe
tailedMessageForSource(messageURL)) | 90 if (consoleMessage->callStack() && m_frame->chromeClient().shouldReportD
etailedMessageForSource(messageURL)) |
91 reportedCallStack = consoleMessage->callStack(); | 91 reportedCallStack = consoleMessage->callStack(); |
92 } else { | 92 } else { |
93 if (!m_frame.host() || (consoleMessage->scriptArguments() && consoleMess
age->scriptArguments()->argumentCount() == 0)) | 93 if (!m_frame->host() || (consoleMessage->scriptArguments() && !consoleMe
ssage->scriptArguments()->argumentCount())) |
94 return; | 94 return; |
95 | 95 |
96 MessageType type = consoleMessage->type(); | 96 MessageType type = consoleMessage->type(); |
97 if (type == StartGroupMessageType || type == EndGroupMessageType || type
== StartGroupCollapsedMessageType) | 97 if (type == StartGroupMessageType || type == EndGroupMessageType || type
== StartGroupCollapsedMessageType) |
98 return; | 98 return; |
99 | 99 |
100 if (m_frame.chromeClient().shouldReportDetailedMessageForSource(messageU
RL)) | 100 if (m_frame->chromeClient().shouldReportDetailedMessageForSource(message
URL)) |
101 reportedCallStack = createScriptCallStack(ScriptCallStack::maxCallSt
ackSizeToCapture); | 101 reportedCallStack = createScriptCallStack(ScriptCallStack::maxCallSt
ackSizeToCapture); |
102 } | 102 } |
103 | 103 |
104 String stackTrace; | 104 String stackTrace; |
105 if (reportedCallStack) | 105 if (reportedCallStack) |
106 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag
e(), reportedCallStack); | 106 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag
e(), reportedCallStack); |
107 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source(
), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, s
tackTrace); | 107 m_frame->chromeClient().addMessageToConsole(m_frame, consoleMessage->source(
), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, s
tackTrace); |
108 } | 108 } |
109 | 109 |
110 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign
ed long requestIdentifier, const ResourceResponse& response) | 110 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign
ed long requestIdentifier, const ResourceResponse& response) |
111 { | 111 { |
112 if (!loader) | 112 if (!loader) |
113 return; | 113 return; |
114 if (response.httpStatusCode() < 400) | 114 if (response.httpStatusCode() < 400) |
115 return; | 115 return; |
116 String message = "Failed to load resource: the server responded with a statu
s of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusT
ext() + ')'; | 116 String message = "Failed to load resource: the server responded with a statu
s of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusT
ext() + ')'; |
117 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(N
etworkMessageSource, ErrorMessageLevel, message, response.url().string()); | 117 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(N
etworkMessageSource, ErrorMessageLevel, message, response.url().string()); |
(...skipping 25 matching lines...) Expand all Loading... |
143 } | 143 } |
144 | 144 |
145 void FrameConsole::unmute() | 145 void FrameConsole::unmute() |
146 { | 146 { |
147 ASSERT(muteCount > 0); | 147 ASSERT(muteCount > 0); |
148 muteCount--; | 148 muteCount--; |
149 } | 149 } |
150 | 150 |
151 ConsoleMessageStorage* FrameConsole::messageStorage() | 151 ConsoleMessageStorage* FrameConsole::messageStorage() |
152 { | 152 { |
153 LocalFrame* curFrame = &m_frame; | 153 LocalFrame* curFrame = m_frame; |
154 Frame* topFrame = curFrame->tree().top(); | 154 Frame* topFrame = curFrame->tree().top(); |
155 ASSERT(topFrame->isLocalFrame()); | 155 ASSERT(topFrame->isLocalFrame()); |
156 LocalFrame* localTopFrame = toLocalFrame(topFrame); | 156 LocalFrame* localTopFrame = toLocalFrame(topFrame); |
157 if (localTopFrame != curFrame) | 157 if (localTopFrame != curFrame) |
158 return localTopFrame->console().messageStorage(); | 158 return localTopFrame->console().messageStorage(); |
159 if (!m_consoleMessageStorage) | 159 if (!m_consoleMessageStorage) |
160 m_consoleMessageStorage = ConsoleMessageStorage::createForFrame(&m_frame
); | 160 m_consoleMessageStorage = ConsoleMessageStorage::createForFrame(m_frame)
; |
161 return m_consoleMessageStorage.get(); | 161 return m_consoleMessageStorage.get(); |
162 } | 162 } |
163 | 163 |
164 void FrameConsole::adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy* p
roxy) | 164 void FrameConsole::adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy* p
roxy) |
165 { | 165 { |
166 ConsoleMessageStorage* storage = messageStorage(); | 166 ConsoleMessageStorage* storage = messageStorage(); |
167 size_t messageCount = storage->size(); | 167 size_t messageCount = storage->size(); |
168 for (size_t i = 0; i < messageCount; ++i) { | 168 for (size_t i = 0; i < messageCount; ++i) { |
169 if (storage->at(i)->workerGlobalScopeProxy() == proxy) | 169 if (storage->at(i)->workerGlobalScopeProxy() == proxy) |
170 storage->at(i)->setWorkerGlobalScopeProxy(nullptr); | 170 storage->at(i)->setWorkerGlobalScopeProxy(nullptr); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 void FrameConsole::trace(Visitor* visitor) | 174 void FrameConsole::trace(Visitor* visitor) |
175 { | 175 { |
| 176 visitor->trace(m_frame); |
176 visitor->trace(m_consoleMessageStorage); | 177 visitor->trace(m_consoleMessageStorage); |
177 } | 178 } |
178 | 179 |
179 } // namespace blink | 180 } // namespace blink |
OLD | NEW |