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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp

Issue 1804043002: Revert of Remove V8RecrusionScope, cleanup call sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 /* 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "platform/v8_inspector/InjectedScript.h" 31 #include "platform/v8_inspector/InjectedScript.h"
32 32
33 #include "platform/inspector_protocol/Parser.h" 33 #include "platform/inspector_protocol/Parser.h"
34 #include "platform/inspector_protocol/String16.h" 34 #include "platform/inspector_protocol/String16.h"
35 #include "platform/inspector_protocol/Values.h" 35 #include "platform/inspector_protocol/Values.h"
36 #include "platform/v8_inspector/InjectedScriptHost.h" 36 #include "platform/v8_inspector/InjectedScriptHost.h"
37 #include "platform/v8_inspector/InjectedScriptManager.h" 37 #include "platform/v8_inspector/InjectedScriptManager.h"
38 #include "platform/v8_inspector/RemoteObjectId.h" 38 #include "platform/v8_inspector/RemoteObjectId.h"
39 #include "platform/v8_inspector/V8DebuggerImpl.h"
40 #include "platform/v8_inspector/V8FunctionCall.h" 39 #include "platform/v8_inspector/V8FunctionCall.h"
41 #include "platform/v8_inspector/V8StringUtil.h" 40 #include "platform/v8_inspector/V8StringUtil.h"
42 #include "platform/v8_inspector/public/V8Debugger.h" 41 #include "platform/v8_inspector/public/V8Debugger.h"
43 #include "platform/v8_inspector/public/V8DebuggerClient.h" 42 #include "platform/v8_inspector/public/V8DebuggerClient.h"
44 #include "platform/v8_inspector/public/V8ToProtocolValue.h" 43 #include "platform/v8_inspector/public/V8ToProtocolValue.h"
45 44
46 using blink::protocol::Array; 45 using blink::protocol::Array;
47 using blink::protocol::Debugger::CallFrame; 46 using blink::protocol::Debugger::CallFrame;
48 using blink::protocol::Debugger::CollectionEntry; 47 using blink::protocol::Debugger::CollectionEntry;
49 using blink::protocol::Debugger::FunctionDetails; 48 using blink::protocol::Debugger::FunctionDetails;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (originScriptId) 108 if (originScriptId)
110 exceptionDetails->setScriptId(String16::number(originScriptId)); 109 exceptionDetails->setScriptId(String16::number(originScriptId));
111 return exceptionDetails.release(); 110 return exceptionDetails.release();
112 } 111 }
113 112
114 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) 113 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data)
115 { 114 {
116 data.GetParameter()->dispose(); 115 data.GetParameter()->dispose();
117 } 116 }
118 117
119 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con text> context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> in jectedScriptNative, int contextId) 118 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con text> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPt r<InjectedScriptNative> injectedScriptNative, int contextId)
120 : m_manager(manager) 119 : m_manager(manager)
121 , m_isolate(context->GetIsolate()) 120 , m_isolate(context->GetIsolate())
122 , m_context(m_isolate, context) 121 , m_context(m_isolate, context)
123 , m_value(m_isolate, object) 122 , m_value(m_isolate, object)
123 , m_client(client)
124 , m_native(injectedScriptNative) 124 , m_native(injectedScriptNative)
125 , m_contextId(contextId) 125 , m_contextId(contextId)
126 { 126 {
127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); 127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter);
128 } 128 }
129 129
130 InjectedScript::~InjectedScript() 130 InjectedScript::~InjectedScript()
131 { 131 {
132 } 132 }
133 133
134 void InjectedScript::evaluate(ErrorString* errorString, const String16& expressi on, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bo ol>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) 134 void InjectedScript::evaluate(ErrorString* errorString, const String16& expressi on, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bo ol>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
135 { 135 {
136 v8::HandleScope handles(m_isolate); 136 v8::HandleScope handles(m_isolate);
137 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evalua te"); 137 V8FunctionCall function(m_client, context(), v8Value(), "evaluate");
138 function.appendArgument(expression); 138 function.appendArgument(expression);
139 function.appendArgument(objectGroup); 139 function.appendArgument(objectGroup);
140 function.appendArgument(includeCommandLineAPI); 140 function.appendArgument(includeCommandLineAPI);
141 function.appendArgument(returnByValue); 141 function.appendArgument(returnByValue);
142 function.appendArgument(generatePreview); 142 function.appendArgument(generatePreview);
143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); 143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails);
144 } 144 }
145 145
146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& ob jectId, const String16& expression, const String16& arguments, bool returnByValu e, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe< bool>* wasThrown) 146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& ob jectId, const String16& expression, const String16& arguments, bool returnByValu e, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe< bool>* wasThrown)
147 { 147 {
148 v8::HandleScope handles(m_isolate); 148 v8::HandleScope handles(m_isolate);
149 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "callFu nctionOn"); 149 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn");
150 function.appendArgument(objectId); 150 function.appendArgument(objectId);
151 function.appendArgument(expression); 151 function.appendArgument(expression);
152 function.appendArgument(arguments); 152 function.appendArgument(arguments);
153 function.appendArgument(returnByValue); 153 function.appendArgument(returnByValue);
154 function.appendArgument(generatePreview); 154 function.appendArgument(generatePreview);
155 *result = makeEvalCall(errorString, function, wasThrown); 155 *result = makeEvalCall(errorString, function, wasThrown);
156 } 156 }
157 157
158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: :Object> callFrames, const String16& callFrameId, const String16& expression, co nst String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<pro tocol::Runtime::ExceptionDetails>* exceptionDetails) 158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: :Object> callFrames, const String16& callFrameId, const String16& expression, co nst String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<pro tocol::Runtime::ExceptionDetails>* exceptionDetails)
159 { 159 {
160 v8::HandleScope handles(m_isolate); 160 v8::HandleScope handles(m_isolate);
161 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evalua teOnCallFrame"); 161 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame ");
162 function.appendArgument(callFrames); 162 function.appendArgument(callFrames);
163 function.appendArgument(callFrameId); 163 function.appendArgument(callFrameId);
164 function.appendArgument(expression); 164 function.appendArgument(expression);
165 function.appendArgument(objectGroup); 165 function.appendArgument(objectGroup);
166 function.appendArgument(includeCommandLineAPI); 166 function.appendArgument(includeCommandLineAPI);
167 function.appendArgument(returnByValue); 167 function.appendArgument(returnByValue);
168 function.appendArgument(generatePreview); 168 function.appendArgument(generatePreview);
169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); 169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails);
170 } 170 }
171 171
172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object > callFrames, const String16& callFrameId) 172 void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object > callFrames, const String16& callFrameId)
173 { 173 {
174 v8::HandleScope handles(m_isolate); 174 v8::HandleScope handles(m_isolate);
175 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "restar tFrame"); 175 V8FunctionCall function(m_client, context(), v8Value(), "restartFrame");
176 function.appendArgument(callFrames); 176 function.appendArgument(callFrames);
177 function.appendArgument(callFrameId); 177 function.appendArgument(callFrameId);
178 OwnPtr<protocol::Value> resultValue = makeCall(function); 178 OwnPtr<protocol::Value> resultValue = makeCall(function);
179 if (resultValue) { 179 if (resultValue) {
180 if (resultValue->type() == protocol::Value::TypeString) { 180 if (resultValue->type() == protocol::Value::TypeString) {
181 resultValue->asString(errorString); 181 resultValue->asString(errorString);
182 } else { 182 } else {
183 bool value; 183 bool value;
184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value); 184 ASSERT_UNUSED(value, resultValue->asBoolean(&value) && value);
185 } 185 }
186 return; 186 return;
187 } 187 }
188 *errorString = "Internal error"; 188 *errorString = "Internal error";
189 } 189 }
190 190
191 void InjectedScript::setVariableValue(ErrorString* errorString, 191 void InjectedScript::setVariableValue(ErrorString* errorString,
192 v8::Local<v8::Object> callFrames, 192 v8::Local<v8::Object> callFrames,
193 const protocol::Maybe<String16>& callFrameIdOpt, 193 const protocol::Maybe<String16>& callFrameIdOpt,
194 const protocol::Maybe<String16>& functionObjectIdOpt, 194 const protocol::Maybe<String16>& functionObjectIdOpt,
195 int scopeNumber, 195 int scopeNumber,
196 const String16& variableName, 196 const String16& variableName,
197 const String16& newValueStr) 197 const String16& newValueStr)
198 { 198 {
199 v8::HandleScope handles(m_isolate); 199 v8::HandleScope handles(m_isolate);
200 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setVar iableValue"); 200 V8FunctionCall function(m_client, context(), v8Value(), "setVariableValue");
201 if (callFrameIdOpt.isJust()) { 201 if (callFrameIdOpt.isJust()) {
202 function.appendArgument(callFrames); 202 function.appendArgument(callFrames);
203 function.appendArgument(callFrameIdOpt.fromJust()); 203 function.appendArgument(callFrameIdOpt.fromJust());
204 } else { 204 } else {
205 function.appendArgument(false); 205 function.appendArgument(false);
206 function.appendArgument(false); 206 function.appendArgument(false);
207 } 207 }
208 if (functionObjectIdOpt.isJust()) 208 if (functionObjectIdOpt.isJust())
209 function.appendArgument(functionObjectIdOpt.fromJust()); 209 function.appendArgument(functionObjectIdOpt.fromJust());
210 else 210 else
211 function.appendArgument(false); 211 function.appendArgument(false);
212 function.appendArgument(scopeNumber); 212 function.appendArgument(scopeNumber);
213 function.appendArgument(variableName); 213 function.appendArgument(variableName);
214 function.appendArgument(newValueStr); 214 function.appendArgument(newValueStr);
215 OwnPtr<protocol::Value> resultValue = makeCall(function); 215 OwnPtr<protocol::Value> resultValue = makeCall(function);
216 if (!resultValue) { 216 if (!resultValue) {
217 *errorString = "Internal error"; 217 *errorString = "Internal error";
218 return; 218 return;
219 } 219 }
220 if (resultValue->type() == protocol::Value::TypeString) { 220 if (resultValue->type() == protocol::Value::TypeString) {
221 resultValue->asString(errorString); 221 resultValue->asString(errorString);
222 return; 222 return;
223 } 223 }
224 // Normal return. 224 // Normal return.
225 } 225 }
226 226
227 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16 & functionId, OwnPtr<FunctionDetails>* result) 227 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16 & functionId, OwnPtr<FunctionDetails>* result)
228 { 228 {
229 v8::HandleScope handles(m_isolate); 229 v8::HandleScope handles(m_isolate);
230 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getFun ctionDetails"); 230 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails" );
231 function.appendArgument(functionId); 231 function.appendArgument(functionId);
232 OwnPtr<protocol::Value> resultValue = makeCall(function); 232 OwnPtr<protocol::Value> resultValue = makeCall(function);
233 protocol::ErrorSupport errors(errorString); 233 protocol::ErrorSupport errors(errorString);
234 *result = FunctionDetails::parse(resultValue.get(), &errors); 234 *result = FunctionDetails::parse(resultValue.get(), &errors);
235 } 235 }
236 236
237 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S tring16& objectId, OwnPtr<GeneratorObjectDetails>* result) 237 void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S tring16& objectId, OwnPtr<GeneratorObjectDetails>* result)
238 { 238 {
239 v8::HandleScope handles(m_isolate); 239 v8::HandleScope handles(m_isolate);
240 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getGen eratorObjectDetails"); 240 V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectD etails");
241 function.appendArgument(objectId); 241 function.appendArgument(objectId);
242 OwnPtr<protocol::Value> resultValue = makeCall(function); 242 OwnPtr<protocol::Value> resultValue = makeCall(function);
243 protocol::ErrorSupport errors(errorString); 243 protocol::ErrorSupport errors(errorString);
244 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); 244 *result = GeneratorObjectDetails::parse(resultValue.get(), &errors);
245 } 245 }
246 246
247 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String 16& objectId, OwnPtr<Array<CollectionEntry>>* result) 247 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String 16& objectId, OwnPtr<Array<CollectionEntry>>* result)
248 { 248 {
249 v8::HandleScope handles(m_isolate); 249 v8::HandleScope handles(m_isolate);
250 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCol lectionEntries"); 250 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie s");
251 function.appendArgument(objectId); 251 function.appendArgument(objectId);
252 OwnPtr<protocol::Value> resultValue = makeCall(function); 252 OwnPtr<protocol::Value> resultValue = makeCall(function);
253 protocol::ErrorSupport errors(errorString); 253 protocol::ErrorSupport errors(errorString);
254 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); 254 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors);
255 } 255 }
256 256
257 void InjectedScript::getProperties(ErrorString* errorString, const String16& obj ectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow nPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionD etails>* exceptionDetails) 257 void InjectedScript::getProperties(ErrorString* errorString, const String16& obj ectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow nPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionD etails>* exceptionDetails)
258 { 258 {
259 v8::HandleScope handles(m_isolate); 259 v8::HandleScope handles(m_isolate);
260 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getPro perties"); 260 V8FunctionCall function(m_client, context(), v8Value(), "getProperties");
261 function.appendArgument(objectId); 261 function.appendArgument(objectId);
262 function.appendArgument(ownProperties); 262 function.appendArgument(ownProperties);
263 function.appendArgument(accessorPropertiesOnly); 263 function.appendArgument(accessorPropertiesOnly);
264 function.appendArgument(generatePreview); 264 function.appendArgument(generatePreview);
265 265
266 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); 266 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails);
267 if (exceptionDetails->isJust()) { 267 if (exceptionDetails->isJust()) {
268 // FIXME: make properties optional 268 // FIXME: make properties optional
269 *properties = Array<PropertyDescriptor>::create(); 269 *properties = Array<PropertyDescriptor>::create();
270 return; 270 return;
271 } 271 }
272 protocol::ErrorSupport errors(errorString); 272 protocol::ErrorSupport errors(errorString);
273 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); 273 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors);
274 } 274 }
275 275
276 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto col::Runtime::ExceptionDetails>* exceptionDetails) 276 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto col::Runtime::ExceptionDetails>* exceptionDetails)
277 { 277 {
278 v8::HandleScope handles(m_isolate); 278 v8::HandleScope handles(m_isolate);
279 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInt ernalProperties"); 279 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti es");
280 function.appendArgument(objectId); 280 function.appendArgument(objectId);
281 281
282 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); 282 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails);
283 if (exceptionDetails->isJust()) 283 if (exceptionDetails->isJust())
284 return; 284 return;
285 protocol::ErrorSupport errors(errorString); 285 protocol::ErrorSupport errors(errorString);
286 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors); 286 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors);
287 if (!errors.hasErrors() && array->length() > 0) 287 if (!errors.hasErrors() && array->length() > 0)
288 *properties = array.release(); 288 *properties = array.release();
289 } 289 }
(...skipping 10 matching lines...) Expand all
300 if (!object->getNumber("id", &boundId)) 300 if (!object->getNumber("id", &boundId))
301 return; 301 return;
302 m_native->unbind(boundId); 302 m_native->unbind(boundId);
303 } 303 }
304 304
305 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI) 305 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI)
306 { 306 {
307 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate); 307 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate);
308 v8::Local<v8::Object> global = context()->Global(); 308 v8::Local<v8::Object> global = context()->Global();
309 if (includeCommandLineAPI) { 309 if (includeCommandLineAPI) {
310 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "co mmandLineAPI"); 310 V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI" );
311 bool hadException = false; 311 bool hadException = false;
312 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ; 312 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ;
313 if (!hadException) 313 if (!hadException)
314 global->Set(commandLineAPISymbolValue, commandLineAPI); 314 global->Set(commandLineAPISymbolValue, commandLineAPI);
315 } 315 }
316 316
317 v8::MaybeLocal<v8::Value> maybeValue = m_manager->debugger()->runCompiledScr ipt(context(), script); 317 v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context() , script);
318 if (includeCommandLineAPI) 318 if (includeCommandLineAPI)
319 global->Delete(context(), commandLineAPISymbolValue); 319 global->Delete(context(), commandLineAPISymbolValue);
320 320
321 return maybeValue; 321 return maybeValue;
322 } 322 }
323 323
324 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames) 324 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames)
325 { 325 {
326 v8::HandleScope handles(m_isolate); 326 v8::HandleScope handles(m_isolate);
327 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapCa llFrames"); 327 V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames");
328 function.appendArgument(callFrames); 328 function.appendArgument(callFrames);
329 bool hadException = false; 329 bool hadException = false;
330 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); 330 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException);
331 ASSERT(!hadException); 331 ASSERT(!hadException);
332 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ; 332 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ;
333 protocol::ErrorSupport errors; 333 protocol::ErrorSupport errors;
334 if (result && result->type() == protocol::Value::TypeArray) 334 if (result && result->type() == protocol::Value::TypeArray)
335 return Array<CallFrame>::parse(result.get(), &errors); 335 return Array<CallFrame>::parse(result.get(), &errors);
336 return Array<CallFrame>::create(); 336 return Array<CallFrame>::create();
337 } 337 }
338 338
339 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String16& groupName, bool generatePreview) const 339 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String16& groupName, bool generatePreview) const
340 { 340 {
341 v8::HandleScope handles(m_isolate); 341 v8::HandleScope handles(m_isolate);
342 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb ject"); 342 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject");
343 function.appendArgument(value); 343 function.appendArgument(value);
344 function.appendArgument(groupName); 344 function.appendArgument(groupName);
345 function.appendArgument(canAccessInspectedWindow()); 345 function.appendArgument(canAccessInspectedWindow());
346 function.appendArgument(generatePreview); 346 function.appendArgument(generatePreview);
347 bool hadException = false; 347 bool hadException = false;
348 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ; 348 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ;
349 if (hadException) 349 if (hadException)
350 return nullptr; 350 return nullptr;
351 protocol::ErrorSupport errors; 351 protocol::ErrorSupport errors;
352 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); 352 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors);
353 } 353 }
354 354
355 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const 355 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const
356 { 356 {
357 v8::HandleScope handles(m_isolate); 357 v8::HandleScope handles(m_isolate);
358 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapTa ble"); 358 V8FunctionCall function(m_client, context(), v8Value(), "wrapTable");
359 function.appendArgument(canAccessInspectedWindow()); 359 function.appendArgument(canAccessInspectedWindow());
360 function.appendArgument(table); 360 function.appendArgument(table);
361 if (columns.IsEmpty()) 361 if (columns.IsEmpty())
362 function.appendArgument(false); 362 function.appendArgument(false);
363 else 363 else
364 function.appendArgument(columns); 364 function.appendArgument(columns);
365 bool hadException = false; 365 bool hadException = false;
366 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException ); 366 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException );
367 if (hadException) 367 if (hadException)
368 return nullptr; 368 return nullptr;
369 protocol::ErrorSupport errors; 369 protocol::ErrorSupport errors;
370 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); 370 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors);
371 } 371 }
372 372
373 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const 373 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const
374 { 374 {
375 return m_native->objectForId(objectId.id()); 375 return m_native->objectForId(objectId.id());
376 } 376 }
377 377
378 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const 378 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const
379 { 379 {
380 return m_native->groupName(objectId.id()); 380 return m_native->groupName(objectId.id());
381 } 381 }
382 382
383 void InjectedScript::releaseObjectGroup(const String16& objectGroup) 383 void InjectedScript::releaseObjectGroup(const String16& objectGroup)
384 { 384 {
385 v8::HandleScope handles(m_isolate); 385 v8::HandleScope handles(m_isolate);
386 m_native->releaseObjectGroup(objectGroup); 386 m_native->releaseObjectGroup(objectGroup);
387 if (objectGroup == "console") { 387 if (objectGroup == "console") {
388 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "cl earLastEvaluationResult"); 388 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua tionResult");
389 bool hadException = false; 389 bool hadException = false;
390 callFunctionWithEvalEnabled(function, hadException); 390 callFunctionWithEvalEnabled(function, hadException);
391 ASSERT(!hadException); 391 ASSERT(!hadException);
392 } 392 }
393 } 393 }
394 394
395 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) 395 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled)
396 { 396 {
397 v8::HandleScope handles(m_isolate); 397 v8::HandleScope handles(m_isolate);
398 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setCus tomObjectFormatterEnabled"); 398 V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectForm atterEnabled");
399 function.appendArgument(enabled); 399 function.appendArgument(enabled);
400 makeCall(function); 400 makeCall(function);
401 } 401 }
402 402
403 bool InjectedScript::canAccessInspectedWindow() const 403 bool InjectedScript::canAccessInspectedWindow() const
404 { 404 {
405 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); 405 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext();
406 if (callingContext.IsEmpty()) 406 if (callingContext.IsEmpty())
407 return true; 407 return true;
408 return m_manager->debugger()->client()->callingContextCanAccessContext(calli ngContext, context()); 408 return m_client->callingContextCanAccessContext(callingContext, context());
409 } 409 }
410 410
411 v8::Local<v8::Context> InjectedScript::context() const 411 v8::Local<v8::Context> InjectedScript::context() const
412 { 412 {
413 return m_context.Get(m_isolate); 413 return m_context.Get(m_isolate);
414 } 414 }
415 415
416 v8::Local<v8::Value> InjectedScript::v8Value() const 416 v8::Local<v8::Value> InjectedScript::v8Value() const
417 { 417 {
418 return m_value.Get(m_isolate); 418 return m_value.Get(m_isolate);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 505 }
506 return result.release(); 506 return result.release();
507 } 507 }
508 508
509 void InjectedScript::dispose() 509 void InjectedScript::dispose()
510 { 510 {
511 m_manager->discardInjectedScript(m_contextId); 511 m_manager->discardInjectedScript(m_contextId);
512 } 512 }
513 513
514 } // namespace blink 514 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698