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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return types; | 60 return types; |
61 } | 61 } |
62 | 62 |
63 namespace { | 63 namespace { |
64 | 64 |
65 int muteCount = 0; | 65 int muteCount = 0; |
66 | 66 |
67 } | 67 } |
68 | 68 |
69 FrameConsole::FrameConsole(LocalFrame& frame) | 69 FrameConsole::FrameConsole(LocalFrame& frame) |
70 : m_frame(frame) | 70 : m_frame(&frame) |
71 { | 71 { |
72 } | 72 } |
73 | 73 |
74 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameConsole); | 74 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameConsole); |
75 | 75 |
76 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM
essage) | 76 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM
essage) |
77 { | 77 { |
78 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; | 78 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; |
79 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource) | 79 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource) |
80 return; | 80 return; |
81 | 81 |
82 // FIXME: This should not need to reach for the main-frame. | 82 // FIXME: This should not need to reach for the main-frame. |
83 // Inspector code should just take the current frame and know how to walk it
self. | 83 // Inspector code should just take the current frame and know how to walk it
self. |
84 ExecutionContext* context = m_frame.document(); | 84 ExecutionContext* context = m_frame->document(); |
85 if (!context) | 85 if (!context) |
86 return; | 86 return; |
87 | 87 |
88 String messageURL; | 88 String messageURL; |
89 unsigned lineNumber = 0; | 89 unsigned lineNumber = 0; |
90 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) { | 90 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) { |
91 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); | 91 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); |
92 messageURL = consoleMessage->callStack()->at(0).sourceURL(); | 92 messageURL = consoleMessage->callStack()->at(0).sourceURL(); |
93 } else { | 93 } else { |
94 lineNumber = consoleMessage->lineNumber(); | 94 lineNumber = consoleMessage->lineNumber(); |
95 messageURL = consoleMessage->url(); | 95 messageURL = consoleMessage->url(); |
96 } | 96 } |
97 | 97 |
98 messageStorage()->reportMessage(consoleMessage); | 98 messageStorage()->reportMessage(consoleMessage); |
99 | 99 |
100 if (consoleMessage->source() == CSSMessageSource || consoleMessage->source()
== NetworkMessageSource) | 100 if (consoleMessage->source() == CSSMessageSource || consoleMessage->source()
== NetworkMessageSource) |
101 return; | 101 return; |
102 | 102 |
103 RefPtrWillBeRawPtr<ScriptCallStack> reportedCallStack = nullptr; | 103 RefPtrWillBeRawPtr<ScriptCallStack> reportedCallStack = nullptr; |
104 if (consoleMessage->source() != ConsoleAPIMessageSource) { | 104 if (consoleMessage->source() != ConsoleAPIMessageSource) { |
105 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDe
tailedMessageForSource(messageURL)) | 105 if (consoleMessage->callStack() && m_frame->chromeClient().shouldReportD
etailedMessageForSource(messageURL)) |
106 reportedCallStack = consoleMessage->callStack(); | 106 reportedCallStack = consoleMessage->callStack(); |
107 } else { | 107 } else { |
108 if (!m_frame.host() || (consoleMessage->scriptArguments() && consoleMess
age->scriptArguments()->argumentCount() == 0)) | 108 if (!m_frame->host() || (consoleMessage->scriptArguments() && !consoleMe
ssage->scriptArguments()->argumentCount())) |
109 return; | 109 return; |
110 | 110 |
111 if (!allClientReportingMessageTypes().contains(consoleMessage->type())) | 111 if (!allClientReportingMessageTypes().contains(consoleMessage->type())) |
112 return; | 112 return; |
113 | 113 |
114 if (m_frame.chromeClient().shouldReportDetailedMessageForSource(messageU
RL)) | 114 if (m_frame->chromeClient().shouldReportDetailedMessageForSource(message
URL)) |
115 reportedCallStack = createScriptCallStack(ScriptCallStack::maxCallSt
ackSizeToCapture); | 115 reportedCallStack = createScriptCallStack(ScriptCallStack::maxCallSt
ackSizeToCapture); |
116 } | 116 } |
117 | 117 |
118 String stackTrace; | 118 String stackTrace; |
119 if (reportedCallStack) | 119 if (reportedCallStack) |
120 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag
e(), reportedCallStack); | 120 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag
e(), reportedCallStack); |
121 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source(
), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, s
tackTrace); | 121 m_frame->chromeClient().addMessageToConsole(m_frame, consoleMessage->source(
), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, s
tackTrace); |
122 } | 122 } |
123 | 123 |
124 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign
ed long requestIdentifier, const ResourceResponse& response) | 124 void FrameConsole::reportResourceResponseReceived(DocumentLoader* loader, unsign
ed long requestIdentifier, const ResourceResponse& response) |
125 { | 125 { |
126 if (!loader) | 126 if (!loader) |
127 return; | 127 return; |
128 if (response.httpStatusCode() < 400) | 128 if (response.httpStatusCode() < 400) |
129 return; | 129 return; |
130 String message = "Failed to load resource: the server responded with a statu
s of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusT
ext() + ')'; | 130 String message = "Failed to load resource: the server responded with a statu
s of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusT
ext() + ')'; |
131 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(N
etworkMessageSource, ErrorMessageLevel, message, response.url().string()); | 131 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(N
etworkMessageSource, ErrorMessageLevel, message, response.url().string()); |
(...skipping 25 matching lines...) Expand all Loading... |
157 } | 157 } |
158 | 158 |
159 void FrameConsole::unmute() | 159 void FrameConsole::unmute() |
160 { | 160 { |
161 ASSERT(muteCount > 0); | 161 ASSERT(muteCount > 0); |
162 muteCount--; | 162 muteCount--; |
163 } | 163 } |
164 | 164 |
165 ConsoleMessageStorage* FrameConsole::messageStorage() | 165 ConsoleMessageStorage* FrameConsole::messageStorage() |
166 { | 166 { |
167 LocalFrame* curFrame = &m_frame; | 167 LocalFrame* curFrame = m_frame; |
168 Frame* topFrame = curFrame->tree().top(); | 168 Frame* topFrame = curFrame->tree().top(); |
169 ASSERT(topFrame->isLocalFrame()); | 169 ASSERT(topFrame->isLocalFrame()); |
170 LocalFrame* localTopFrame = toLocalFrame(topFrame); | 170 LocalFrame* localTopFrame = toLocalFrame(topFrame); |
171 if (localTopFrame != curFrame) | 171 if (localTopFrame != curFrame) |
172 return localTopFrame->console().messageStorage(); | 172 return localTopFrame->console().messageStorage(); |
173 if (!m_consoleMessageStorage) | 173 if (!m_consoleMessageStorage) |
174 m_consoleMessageStorage = ConsoleMessageStorage::createForFrame(&m_frame
); | 174 m_consoleMessageStorage = ConsoleMessageStorage::createForFrame(m_frame)
; |
175 return m_consoleMessageStorage.get(); | 175 return m_consoleMessageStorage.get(); |
176 } | 176 } |
177 | 177 |
178 void FrameConsole::clearMessages() | 178 void FrameConsole::clearMessages() |
179 { | 179 { |
180 messageStorage()->clear(); | 180 messageStorage()->clear(); |
181 } | 181 } |
182 | 182 |
183 void FrameConsole::adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy* p
roxy) | 183 void FrameConsole::adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy* p
roxy) |
184 { | 184 { |
185 messageStorage()->adoptWorkerMessagesAfterTermination(proxy); | 185 messageStorage()->adoptWorkerMessagesAfterTermination(proxy); |
186 } | 186 } |
187 | 187 |
188 void FrameConsole::trace(Visitor* visitor) | 188 void FrameConsole::trace(Visitor* visitor) |
189 { | 189 { |
| 190 visitor->trace(m_frame); |
190 visitor->trace(m_consoleMessageStorage); | 191 visitor->trace(m_consoleMessageStorage); |
191 } | 192 } |
192 | 193 |
193 } // namespace blink | 194 } // namespace blink |
OLD | NEW |