Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: src/inspector/inspected-context.cc

Issue 2916803005: [inspector] Create InjectedScript per session in each context (Closed)
Patch Set: rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/inspected-context.h ('k') | src/inspector/v8-console.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/inspector/inspected-context.h ('k') | src/inspector/v8-console.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698