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

Side by Side Diff: src/inspector/JavaScriptCallFrame.cpp

Issue 2332243002: [inspector] fixed all deprecated calls (Closed)
Patch Set: addressed comments Created 4 years, 3 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/InjectedScriptNative.cpp ('k') | src/inspector/V8ConsoleMessage.cpp » ('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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const { 47 int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const {
48 v8::HandleScope handleScope(m_isolate); 48 v8::HandleScope handleScope(m_isolate);
49 v8::MicrotasksScope microtasks(m_isolate, 49 v8::MicrotasksScope microtasks(m_isolate,
50 v8::MicrotasksScope::kDoNotRunMicrotasks); 50 v8::MicrotasksScope::kDoNotRunMicrotasks);
51 v8::Local<v8::Context> context = 51 v8::Local<v8::Context> context =
52 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); 52 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
53 v8::Local<v8::Object> callFrame = 53 v8::Local<v8::Object> callFrame =
54 v8::Local<v8::Object>::New(m_isolate, m_callFrame); 54 v8::Local<v8::Object>::New(m_isolate, m_callFrame);
55 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast( 55 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
56 callFrame->Get(toV8StringInternalized(m_isolate, name))); 56 callFrame->Get(context, toV8StringInternalized(m_isolate, name))
57 .ToLocalChecked());
57 v8::Local<v8::Value> result; 58 v8::Local<v8::Value> result;
58 if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) || 59 if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) ||
59 !result->IsInt32()) 60 !result->IsInt32())
60 return 0; 61 return 0;
61 return result.As<v8::Int32>()->Value(); 62 return result.As<v8::Int32>()->Value();
62 } 63 }
63 64
64 int JavaScriptCallFrame::sourceID() const { 65 int JavaScriptCallFrame::sourceID() const {
65 return callV8FunctionReturnInt("sourceID"); 66 return callV8FunctionReturnInt("sourceID");
66 } 67 }
67 68
68 int JavaScriptCallFrame::line() const { 69 int JavaScriptCallFrame::line() const {
69 return callV8FunctionReturnInt("line"); 70 return callV8FunctionReturnInt("line");
70 } 71 }
71 72
72 int JavaScriptCallFrame::column() const { 73 int JavaScriptCallFrame::column() const {
73 return callV8FunctionReturnInt("column"); 74 return callV8FunctionReturnInt("column");
74 } 75 }
75 76
76 int JavaScriptCallFrame::contextId() const { 77 int JavaScriptCallFrame::contextId() const {
77 return callV8FunctionReturnInt("contextId"); 78 return callV8FunctionReturnInt("contextId");
78 } 79 }
79 80
80 bool JavaScriptCallFrame::isAtReturn() const { 81 bool JavaScriptCallFrame::isAtReturn() const {
81 v8::HandleScope handleScope(m_isolate); 82 v8::HandleScope handleScope(m_isolate);
82 v8::Local<v8::Value> result = 83 v8::Local<v8::Context> context =
83 v8::Local<v8::Object>::New(m_isolate, m_callFrame) 84 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
84 ->Get(toV8StringInternalized(m_isolate, "isAtReturn")); 85 v8::Local<v8::Object> callFrame =
85 if (result.IsEmpty() || !result->IsBoolean()) return false; 86 v8::Local<v8::Object>::New(m_isolate, m_callFrame);
86 return result->BooleanValue(); 87 v8::Local<v8::Value> result;
88 if (!callFrame->Get(context, toV8StringInternalized(m_isolate, "isAtReturn"))
89 .ToLocal(&result) ||
90 !result->IsBoolean())
91 return false;
92 return result.As<v8::Boolean>()->BooleanValue(context).FromMaybe(false);
87 } 93 }
88 94
89 v8::Local<v8::Object> JavaScriptCallFrame::details() const { 95 v8::Local<v8::Object> JavaScriptCallFrame::details() const {
90 v8::MicrotasksScope microtasks(m_isolate, 96 v8::MicrotasksScope microtasks(m_isolate,
91 v8::MicrotasksScope::kDoNotRunMicrotasks); 97 v8::MicrotasksScope::kDoNotRunMicrotasks);
98 v8::Local<v8::Context> context =
99 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
92 v8::Local<v8::Object> callFrame = 100 v8::Local<v8::Object> callFrame =
93 v8::Local<v8::Object>::New(m_isolate, m_callFrame); 101 v8::Local<v8::Object>::New(m_isolate, m_callFrame);
94 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast( 102 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
95 callFrame->Get(toV8StringInternalized(m_isolate, "details"))); 103 callFrame->Get(context, toV8StringInternalized(m_isolate, "details"))
104 .ToLocalChecked());
96 return v8::Local<v8::Object>::Cast( 105 return v8::Local<v8::Object>::Cast(
97 func->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr) 106 func->Call(context, callFrame, 0, nullptr).ToLocalChecked());
98 .ToLocalChecked());
99 } 107 }
100 108
101 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate( 109 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(
102 v8::Local<v8::Value> expression) { 110 v8::Local<v8::Value> expression) {
103 v8::MicrotasksScope microtasks(m_isolate, 111 v8::MicrotasksScope microtasks(m_isolate,
104 v8::MicrotasksScope::kRunMicrotasks); 112 v8::MicrotasksScope::kRunMicrotasks);
113 v8::Local<v8::Context> context =
114 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
105 v8::Local<v8::Object> callFrame = 115 v8::Local<v8::Object> callFrame =
106 v8::Local<v8::Object>::New(m_isolate, m_callFrame); 116 v8::Local<v8::Object>::New(m_isolate, m_callFrame);
107 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast( 117 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(
108 callFrame->Get(toV8StringInternalized(m_isolate, "evaluate"))); 118 callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate"))
109 return evalFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 1, 119 .ToLocalChecked());
110 &expression); 120 return evalFunction->Call(context, callFrame, 1, &expression);
111 } 121 }
112 122
113 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() { 123 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() {
114 v8::MicrotasksScope microtasks(m_isolate, 124 v8::MicrotasksScope microtasks(m_isolate,
115 v8::MicrotasksScope::kDoNotRunMicrotasks); 125 v8::MicrotasksScope::kDoNotRunMicrotasks);
126 v8::Local<v8::Context> context =
127 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
116 v8::Local<v8::Object> callFrame = 128 v8::Local<v8::Object> callFrame =
117 v8::Local<v8::Object>::New(m_isolate, m_callFrame); 129 v8::Local<v8::Object>::New(m_isolate, m_callFrame);
118 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast( 130 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(
119 callFrame->Get(toV8StringInternalized(m_isolate, "restart"))); 131 callFrame->Get(context, toV8StringInternalized(m_isolate, "restart"))
132 .ToLocalChecked());
120 v8::Debug::SetLiveEditEnabled(m_isolate, true); 133 v8::Debug::SetLiveEditEnabled(m_isolate, true);
121 v8::MaybeLocal<v8::Value> result = restartFunction->Call( 134 v8::MaybeLocal<v8::Value> result = restartFunction->Call(
122 m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); 135 m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr);
123 v8::Debug::SetLiveEditEnabled(m_isolate, false); 136 v8::Debug::SetLiveEditEnabled(m_isolate, false);
124 return result; 137 return result;
125 } 138 }
126 139
127 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue( 140 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue(
128 int scopeNumber, v8::Local<v8::Value> variableName, 141 int scopeNumber, v8::Local<v8::Value> variableName,
129 v8::Local<v8::Value> newValue) { 142 v8::Local<v8::Value> newValue) {
130 v8::MicrotasksScope microtasks(m_isolate, 143 v8::MicrotasksScope microtasks(m_isolate,
131 v8::MicrotasksScope::kDoNotRunMicrotasks); 144 v8::MicrotasksScope::kDoNotRunMicrotasks);
145 v8::Local<v8::Context> context =
146 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
132 v8::Local<v8::Object> callFrame = 147 v8::Local<v8::Object> callFrame =
133 v8::Local<v8::Object>::New(m_isolate, m_callFrame); 148 v8::Local<v8::Object>::New(m_isolate, m_callFrame);
134 v8::Local<v8::Function> setVariableValueFunction = 149 v8::Local<v8::Function> setVariableValueFunction =
135 v8::Local<v8::Function>::Cast(callFrame->Get( 150 v8::Local<v8::Function>::Cast(
136 toV8StringInternalized(m_isolate, "setVariableValue"))); 151 callFrame
152 ->Get(context,
153 toV8StringInternalized(m_isolate, "setVariableValue"))
154 .ToLocalChecked());
137 v8::Local<v8::Value> argv[] = { 155 v8::Local<v8::Value> argv[] = {
138 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), 156 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)),
139 variableName, newValue}; 157 variableName, newValue};
140 return setVariableValueFunction->Call(m_debuggerContext.Get(m_isolate), 158 return setVariableValueFunction->Call(context, callFrame,
141 callFrame,
142 V8_INSPECTOR_ARRAY_LENGTH(argv), argv); 159 V8_INSPECTOR_ARRAY_LENGTH(argv), argv);
143 } 160 }
144 161
145 } // namespace v8_inspector 162 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/InjectedScriptNative.cpp ('k') | src/inspector/V8ConsoleMessage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698