| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #if !ENABLE(OILPAN) | 57 #if !ENABLE(OILPAN) |
| 58 m_inspectorDOMAgent = nullptr; | 58 m_inspectorDOMAgent = nullptr; |
| 59 m_instrumentingAgents->setPageConsoleAgent(nullptr); | 59 m_instrumentingAgents->setPageConsoleAgent(nullptr); |
| 60 #endif | 60 #endif |
| 61 } | 61 } |
| 62 | 62 |
| 63 DEFINE_TRACE(PageConsoleAgent) | 63 DEFINE_TRACE(PageConsoleAgent) |
| 64 { | 64 { |
| 65 visitor->trace(m_inspectorDOMAgent); | 65 visitor->trace(m_inspectorDOMAgent); |
| 66 visitor->trace(m_inspectedFrames); | 66 visitor->trace(m_inspectedFrames); |
| 67 #if ENABLE(OILPAN) |
| 68 visitor->trace(m_workersWithEnabledConsole); |
| 69 #endif |
| 67 InspectorConsoleAgent::trace(visitor); | 70 InspectorConsoleAgent::trace(visitor); |
| 68 } | 71 } |
| 69 | 72 |
| 70 void PageConsoleAgent::enable(ErrorString* errorString) | 73 void PageConsoleAgent::enable(ErrorString* errorString) |
| 71 { | 74 { |
| 72 InspectorConsoleAgent::enable(errorString); | 75 InspectorConsoleAgent::enable(errorString); |
| 73 m_workersWithEnabledConsole.clear(); | 76 m_workersWithEnabledConsole.clear(); |
| 74 m_instrumentingAgents->setPageConsoleAgent(this); | 77 m_instrumentingAgents->setPageConsoleAgent(this); |
| 75 } | 78 } |
| 76 | 79 |
| 77 void PageConsoleAgent::disable(ErrorString* errorString) | 80 void PageConsoleAgent::disable(ErrorString* errorString) |
| 78 { | 81 { |
| 79 m_instrumentingAgents->setPageConsoleAgent(nullptr); | 82 m_instrumentingAgents->setPageConsoleAgent(nullptr); |
| 80 InspectorConsoleAgent::disable(errorString); | 83 InspectorConsoleAgent::disable(errorString); |
| 84 m_workersWithEnabledConsole.clear(); |
| 81 } | 85 } |
| 82 | 86 |
| 83 void PageConsoleAgent::clearMessages(ErrorString* errorString) | 87 void PageConsoleAgent::clearMessages(ErrorString* errorString) |
| 84 { | 88 { |
| 85 m_inspectorDOMAgent->releaseDanglingNodes(); | 89 m_inspectorDOMAgent->releaseDanglingNodes(); |
| 86 messageStorage()->clear(m_inspectedFrames->root()->document()); | 90 messageStorage()->clear(m_inspectedFrames->root()->document()); |
| 87 } | 91 } |
| 88 | 92 |
| 89 void PageConsoleAgent::workerConsoleAgentEnabled(WorkerGlobalScopeProxy* proxy) | 93 void PageConsoleAgent::workerConsoleAgentEnabled(WorkerInspectorProxy* workerIns
pectorProxy) |
| 90 { | 94 { |
| 91 m_workersWithEnabledConsole.add(proxy); | 95 m_workersWithEnabledConsole.add(workerInspectorProxy); |
| 92 } | 96 } |
| 93 | 97 |
| 94 ConsoleMessageStorage* PageConsoleAgent::messageStorage() | 98 ConsoleMessageStorage* PageConsoleAgent::messageStorage() |
| 95 { | 99 { |
| 96 return &m_inspectedFrames->root()->host()->consoleMessageStorage(); | 100 return &m_inspectedFrames->root()->host()->consoleMessageStorage(); |
| 97 } | 101 } |
| 98 | 102 |
| 99 void PageConsoleAgent::workerTerminated(WorkerInspectorProxy* workerInspectorPro
xy) | 103 void PageConsoleAgent::workerTerminated(WorkerInspectorProxy* workerInspectorPro
xy) |
| 100 { | 104 { |
| 101 WorkerGlobalScopeProxy* proxy = workerInspectorProxy->workerGlobalScopeProxy
(); | 105 WorkerInspectorProxySet::iterator it = m_workersWithEnabledConsole.find(work
erInspectorProxy); |
| 102 if (!proxy) | 106 if (it != m_workersWithEnabledConsole.end()) { |
| 107 m_workersWithEnabledConsole.remove(it); |
| 103 return; | 108 return; |
| 104 | 109 } |
| 105 HashSet<WorkerGlobalScopeProxy*>::iterator iterator = m_workersWithEnabledCo
nsole.find(proxy); | |
| 106 bool workerAgentWasEnabled = iterator != m_workersWithEnabledConsole.end(); | |
| 107 if (workerAgentWasEnabled) | |
| 108 return; | |
| 109 | 110 |
| 110 ConsoleMessageStorage* storage = messageStorage(); | 111 ConsoleMessageStorage* storage = messageStorage(); |
| 111 size_t messageCount = storage->size(); | 112 size_t messageCount = storage->size(); |
| 112 for (size_t i = 0; i < messageCount; ++i) { | 113 for (size_t i = 0; i < messageCount; ++i) { |
| 113 ConsoleMessage* message = storage->at(i); | 114 ConsoleMessage* message = storage->at(i); |
| 114 if (message->workerGlobalScopeProxy() == proxy) { | 115 if (message->workerInspectorProxy() == workerInspectorProxy) { |
| 115 message->setWorkerGlobalScopeProxy(nullptr); | 116 message->setWorkerInspectorProxy(nullptr); |
| 116 sendConsoleMessageToFrontend(message, false); | 117 sendConsoleMessageToFrontend(message, false); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 121 void PageConsoleAgent::enableStackCapturingIfNeeded() | 122 void PageConsoleAgent::enableStackCapturingIfNeeded() |
| 122 { | 123 { |
| 123 if (!s_enabledAgentCount) | 124 if (!s_enabledAgentCount) |
| 124 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), true); | 125 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), true); |
| 125 ++s_enabledAgentCount; | 126 ++s_enabledAgentCount; |
| 126 } | 127 } |
| 127 | 128 |
| 128 void PageConsoleAgent::disableStackCapturingIfNeeded() | 129 void PageConsoleAgent::disableStackCapturingIfNeeded() |
| 129 { | 130 { |
| 130 if (!(--s_enabledAgentCount)) | 131 if (!(--s_enabledAgentCount)) |
| 131 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), false); | 132 ScriptController::setCaptureCallStackForUncaughtExceptions(toIsolate(m_i
nspectedFrames->root()), false); |
| 132 } | 133 } |
| 133 | 134 |
| 134 } // namespace blink | 135 } // namespace blink |
| OLD | NEW |