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

Side by Side Diff: Source/core/inspector/InspectorConsoleAgent.cpp

Issue 185713007: DevTools: Add timestamp support in the console (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed apavlov's comments Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 static const char consoleMessagesEnabled[] = "consoleMessagesEnabled"; 60 static const char consoleMessagesEnabled[] = "consoleMessagesEnabled";
61 } 61 }
62 62
63 int InspectorConsoleAgent::s_enabledAgentCount = 0; 63 int InspectorConsoleAgent::s_enabledAgentCount = 0;
64 64
65 InspectorConsoleAgent::InspectorConsoleAgent(InspectorTimelineAgent* timelineAge nt, InjectedScriptManager* injectedScriptManager) 65 InspectorConsoleAgent::InspectorConsoleAgent(InspectorTimelineAgent* timelineAge nt, InjectedScriptManager* injectedScriptManager)
66 : InspectorBaseAgent<InspectorConsoleAgent>("Console") 66 : InspectorBaseAgent<InspectorConsoleAgent>("Console")
67 , m_timelineAgent(timelineAgent) 67 , m_timelineAgent(timelineAgent)
68 , m_injectedScriptManager(injectedScriptManager) 68 , m_injectedScriptManager(injectedScriptManager)
69 , m_frontend(0) 69 , m_frontend(0)
70 , m_previousMessage(0)
71 , m_expiredConsoleMessageCount(0) 70 , m_expiredConsoleMessageCount(0)
72 , m_enabled(false) 71 , m_enabled(false)
73 { 72 {
74 } 73 }
75 74
76 InspectorConsoleAgent::~InspectorConsoleAgent() 75 InspectorConsoleAgent::~InspectorConsoleAgent()
77 { 76 {
78 m_instrumentingAgents->setInspectorConsoleAgent(0); 77 m_instrumentingAgents->setInspectorConsoleAgent(0);
79 m_instrumentingAgents = 0; 78 m_instrumentingAgents = 0;
80 m_state = 0; 79 m_state = 0;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 m_enabled = false; 114 m_enabled = false;
116 if (!(--s_enabledAgentCount)) 115 if (!(--s_enabledAgentCount))
117 ScriptController::setCaptureCallStackForUncaughtExceptions(false); 116 ScriptController::setCaptureCallStackForUncaughtExceptions(false);
118 m_state->setBoolean(ConsoleAgentState::consoleMessagesEnabled, false); 117 m_state->setBoolean(ConsoleAgentState::consoleMessagesEnabled, false);
119 } 118 }
120 119
121 void InspectorConsoleAgent::clearMessages(ErrorString*) 120 void InspectorConsoleAgent::clearMessages(ErrorString*)
122 { 121 {
123 m_consoleMessages.clear(); 122 m_consoleMessages.clear();
124 m_expiredConsoleMessageCount = 0; 123 m_expiredConsoleMessageCount = 0;
125 m_previousMessage = 0;
126 m_injectedScriptManager->releaseObjectGroup("console"); 124 m_injectedScriptManager->releaseObjectGroup("console");
127 if (m_frontend && m_enabled) 125 if (m_frontend && m_enabled)
128 m_frontend->messagesCleared(); 126 m_frontend->messagesCleared();
129 } 127 }
130 128
131 void InspectorConsoleAgent::reset() 129 void InspectorConsoleAgent::reset()
132 { 130 {
133 ErrorString error; 131 ErrorString error;
134 clearMessages(&error); 132 clearMessages(&error);
135 m_times.clear(); 133 m_times.clear();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 message.append(error.localizedDescription()); 293 message.append(error.localizedDescription());
296 } 294 }
297 addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0, 0, requestIdentifier); 295 addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0, 0, requestIdentifier);
298 } 296 }
299 297
300 void InspectorConsoleAgent::setMonitoringXHREnabled(ErrorString*, bool enabled) 298 void InspectorConsoleAgent::setMonitoringXHREnabled(ErrorString*, bool enabled)
301 { 299 {
302 m_state->setBoolean(ConsoleAgentState::monitoringXHR, enabled); 300 m_state->setBoolean(ConsoleAgentState::monitoringXHR, enabled);
303 } 301 }
304 302
305 static bool isGroupMessage(MessageType type)
306 {
307 return type == StartGroupMessageType
308 || type == StartGroupCollapsedMessageType
309 || type == EndGroupMessageType;
310 }
311 303
312 void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console Message) 304 void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console Message)
313 { 305 {
314 ASSERT_ARG(consoleMessage, consoleMessage); 306 ASSERT_ARG(consoleMessage, consoleMessage);
315 307
316 if (m_previousMessage && !isGroupMessage(m_previousMessage->type()) && m_pre viousMessage->isEqual(consoleMessage.get())) { 308 ConsoleMessage* msg = consoleMessage.get();
apavlov 2014/03/21 14:47:58 Blink style does not honor abbreviations. Moreover
317 m_previousMessage->incrementCount(); 309 m_consoleMessages.append(consoleMessage);
318 if (m_frontend && m_enabled) 310 if (m_frontend && m_enabled)
319 m_previousMessage->updateRepeatCountInConsole(m_frontend); 311 msg->addToFrontend(m_frontend, m_injectedScriptManager, true);
320 } else {
321 m_previousMessage = consoleMessage.get();
322 m_consoleMessages.append(consoleMessage);
323 if (m_frontend && m_enabled)
324 m_previousMessage->addToFrontend(m_frontend, m_injectedScriptManager , true);
325 }
326 312
327 if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) { 313 if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) {
328 m_expiredConsoleMessageCount += expireConsoleMessagesStep; 314 m_expiredConsoleMessageCount += expireConsoleMessagesStep;
329 m_consoleMessages.remove(0, expireConsoleMessagesStep); 315 m_consoleMessages.remove(0, expireConsoleMessagesStep);
330 } 316 }
331 } 317 }
332 318
333 class InspectableHeapObject FINAL : public InjectedScriptHost::InspectableObject { 319 class InspectableHeapObject FINAL : public InjectedScriptHost::InspectableObject {
334 public: 320 public:
335 explicit InspectableHeapObject(int heapObjectId) : m_heapObjectId(heapObject Id) { } 321 explicit InspectableHeapObject(int heapObjectId) : m_heapObjectId(heapObject Id) { }
336 virtual ScriptValue get(ScriptState*) OVERRIDE 322 virtual ScriptValue get(ScriptState*) OVERRIDE
337 { 323 {
338 return ScriptProfiler::objectByHeapObjectId(m_heapObjectId); 324 return ScriptProfiler::objectByHeapObjectId(m_heapObjectId);
339 } 325 }
340 private: 326 private:
341 int m_heapObjectId; 327 int m_heapObjectId;
342 }; 328 };
343 329
344 void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHe apObjectId) 330 void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHe apObjectId)
345 { 331 {
346 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableHeapObject(inspectedHeapObjectId))); 332 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableHeapObject(inspectedHeapObjectId)));
347 } 333 }
348 334
349 } // namespace WebCore 335 } // namespace WebCore
350 336
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698