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

Side by Side Diff: src/inspector/injected-script.cc

Issue 2432163004: Avoid using stale InspectedContext pointers (Closed)
Patch Set: Fix nits Created 4 years, 1 month 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 | « AUTHORS ('k') | src/inspector/inspected-context.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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 .ToLocal(&value)) 92 .ToLocal(&value))
93 return nullptr; 93 return nullptr;
94 DCHECK(value->IsFunction()); 94 DCHECK(value->IsFunction());
95 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); 95 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
96 v8::Local<v8::Object> windowGlobal = context->Global(); 96 v8::Local<v8::Object> windowGlobal = context->Global();
97 v8::Local<v8::Value> info[] = { 97 v8::Local<v8::Value> info[] = {
98 scriptHostWrapper, windowGlobal, 98 scriptHostWrapper, windowGlobal,
99 v8::Number::New(isolate, inspectedContext->contextId())}; 99 v8::Number::New(isolate, inspectedContext->contextId())};
100 v8::MicrotasksScope microtasksScope(isolate, 100 v8::MicrotasksScope microtasksScope(isolate,
101 v8::MicrotasksScope::kDoNotRunMicrotasks); 101 v8::MicrotasksScope::kDoNotRunMicrotasks);
102
103 int contextGroupId = inspectedContext->contextGroupId();
104 int contextId = inspectedContext->contextId();
105 V8InspectorImpl* inspector = inspectedContext->inspector();
102 v8::Local<v8::Value> injectedScriptValue; 106 v8::Local<v8::Value> injectedScriptValue;
103 if (!function->Call(context, windowGlobal, arraysize(info), info) 107 if (!function->Call(context, windowGlobal, arraysize(info), info)
104 .ToLocal(&injectedScriptValue)) 108 .ToLocal(&injectedScriptValue))
105 return nullptr; 109 return nullptr;
110 if (inspector->getContext(contextGroupId, contextId) != inspectedContext)
111 return nullptr;
106 if (!injectedScriptValue->IsObject()) return nullptr; 112 if (!injectedScriptValue->IsObject()) return nullptr;
107 return wrapUnique(new InjectedScript(inspectedContext, 113 return wrapUnique(new InjectedScript(inspectedContext,
108 injectedScriptValue.As<v8::Object>(), 114 injectedScriptValue.As<v8::Object>(),
109 std::move(injectedScriptNative))); 115 std::move(injectedScriptNative)));
110 } 116 }
111 117
112 InjectedScript::InjectedScript( 118 InjectedScript::InjectedScript(
113 InspectedContext* context, v8::Local<v8::Object> object, 119 InspectedContext* context, v8::Local<v8::Object> object,
114 std::unique_ptr<InjectedScriptNative> injectedScriptNative) 120 std::unique_ptr<InjectedScriptNative> injectedScriptNative)
115 : m_context(context), 121 : m_context(context),
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 void InjectedScript::CallFrameScope::findInjectedScript( 572 void InjectedScript::CallFrameScope::findInjectedScript(
567 V8InspectorSessionImpl* session) { 573 V8InspectorSessionImpl* session) {
568 std::unique_ptr<RemoteCallFrameId> remoteId = 574 std::unique_ptr<RemoteCallFrameId> remoteId =
569 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); 575 RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId);
570 if (!remoteId) return; 576 if (!remoteId) return;
571 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 577 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
572 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()); 578 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get());
573 } 579 }
574 580
575 } // namespace v8_inspector 581 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « AUTHORS ('k') | src/inspector/inspected-context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698