Index: third_party/WebKit/Source/core/inspector/InspectorWorkerAgent.cpp |
diff --git a/third_party/WebKit/Source/core/inspector/InspectorWorkerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorWorkerAgent.cpp |
index e009c7bbd6cd1c19a6705a98da5de2326a4423c6..3595d89ed35536fbc1a1a988a9ee83bf2867db49 100644 |
--- a/third_party/WebKit/Source/core/inspector/InspectorWorkerAgent.cpp |
+++ b/third_party/WebKit/Source/core/inspector/InspectorWorkerAgent.cpp |
@@ -41,6 +41,7 @@ namespace blink { |
namespace WorkerAgentState { |
static const char autoAttach[] = "autoAttach"; |
static const char waitForDebuggerOnStart[] = "waitForDebuggerOnStart"; |
+static const char attachedWorkerIds[] = "attachedWorkerIds"; |
}; |
InspectorWorkerAgent::InspectorWorkerAgent(InspectedFrames* inspectedFrames) |
@@ -52,6 +53,10 @@ void InspectorWorkerAgent::restore() { |
if (!autoAttachEnabled()) |
return; |
m_instrumentingAgents->addInspectorWorkerAgent(this); |
+ protocol::DictionaryValue* attached = attachedWorkerIds(); |
+ for (size_t i = 0; i < attached->size(); ++i) |
+ frontend()->detachedFromTarget(attached->at(i).first); |
+ m_state->remove(WorkerAgentState::attachedWorkerIds); |
connectToAllProxies(); |
} |
@@ -62,6 +67,7 @@ Response InspectorWorkerAgent::disable() { |
} |
m_state->setBoolean(WorkerAgentState::autoAttach, false); |
m_state->setBoolean(WorkerAgentState::waitForDebuggerOnStart, false); |
+ m_state->remove(WorkerAgentState::attachedWorkerIds); |
return Response::OK(); |
} |
@@ -122,6 +128,7 @@ void InspectorWorkerAgent::workerTerminated(WorkerInspectorProxy* proxy) { |
DCHECK(frontend() && autoAttachEnabled()); |
if (m_connectedProxies.find(proxy->inspectorId()) == m_connectedProxies.end()) |
return; |
+ attachedWorkerIds()->remove(proxy->inspectorId()); |
frontend()->detachedFromTarget(proxy->inspectorId()); |
proxy->disconnectFromInspector(this); |
m_connectedProxies.erase(proxy->inspectorId()); |
@@ -137,8 +144,10 @@ void InspectorWorkerAgent::connectToAllProxies() { |
void InspectorWorkerAgent::disconnectFromAllProxies(bool reportToFrontend) { |
for (auto& idProxy : m_connectedProxies) { |
- if (reportToFrontend) |
+ if (reportToFrontend) { |
+ attachedWorkerIds()->remove(idProxy.key); |
frontend()->detachedFromTarget(idProxy.key); |
+ } |
idProxy.value->disconnectFromInspector(this); |
} |
m_connectedProxies.clear(); |
@@ -152,17 +161,31 @@ void InspectorWorkerAgent::didCommitLoadForLocalFrame(LocalFrame* frame) { |
// Usually, it's fine to report them terminated later, but some tests |
// expect strict set of workers, and we reuse renderer between tests. |
for (auto& idProxy : m_connectedProxies) { |
+ attachedWorkerIds()->remove(idProxy.key); |
frontend()->detachedFromTarget(idProxy.key); |
idProxy.value->disconnectFromInspector(this); |
} |
m_connectedProxies.clear(); |
} |
+protocol::DictionaryValue* InspectorWorkerAgent::attachedWorkerIds() { |
+ protocol::DictionaryValue* ids = |
+ m_state->getObject(WorkerAgentState::attachedWorkerIds); |
+ if (!ids) { |
+ std::unique_ptr<protocol::DictionaryValue> newIds = |
+ protocol::DictionaryValue::create(); |
+ ids = newIds.get(); |
+ m_state->setObject(WorkerAgentState::attachedWorkerIds, std::move(newIds)); |
+ } |
+ return ids; |
+} |
+ |
void InspectorWorkerAgent::connectToProxy(WorkerInspectorProxy* proxy, |
bool waitingForDebugger) { |
m_connectedProxies.set(proxy->inspectorId(), proxy); |
proxy->connectToInspector(this); |
DCHECK(frontend()); |
+ attachedWorkerIds()->setBoolean(proxy->inspectorId(), true); |
frontend()->attachedToTarget(protocol::Target::TargetInfo::create() |
.setTargetId(proxy->inspectorId()) |
.setType("worker") |