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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/inspector/inspected-context.h ('k') | src/inspector/v8-console.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/inspected-context.h" 5 #include "src/inspector/inspected-context.h"
6 6
7 #include "src/debug/debug-interface.h" 7 #include "src/debug/debug-interface.h"
8 #include "src/inspector/injected-script.h" 8 #include "src/inspector/injected-script.h"
9 #include "src/inspector/string-util.h" 9 #include "src/inspector/string-util.h"
10 #include "src/inspector/v8-console.h" 10 #include "src/inspector/v8-console.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return m_reportedSessionIds.find(sessionId) != m_reportedSessionIds.cend(); 57 return m_reportedSessionIds.find(sessionId) != m_reportedSessionIds.cend();
58 } 58 }
59 59
60 void InspectedContext::setReported(int sessionId, bool reported) { 60 void InspectedContext::setReported(int sessionId, bool reported) {
61 if (reported) 61 if (reported)
62 m_reportedSessionIds.insert(sessionId); 62 m_reportedSessionIds.insert(sessionId);
63 else 63 else
64 m_reportedSessionIds.erase(sessionId); 64 m_reportedSessionIds.erase(sessionId);
65 } 65 }
66 66
67 bool InspectedContext::createInjectedScript() { 67 InjectedScript* InspectedContext::getInjectedScript(int sessionId) {
68 DCHECK(!m_injectedScript); 68 auto it = m_injectedScripts.find(sessionId);
69 std::unique_ptr<InjectedScript> injectedScript = InjectedScript::create(this); 69 return it == m_injectedScripts.end() ? nullptr : it->second.get();
70 }
71
72 bool InspectedContext::createInjectedScript(int sessionId) {
73 DCHECK(m_injectedScripts.find(sessionId) == m_injectedScripts.end());
74 std::unique_ptr<InjectedScript> injectedScript =
75 InjectedScript::create(this, sessionId);
70 // InjectedScript::create can destroy |this|. 76 // InjectedScript::create can destroy |this|.
71 if (!injectedScript) return false; 77 if (!injectedScript) return false;
72 m_injectedScript = std::move(injectedScript); 78 m_injectedScripts[sessionId] = std::move(injectedScript);
73 return true; 79 return true;
74 } 80 }
75 81
76 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } 82 void InspectedContext::discardInjectedScript(int sessionId) {
83 m_injectedScripts.erase(sessionId);
84 }
77 85
78 } // namespace v8_inspector 86 } // namespace v8_inspector
OLDNEW
« 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