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/v8-inspector-session-impl.cc

Issue 2432163004: Avoid using stale InspectedContext pointers (Closed)
Patch Set: Fix nits Created 4 years, 2 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
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/v8-inspector-session-impl.h" 5 #include "src/inspector/v8-inspector-session-impl.h"
6 6
7 #include "src/inspector/injected-script.h" 7 #include "src/inspector/injected-script.h"
8 #include "src/inspector/inspected-context.h" 8 #include "src/inspector/inspected-context.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 #include "src/inspector/remote-object-id.h" 10 #include "src/inspector/remote-object-id.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 auto contextsIt = contexts->find(contextId); 182 auto contextsIt = contexts->find(contextId);
183 if (contextsIt == contexts->end()) { 183 if (contextsIt == contexts->end()) {
184 *errorString = "Cannot find context with specified id"; 184 *errorString = "Cannot find context with specified id";
185 return nullptr; 185 return nullptr;
186 } 186 }
187 187
188 const std::unique_ptr<InspectedContext>& context = contextsIt->second; 188 const std::unique_ptr<InspectedContext>& context = contextsIt->second;
189 if (!context->getInjectedScript()) { 189 if (!context->getInjectedScript()) {
190 context->createInjectedScript(); 190 if (!context->createInjectedScript()) {
191 if (!context->getInjectedScript()) {
192 *errorString = "Cannot access specified execution context"; 191 *errorString = "Cannot access specified execution context";
193 return nullptr; 192 return nullptr;
194 } 193 }
195 if (m_customObjectFormatterEnabled) 194 if (m_customObjectFormatterEnabled)
196 context->getInjectedScript()->setCustomObjectFormatterEnabled(true); 195 context->getInjectedScript()->setCustomObjectFormatterEnabled(true);
197 } 196 }
198 return context->getInjectedScript(); 197 return context->getInjectedScript();
199 } 198 }
200 199
201 InjectedScript* V8InspectorSessionImpl::findInjectedScript( 200 InjectedScript* V8InspectorSessionImpl::findInjectedScript(
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = 408 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches =
410 searchInTextByLinesImpl(this, toString16(text), toString16(query), 409 searchInTextByLinesImpl(this, toString16(text), toString16(query),
411 caseSensitive, isRegex); 410 caseSensitive, isRegex);
412 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> result; 411 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> result;
413 for (size_t i = 0; i < matches.size(); ++i) 412 for (size_t i = 0; i < matches.size(); ++i)
414 result.push_back(std::move(matches[i])); 413 result.push_back(std::move(matches[i]));
415 return result; 414 return result;
416 } 415 }
417 416
418 } // namespace v8_inspector 417 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/inspected-context.cc ('k') | test/inspector/console/destroy-context-during-log.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698