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

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: Created 6 years, 3 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/frame/LocalDOMWindow.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 15 matching lines...) Expand all
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 "config.h" 29 #include "config.h"
30 #include "core/frame/FrameConsole.h" 30 #include "core/frame/FrameConsole.h"
31 31
32 #include "bindings/core/v8/ScriptCallStackFactory.h" 32 #include "bindings/core/v8/ScriptCallStackFactory.h"
33 #include "core/frame/FrameHost.h" 33 #include "core/frame/FrameHost.h"
34 #include "core/inspector/ConsoleAPITypes.h" 34 #include "core/inspector/ConsoleAPITypes.h"
35 #include "core/inspector/ConsoleMessage.h" 35 #include "core/inspector/ConsoleMessage.h"
36 #include "core/inspector/ConsoleMessageStorage.h"
36 #include "core/inspector/InspectorConsoleInstrumentation.h" 37 #include "core/inspector/InspectorConsoleInstrumentation.h"
37 #include "core/inspector/ScriptCallStack.h" 38 #include "core/inspector/ScriptCallStack.h"
38 #include "core/page/Chrome.h" 39 #include "core/page/Chrome.h"
39 #include "core/page/ChromeClient.h" 40 #include "core/page/ChromeClient.h"
40 #include "core/page/Page.h" 41 #include "core/page/Page.h"
41 #include "core/workers/WorkerGlobalScopeProxy.h" 42 #include "core/workers/WorkerGlobalScopeProxy.h"
42 #include "wtf/text/StringBuilder.h" 43 #include "wtf/text/StringBuilder.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 namespace { 47 namespace {
47 48
48 int muteCount = 0; 49 int muteCount = 0;
49 50
50 } 51 }
51 52
52 FrameConsole::FrameConsole(LocalFrame& frame) 53 FrameConsole::FrameConsole(LocalFrame& frame)
53 : m_frame(frame) 54 : m_frame(frame)
54 { 55 {
55 } 56 }
56 57
58 FrameConsole::~FrameConsole()
59 {
60 }
61
57 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM essage) 62 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM essage)
58 { 63 {
59 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; 64 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage;
60 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource) 65 if (muteCount && consoleMessage->source() != ConsoleAPIMessageSource)
61 return; 66 return;
62 67
63 // FIXME: This should not need to reach for the main-frame. 68 // FIXME: This should not need to reach for the main-frame.
64 // Inspector code should just take the current frame and know how to walk it self. 69 // Inspector code should just take the current frame and know how to walk it self.
65 ExecutionContext* context = m_frame.document(); 70 ExecutionContext* context = m_frame.document();
66 if (!context) 71 if (!context)
67 return; 72 return;
68 73
69 InspectorInstrumentation::addMessageToConsole(context, consoleMessage.get()) ;
70
71 if (consoleMessage->source() == CSSMessageSource)
72 return;
73
74 String messageURL; 74 String messageURL;
75 unsigned lineNumber = 0; 75 unsigned lineNumber = 0;
76 if (consoleMessage->callStack()) { 76 if (consoleMessage->callStack() && consoleMessage->callStack()->size()) {
77 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); 77 lineNumber = consoleMessage->callStack()->at(0).lineNumber();
78 messageURL = consoleMessage->callStack()->at(0).sourceURL(); 78 messageURL = consoleMessage->callStack()->at(0).sourceURL();
79 } else { 79 } else {
80 lineNumber = consoleMessage->lineNumber(); 80 lineNumber = consoleMessage->lineNumber();
81 messageURL = consoleMessage->url(); 81 messageURL = consoleMessage->url();
82 } 82 }
83 83
84 messageStorage()->reportMessage(consoleMessage);
85
86 if (consoleMessage->source() == CSSMessageSource)
87 return;
88
84 RefPtrWillBeRawPtr<ScriptCallStack> reportedCallStack = nullptr; 89 RefPtrWillBeRawPtr<ScriptCallStack> reportedCallStack = nullptr;
85 if (consoleMessage->source() != ConsoleAPIMessageSource) { 90 if (consoleMessage->source() != ConsoleAPIMessageSource) {
86 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDe tailedMessageForSource(messageURL)) 91 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDe tailedMessageForSource(messageURL))
87 reportedCallStack = consoleMessage->callStack(); 92 reportedCallStack = consoleMessage->callStack();
88 } else { 93 } else {
89 if (!m_frame.host() || (consoleMessage->scriptArguments() && consoleMess age->scriptArguments()->argumentCount() == 0)) 94 if (!m_frame.host() || (consoleMessage->scriptArguments() && consoleMess age->scriptArguments()->argumentCount() == 0))
90 return; 95 return;
91 96
92 MessageType type = consoleMessage->type(); 97 MessageType type = consoleMessage->type();
93 if (type == StartGroupMessageType || type == EndGroupMessageType || type == StartGroupCollapsedMessageType) 98 if (type == StartGroupMessageType || type == EndGroupMessageType || type == StartGroupCollapsedMessageType)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 { 130 {
126 muteCount++; 131 muteCount++;
127 } 132 }
128 133
129 void FrameConsole::unmute() 134 void FrameConsole::unmute()
130 { 135 {
131 ASSERT(muteCount > 0); 136 ASSERT(muteCount > 0);
132 muteCount--; 137 muteCount--;
133 } 138 }
134 139
140 ConsoleMessageStorage* FrameConsole::messageStorage()
141 {
142 LocalFrame* curFrame = &m_frame;
143 Frame* topFrame = curFrame->tree().top();
144 ASSERT(topFrame->isLocalFrame());
145 LocalFrame* localTopFrame = toLocalFrame(topFrame);
146 if (localTopFrame != curFrame)
147 return localTopFrame->console().messageStorage();
148 if (!m_consoleMessageStorage)
149 m_consoleMessageStorage = ConsoleMessageStorage::createForFrame(&m_frame );
150 return m_consoleMessageStorage.get();
151 }
152
135 void FrameConsole::adoptWorkerConsoleMessages(WorkerGlobalScopeProxy* proxy) 153 void FrameConsole::adoptWorkerConsoleMessages(WorkerGlobalScopeProxy* proxy)
136 { 154 {
137 InspectorInstrumentation::adoptWorkerConsoleMessages(m_frame.document(), pro xy); 155 InspectorInstrumentation::adoptWorkerConsoleMessages(m_frame.document(), pro xy);
138 } 156 }
139 157
140 } // namespace blink 158 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameConsole.h ('k') | Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698