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

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

Issue 464293002: [DevTools] ConsoleMessage storage moved from ConsoleAgent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@remove-can-generate
Patch Set: Rebased Created 6 years, 4 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (muteCount) 58 if (muteCount)
59 return; 59 return;
60 60
61 // FIXME: This should not need to reach for the main-frame. 61 // FIXME: This should not need to reach for the main-frame.
62 // Inspector code should just take the current frame and know how to walk it self. 62 // Inspector code should just take the current frame and know how to walk it self.
63 ExecutionContext* context = m_frame.document(); 63 ExecutionContext* context = m_frame.document();
64 if (!context) 64 if (!context)
65 return; 65 return;
66 66
67 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; 67 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage;
68 InspectorInstrumentation::addMessageToConsole(context, consoleMessage.get()) ;
69 68
69 unsigned lineNumber = consoleMessage->lineNumber();
vsevik 2014/08/14 08:06:21 This one is worth a comment, or even a FIXME since
kozyatinskiy1 2014/08/20 13:44:18 It was moved to another patch.
70 String messageURL; 70 String messageURL;
71 if (consoleMessage->callStack()) 71 if (consoleMessage->callStack() && consoleMessage->callStack()->size())
72 messageURL = consoleMessage->callStack()->at(0).sourceURL(); 72 messageURL = consoleMessage->callStack()->at(0).sourceURL();
73 else 73 else
74 messageURL = consoleMessage->url(); 74 messageURL = consoleMessage->url();
75 75
76 ConsoleMessageStorage* storage = messageStorage();
vsevik 2014/08/14 08:06:21 This method does two things 1) Report the message
kozyatinskiy1 2014/08/20 13:44:18 Done.
77 if (storage)
vsevik 2014/08/14 08:06:21 Let's assume this is never null and move Inspect
kozyatinskiy1 2014/08/20 13:44:18 Done.
78 storage->addMessage(consoleMessage);
79 InspectorInstrumentation::addMessageToConsole(context, consoleMessage);
80
76 if (consoleMessage->source() == CSSMessageSource) 81 if (consoleMessage->source() == CSSMessageSource)
77 return; 82 return;
78 83
79 String stackTrace; 84 String stackTrace;
80 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDetail edMessageForSource(consoleMessage->url())) 85 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDetail edMessageForSource(consoleMessage->url()))
81 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag e(), consoleMessage->callStack()); 86 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag e(), consoleMessage->callStack());
82 87
83 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), consoleMessage->lineNumbe r(), messageURL, stackTrace); 88 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, s tackTrace);
84 } 89 }
85 90
86 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack) 91 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack)
87 { 92 {
88 StringBuilder stackTrace; 93 StringBuilder stackTrace;
89 for (size_t i = 0; i < callStack->size(); ++i) { 94 for (size_t i = 0; i < callStack->size(); ++i) {
90 const ScriptCallFrame& frame = callStack->at(i); 95 const ScriptCallFrame& frame = callStack->at(i);
91 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 96 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
92 stackTrace.append(" ("); 97 stackTrace.append(" (");
93 stackTrace.append(frame.sourceURL()); 98 stackTrace.append(frame.sourceURL());
(...skipping 16 matching lines...) Expand all
110 { 115 {
111 ASSERT(muteCount > 0); 116 ASSERT(muteCount > 0);
112 muteCount--; 117 muteCount--;
113 } 118 }
114 119
115 void FrameConsole::adoptWorkerConsoleMessages(WorkerGlobalScopeProxy* proxy) 120 void FrameConsole::adoptWorkerConsoleMessages(WorkerGlobalScopeProxy* proxy)
116 { 121 {
117 InspectorInstrumentation::adoptWorkerConsoleMessages(m_frame.document(), pro xy); 122 InspectorInstrumentation::adoptWorkerConsoleMessages(m_frame.document(), pro xy);
118 } 123 }
119 124
125 ConsoleMessageStorage* FrameConsole::messageStorage()
126 {
vsevik 2014/08/14 08:06:22 LocalFrame* localTopFrame = toLocalFrame(curFrame-
kozyatinskiy1 2014/08/20 13:44:18 Done.
127 LocalFrame* curFrame = &m_frame;
128 // traversal to top frame
129 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame())
130 curFrame = toLocalFrame(curFrame->tree().parent());
131
132 // if top is current - return storage
133 if (curFrame == &m_frame) {
134 if (m_consoleMessageStorage.get())
135 return m_consoleMessageStorage.get();
136 m_consoleMessageStorage = ConsoleMessageStorage::create();
137 return m_consoleMessageStorage.get();
138 }
139
140 // if top is local - return storage
141 if (curFrame->isLocalFrame())
142 return curFrame->console().messageStorage();
143
144 return nullptr;
145 }
146
120 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698