Index: content/browser/devtools/protocol/target_handler.cc |
diff --git a/content/browser/devtools/protocol/target_handler.cc b/content/browser/devtools/protocol/target_handler.cc |
index 6ce10663f85ae482733daf7d4904b1f9b2b66e01..8b982c8a9186764405f8956d885bfb25c0dbb8ee 100644 |
--- a/content/browser/devtools/protocol/target_handler.cc |
+++ b/content/browser/devtools/protocol/target_handler.cc |
@@ -223,9 +223,11 @@ void TargetHandler::TargetDestroyedInternal( |
bool TargetHandler::AttachToTargetInternal( |
DevToolsAgentHost* host, bool waiting_for_debugger) { |
- if (!host->AttachClient(this)) |
- return false; |
attached_hosts_[host->GetId()] = host; |
+ if (!host->AttachClient(this)) { |
+ attached_hosts_.erase(host->GetId()); |
+ return false; |
+ } |
frontend_->AttachedToTarget(CreateInfo(host), waiting_for_debugger); |
return true; |
} |
@@ -415,6 +417,8 @@ bool TargetHandler::ShouldForceDevToolsAgentHostCreation() { |
} |
void TargetHandler::DevToolsAgentHostCreated(DevToolsAgentHost* agent_host) { |
+ if (agent_host->GetType() == "node" && agent_host->IsAttached()) |
+ return; |
// If we start discovering late, all existing agent hosts will be reported, |
// but we could have already attached to some. |
TargetCreatedInternal(agent_host); |
@@ -425,6 +429,22 @@ void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* agent_host) { |
TargetDestroyedInternal(agent_host); |
} |
+void TargetHandler::DevToolsAgentHostAttached(DevToolsAgentHost* host) { |
+ if (host->GetType() == "node" && |
+ reported_hosts_.find(host->GetId()) != reported_hosts_.end() && |
+ attached_hosts_.find(host->GetId()) == attached_hosts_.end()) { |
+ TargetDestroyedInternal(host); |
+ } |
+} |
+ |
+void TargetHandler::DevToolsAgentHostDetached(DevToolsAgentHost* host) { |
+ if (host->GetType() == "node" && |
+ reported_hosts_.find(host->GetId()) == reported_hosts_.end() && |
+ attached_hosts_.find(host->GetId()) == attached_hosts_.end()) { |
+ TargetCreatedInternal(host); |
+ } |
+} |
+ |
// -------- ServiceWorkerDevToolsManager::Observer ---------- |
void TargetHandler::WorkerCreated( |