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

Side by Side Diff: Source/core/inspector/ConsoleMessage.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/inspector/ConsoleMessage.h ('k') | Source/core/inspector/ConsoleMessageStorage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/inspector/ConsoleMessage.h" 6 #include "core/inspector/ConsoleMessage.h"
7 7
8 #include "bindings/core/v8/ScriptCallStackFactory.h"
8 #include "bindings/core/v8/ScriptValue.h" 9 #include "bindings/core/v8/ScriptValue.h"
9 #include "core/inspector/ScriptArguments.h" 10 #include "core/inspector/ScriptArguments.h"
11 #include "wtf/CurrentTime.h"
12 #include "wtf/PassOwnPtr.h"
10 13
11 namespace blink { 14 namespace blink {
12 15
13 ConsoleMessage::ConsoleMessage(MessageSource source, 16 ConsoleMessage::ConsoleMessage(MessageSource source,
14 MessageLevel level, 17 MessageLevel level,
15 const String& message, 18 const String& message,
16 const String& url, 19 const String& url,
17 unsigned lineNumber, 20 unsigned lineNumber,
18 unsigned columnNumber) 21 unsigned columnNumber)
19 : m_source(source) 22 : m_source(source)
20 , m_level(level) 23 , m_level(level)
21 , m_type(LogMessageType) 24 , m_type(LogMessageType)
22 , m_message(message) 25 , m_message(message)
23 , m_url(url) 26 , m_url(url)
24 , m_lineNumber(lineNumber) 27 , m_lineNumber(lineNumber)
25 , m_columnNumber(columnNumber) 28 , m_columnNumber(columnNumber)
26 , m_requestIdentifier(0) 29 , m_requestIdentifier(0)
30 , m_timestamp(WTF::currentTime())
27 , m_workerProxy(nullptr) 31 , m_workerProxy(nullptr)
28 { 32 {
29 } 33 }
30 34
31 ConsoleMessage::~ConsoleMessage() 35 ConsoleMessage::~ConsoleMessage()
32 { 36 {
33 } 37 }
34 38
35 MessageType ConsoleMessage::type() const 39 MessageType ConsoleMessage::type() const
36 { 40 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 78
75 ScriptState* ConsoleMessage::scriptState() const 79 ScriptState* ConsoleMessage::scriptState() const
76 { 80 {
77 if (m_scriptState) 81 if (m_scriptState)
78 return m_scriptState->get(); 82 return m_scriptState->get();
79 return nullptr; 83 return nullptr;
80 } 84 }
81 85
82 void ConsoleMessage::setScriptState(ScriptState* scriptState) 86 void ConsoleMessage::setScriptState(ScriptState* scriptState)
83 { 87 {
88 if (m_scriptState)
89 m_scriptState->clear();
90
84 if (scriptState) 91 if (scriptState)
85 m_scriptState = adoptPtr(new ScriptStateProtectingContext(scriptState)); 92 m_scriptState = adoptPtr(new ScriptStateProtectingContext(scriptState));
86 else 93 else
87 m_scriptState.clear(); 94 m_scriptState.clear();
88 } 95 }
89 96
90 PassRefPtrWillBeRawPtr<ScriptArguments> ConsoleMessage::scriptArguments() const 97 PassRefPtrWillBeRawPtr<ScriptArguments> ConsoleMessage::scriptArguments() const
91 { 98 {
92 return m_scriptArguments; 99 return m_scriptArguments;
93 } 100 }
94 101
95 void ConsoleMessage::setScriptArguments(PassRefPtrWillBeRawPtr<ScriptArguments> scriptArguments) 102 void ConsoleMessage::setScriptArguments(PassRefPtrWillBeRawPtr<ScriptArguments> scriptArguments)
96 { 103 {
97 m_scriptArguments = scriptArguments; 104 m_scriptArguments = scriptArguments;
98 } 105 }
99 106
100 unsigned long ConsoleMessage::requestIdentifier() const 107 unsigned long ConsoleMessage::requestIdentifier() const
101 { 108 {
102 return m_requestIdentifier; 109 return m_requestIdentifier;
103 } 110 }
104 111
105 void ConsoleMessage::setRequestIdentifier(unsigned long requestIdentifier) 112 void ConsoleMessage::setRequestIdentifier(unsigned long requestIdentifier)
106 { 113 {
107 m_requestIdentifier = requestIdentifier; 114 m_requestIdentifier = requestIdentifier;
108 } 115 }
109 116
117 double ConsoleMessage::timestamp() const
118 {
119 return m_timestamp;
120 }
121
122 void ConsoleMessage::setTimestamp(double timestamp)
123 {
124 m_timestamp = timestamp;
125 }
126
110 MessageSource ConsoleMessage::source() const 127 MessageSource ConsoleMessage::source() const
111 { 128 {
112 return m_source; 129 return m_source;
113 } 130 }
114 131
115 MessageLevel ConsoleMessage::level() const 132 MessageLevel ConsoleMessage::level() const
116 { 133 {
117 return m_level; 134 return m_level;
118 } 135 }
119 136
120 const String& ConsoleMessage::message() const 137 const String& ConsoleMessage::message() const
121 { 138 {
122 return m_message; 139 return m_message;
123 } 140 }
124 141
125 unsigned ConsoleMessage::columnNumber() const 142 unsigned ConsoleMessage::columnNumber() const
126 { 143 {
127 return m_columnNumber; 144 return m_columnNumber;
128 } 145 }
129 146
147 void ConsoleMessage::frameWindowDiscarded(LocalDOMWindow* window)
148 {
149 if (scriptState() && scriptState()->domWindow() == window)
150 setScriptState(nullptr);
151
152 if (!m_scriptArguments)
153 return;
154 if (m_scriptArguments->scriptState()->domWindow() != window)
155 return;
156 if (!m_message)
157 m_message = "<message collected>";
158 m_scriptArguments.clear();
159 }
160
161 unsigned ConsoleMessage::argumentCount()
162 {
163 if (m_scriptArguments)
164 return m_scriptArguments->argumentCount();
165 return 0;
166 }
167
168 void ConsoleMessage::collectCallStack()
169 {
170 if (m_type == EndGroupMessageType)
171 return;
172
173 if (!m_callStack || m_source == ConsoleAPIMessageSource)
174 m_callStack = createScriptCallStackForConsole(ScriptCallStack::maxCallSt ackSizeToCapture, true);
175
176 if (m_callStack && m_callStack->size()) {
177 const ScriptCallFrame& frame = m_callStack->at(0);
178 m_url = frame.sourceURL();
179 m_lineNumber = frame.lineNumber();
180 m_columnNumber = frame.columnNumber();
181 return;
182 }
183
184 m_callStack.clear();
185 }
186
130 void ConsoleMessage::trace(Visitor* visitor) 187 void ConsoleMessage::trace(Visitor* visitor)
131 { 188 {
132 visitor->trace(m_callStack); 189 visitor->trace(m_callStack);
133 visitor->trace(m_scriptArguments); 190 visitor->trace(m_scriptArguments);
134 } 191 }
135 192
136 } // namespace blink 193 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/ConsoleMessage.h ('k') | Source/core/inspector/ConsoleMessageStorage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698