Index: src/inspector/inspected-context.cc |
diff --git a/src/inspector/inspected-context.cc b/src/inspector/inspected-context.cc |
index 01ade93702f4de21732b4c38fb791227d46356f6..d7a2f810db315b73140c7baaa6f6d32e412274dc 100644 |
--- a/src/inspector/inspected-context.cc |
+++ b/src/inspector/inspected-context.cc |
@@ -64,15 +64,23 @@ void InspectedContext::setReported(int sessionId, bool reported) { |
m_reportedSessionIds.erase(sessionId); |
} |
-bool InspectedContext::createInjectedScript() { |
- DCHECK(!m_injectedScript); |
- std::unique_ptr<InjectedScript> injectedScript = InjectedScript::create(this); |
+InjectedScript* InspectedContext::getInjectedScript(int sessionId) { |
+ auto it = m_injectedScripts.find(sessionId); |
+ return it == m_injectedScripts.end() ? nullptr : it->second.get(); |
+} |
+ |
+bool InspectedContext::createInjectedScript(int sessionId) { |
+ DCHECK(m_injectedScripts.find(sessionId) == m_injectedScripts.end()); |
+ std::unique_ptr<InjectedScript> injectedScript = |
+ InjectedScript::create(this, sessionId); |
// InjectedScript::create can destroy |this|. |
if (!injectedScript) return false; |
- m_injectedScript = std::move(injectedScript); |
+ m_injectedScripts[sessionId] = std::move(injectedScript); |
return true; |
} |
-void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } |
+void InspectedContext::discardInjectedScript(int sessionId) { |
+ m_injectedScripts.erase(sessionId); |
+} |
} // namespace v8_inspector |