Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: Source/core/frame/FrameConsole.cpp

Issue 644073003: Fixing crash with sig: blink::FrameConsole::addMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/frame/FrameConsole.h ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 { 78 {
79 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; 79 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage;
80 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource) 80 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource)
81 return; 81 return;
82 82
83 // FIXME: This should not need to reach for the main-frame. 83 // FIXME: This should not need to reach for the main-frame.
84 // Inspector code should just take the current frame and know how to walk it self. 84 // Inspector code should just take the current frame and know how to walk it self.
85 ExecutionContext* context = frame().document(); 85 ExecutionContext* context = frame().document();
86 if (!context) 86 if (!context)
87 return; 87 return;
88 if (!messageStorage())
89 return;
88 90
89 String messageURL; 91 String messageURL;
90 unsigned lineNumber = 0; 92 unsigned lineNumber = 0;
91 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) { 93 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) {
92 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); 94 lineNumber = consoleMessage->callStack()->at(0).lineNumber();
93 messageURL = consoleMessage->callStack()->at(0).sourceURL(); 95 messageURL = consoleMessage->callStack()->at(0).sourceURL();
94 } else { 96 } else {
95 lineNumber = consoleMessage->lineNumber(); 97 lineNumber = consoleMessage->lineNumber();
96 messageURL = consoleMessage->url(); 98 messageURL = consoleMessage->url();
97 } 99 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 160 }
159 161
160 void FrameConsole::unmute() 162 void FrameConsole::unmute()
161 { 163 {
162 ASSERT(muteCount > 0); 164 ASSERT(muteCount > 0);
163 muteCount--; 165 muteCount--;
164 } 166 }
165 167
166 ConsoleMessageStorage* FrameConsole::messageStorage() 168 ConsoleMessageStorage* FrameConsole::messageStorage()
167 { 169 {
168 ASSERT(m_frame->page()); 170 if (!m_frame->host())
169 return &m_frame->page()->frameHost().consoleMessageStorage(); 171 return nullptr;
172 return &m_frame->host()->consoleMessageStorage();
170 } 173 }
171 174
172 void FrameConsole::clearMessages() 175 void FrameConsole::clearMessages()
173 { 176 {
174 messageStorage()->clear(); 177 ConsoleMessageStorage* storage = messageStorage();
178 if (storage)
179 storage->clear();
175 } 180 }
176 181
177 void FrameConsole::adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy* p roxy) 182 void FrameConsole::adoptWorkerMessagesAfterTermination(WorkerGlobalScopeProxy* p roxy)
178 { 183 {
179 messageStorage()->adoptWorkerMessagesAfterTermination(proxy); 184 ConsoleMessageStorage* storage = messageStorage();
185 if (storage)
186 storage->adoptWorkerMessagesAfterTermination(proxy);
180 } 187 }
181 188
182 void FrameConsole::didFailLoading(unsigned long requestIdentifier, const Resourc eError& error) 189 void FrameConsole::didFailLoading(unsigned long requestIdentifier, const Resourc eError& error)
183 { 190 {
184 if (error.isCancellation()) // Report failures only. 191 if (error.isCancellation()) // Report failures only.
185 return; 192 return;
193 ConsoleMessageStorage* storage = messageStorage();
194 if (!storage)
195 return;
186 StringBuilder message; 196 StringBuilder message;
187 message.appendLiteral("Failed to load resource"); 197 message.appendLiteral("Failed to load resource");
188 if (!error.localizedDescription().isEmpty()) { 198 if (!error.localizedDescription().isEmpty()) {
189 message.appendLiteral(": "); 199 message.appendLiteral(": ");
190 message.append(error.localizedDescription()); 200 message.append(error.localizedDescription());
191 } 201 }
192 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(N etworkMessageSource, ErrorMessageLevel, message.toString(), error.failingURL()); 202 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(N etworkMessageSource, ErrorMessageLevel, message.toString(), error.failingURL());
193 consoleMessage->setRequestIdentifier(requestIdentifier); 203 consoleMessage->setRequestIdentifier(requestIdentifier);
194 messageStorage()->reportMessage(consoleMessage.release()); 204 storage->reportMessage(consoleMessage.release());
195 } 205 }
196 206
197 void FrameConsole::trace(Visitor* visitor) 207 void FrameConsole::trace(Visitor* visitor)
198 { 208 {
199 visitor->trace(m_frame); 209 visitor->trace(m_frame);
200 visitor->trace(m_consoleMessageStorage);
201 } 210 }
202 211
203 } // namespace blink 212 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameConsole.h ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698