| OLD | NEW |
| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/frame/FrameConsole.h" | 36 #include "core/frame/FrameConsole.h" |
| 37 #include "core/frame/FrameHost.h" | 37 #include "core/frame/FrameHost.h" |
| 38 #include "core/inspector/ConsoleMessage.h" | 38 #include "core/inspector/ConsoleMessage.h" |
| 39 #include "core/inspector/ConsoleMessageStorage.h" | 39 #include "core/inspector/ConsoleMessageStorage.h" |
| 40 #include "core/inspector/InspectedFrames.h" | 40 #include "core/inspector/InspectedFrames.h" |
| 41 #include "core/inspector/InspectorDOMAgent.h" | 41 #include "core/inspector/InspectorDOMAgent.h" |
| 42 #include "core/workers/WorkerInspectorProxy.h" | |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 int PageConsoleAgent::s_enabledAgentCount = 0; | 45 int PageConsoleAgent::s_enabledAgentCount = 0; |
| 47 | 46 |
| 48 PageConsoleAgent::PageConsoleAgent(V8InspectorSession* v8Session, InspectorDOMAg
ent* domAgent, InspectedFrames* inspectedFrames) | 47 PageConsoleAgent::PageConsoleAgent(V8InspectorSession* v8Session, InspectorDOMAg
ent* domAgent, InspectedFrames* inspectedFrames) |
| 49 : InspectorConsoleAgent(v8Session) | 48 : InspectorConsoleAgent(v8Session) |
| 50 , m_inspectorDOMAgent(domAgent) | 49 , m_inspectorDOMAgent(domAgent) |
| 51 , m_inspectedFrames(inspectedFrames) | 50 , m_inspectedFrames(inspectedFrames) |
| 52 { | 51 { |
| 53 } | 52 } |
| 54 | 53 |
| 55 PageConsoleAgent::~PageConsoleAgent() | 54 PageConsoleAgent::~PageConsoleAgent() |
| 56 { | 55 { |
| 57 } | 56 } |
| 58 | 57 |
| 59 DEFINE_TRACE(PageConsoleAgent) | 58 DEFINE_TRACE(PageConsoleAgent) |
| 60 { | 59 { |
| 61 visitor->trace(m_inspectorDOMAgent); | 60 visitor->trace(m_inspectorDOMAgent); |
| 62 visitor->trace(m_inspectedFrames); | 61 visitor->trace(m_inspectedFrames); |
| 63 visitor->trace(m_workersWithEnabledConsole); | |
| 64 InspectorConsoleAgent::trace(visitor); | 62 InspectorConsoleAgent::trace(visitor); |
| 65 } | 63 } |
| 66 | 64 |
| 67 void PageConsoleAgent::enable(ErrorString* errorString) | 65 void PageConsoleAgent::enable(ErrorString* errorString) |
| 68 { | 66 { |
| 69 InspectorConsoleAgent::enable(errorString); | 67 InspectorConsoleAgent::enable(errorString); |
| 70 m_workersWithEnabledConsole.clear(); | |
| 71 m_instrumentingAgents->addPageConsoleAgent(this); | |
| 72 } | 68 } |
| 73 | 69 |
| 74 void PageConsoleAgent::disable(ErrorString* errorString) | 70 void PageConsoleAgent::disable(ErrorString* errorString) |
| 75 { | 71 { |
| 76 m_instrumentingAgents->removePageConsoleAgent(this); | |
| 77 InspectorConsoleAgent::disable(errorString); | 72 InspectorConsoleAgent::disable(errorString); |
| 78 m_workersWithEnabledConsole.clear(); | |
| 79 } | 73 } |
| 80 | 74 |
| 81 void PageConsoleAgent::clearMessages(ErrorString* errorString) | 75 void PageConsoleAgent::clearMessages(ErrorString* errorString) |
| 82 { | 76 { |
| 83 messageStorage()->clear(m_inspectedFrames->root()->document()); | 77 messageStorage()->clear(m_inspectedFrames->root()->document()); |
| 84 } | 78 } |
| 85 | 79 |
| 86 void PageConsoleAgent::workerConsoleAgentEnabled(WorkerInspectorProxy* workerIns
pectorProxy) | |
| 87 { | |
| 88 m_workersWithEnabledConsole.add(workerInspectorProxy); | |
| 89 } | |
| 90 | |
| 91 ConsoleMessageStorage* PageConsoleAgent::messageStorage() | 80 ConsoleMessageStorage* PageConsoleAgent::messageStorage() |
| 92 { | 81 { |
| 93 return &m_inspectedFrames->root()->host()->consoleMessageStorage(); | 82 return &m_inspectedFrames->root()->host()->consoleMessageStorage(); |
| 94 } | 83 } |
| 95 | 84 |
| 96 void PageConsoleAgent::workerTerminated(WorkerInspectorProxy* workerInspectorPro
xy) | |
| 97 { | |
| 98 WorkerInspectorProxySet::iterator it = m_workersWithEnabledConsole.find(work
erInspectorProxy); | |
| 99 if (it != m_workersWithEnabledConsole.end()) { | |
| 100 m_workersWithEnabledConsole.remove(it); | |
| 101 return; | |
| 102 } | |
| 103 | |
| 104 ConsoleMessageStorage* storage = messageStorage(); | |
| 105 size_t messageCount = storage->size(); | |
| 106 for (size_t i = 0; i < messageCount; ++i) { | |
| 107 ConsoleMessage* message = storage->at(i); | |
| 108 if (message->workerInspectorProxy() == workerInspectorProxy) { | |
| 109 message->setWorkerInspectorProxy(nullptr); | |
| 110 sendConsoleMessageToFrontend(message, false); | |
| 111 } | |
| 112 } | |
| 113 } | |
| 114 | |
| 115 void PageConsoleAgent::consoleMessagesCleared() | 85 void PageConsoleAgent::consoleMessagesCleared() |
| 116 { | 86 { |
| 117 m_inspectorDOMAgent->releaseDanglingNodes(); | 87 m_inspectorDOMAgent->releaseDanglingNodes(); |
| 118 InspectorConsoleAgent::consoleMessagesCleared(); | 88 InspectorConsoleAgent::consoleMessagesCleared(); |
| 119 } | 89 } |
| 120 | 90 |
| 121 void PageConsoleAgent::enableStackCapturingIfNeeded() | 91 void PageConsoleAgent::enableStackCapturingIfNeeded() |
| 122 { | 92 { |
| 123 if (!s_enabledAgentCount) | 93 if (!s_enabledAgentCount) |
| 124 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), true); | 94 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), true); |
| 125 ++s_enabledAgentCount; | 95 ++s_enabledAgentCount; |
| 126 } | 96 } |
| 127 | 97 |
| 128 void PageConsoleAgent::disableStackCapturingIfNeeded() | 98 void PageConsoleAgent::disableStackCapturingIfNeeded() |
| 129 { | 99 { |
| 130 if (!(--s_enabledAgentCount)) | 100 if (!(--s_enabledAgentCount)) |
| 131 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), false); | 101 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), false); |
| 132 } | 102 } |
| 133 | 103 |
| 134 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |