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

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

Issue 1806643002: Revert of Remove V8RecrusionScope, cleanup call sites. (patchset #8 id:140001 of https://codereview… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverts 1805543002 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::getCollectionEntries(ErrorString* errorString, const String 16& objectId, OwnPtr<Array<CollectionEntry>>* result) 237 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String 16& objectId, OwnPtr<Array<CollectionEntry>>* result)
238 { 238 {
239 v8::HandleScope handles(m_isolate); 239 v8::HandleScope handles(m_isolate);
240 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCol lectionEntries"); 240 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie s");
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 = Array<CollectionEntry>::parse(resultValue.get(), &errors); 244 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors);
245 } 245 }
246 246
247 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) 247 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)
248 { 248 {
249 v8::HandleScope handles(m_isolate); 249 v8::HandleScope handles(m_isolate);
250 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getPro perties"); 250 V8FunctionCall function(m_client, context(), v8Value(), "getProperties");
251 function.appendArgument(objectId); 251 function.appendArgument(objectId);
252 function.appendArgument(ownProperties); 252 function.appendArgument(ownProperties);
253 function.appendArgument(accessorPropertiesOnly); 253 function.appendArgument(accessorPropertiesOnly);
254 function.appendArgument(generatePreview); 254 function.appendArgument(generatePreview);
255 255
256 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); 256 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails);
257 if (exceptionDetails->isJust()) { 257 if (exceptionDetails->isJust()) {
258 // FIXME: make properties optional 258 // FIXME: make properties optional
259 *properties = Array<PropertyDescriptor>::create(); 259 *properties = Array<PropertyDescriptor>::create();
260 return; 260 return;
261 } 261 }
262 protocol::ErrorSupport errors(errorString); 262 protocol::ErrorSupport errors(errorString);
263 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); 263 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors);
264 } 264 }
265 265
266 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto col::Runtime::ExceptionDetails>* exceptionDetails) 266 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto col::Runtime::ExceptionDetails>* exceptionDetails)
267 { 267 {
268 v8::HandleScope handles(m_isolate); 268 v8::HandleScope handles(m_isolate);
269 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInt ernalProperties"); 269 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti es");
270 function.appendArgument(objectId); 270 function.appendArgument(objectId);
271 271
272 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); 272 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails);
273 if (exceptionDetails->isJust()) 273 if (exceptionDetails->isJust())
274 return; 274 return;
275 protocol::ErrorSupport errors(errorString); 275 protocol::ErrorSupport errors(errorString);
276 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors); 276 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors);
277 if (!errors.hasErrors() && array->length() > 0) 277 if (!errors.hasErrors() && array->length() > 0)
278 *properties = array.release(); 278 *properties = array.release();
279 } 279 }
(...skipping 10 matching lines...) Expand all
290 if (!object->getNumber("id", &boundId)) 290 if (!object->getNumber("id", &boundId))
291 return; 291 return;
292 m_native->unbind(boundId); 292 m_native->unbind(boundId);
293 } 293 }
294 294
295 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI) 295 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI)
296 { 296 {
297 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate); 297 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate);
298 v8::Local<v8::Object> global = context()->Global(); 298 v8::Local<v8::Object> global = context()->Global();
299 if (includeCommandLineAPI) { 299 if (includeCommandLineAPI) {
300 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "co mmandLineAPI"); 300 V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI" );
301 bool hadException = false; 301 bool hadException = false;
302 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ; 302 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ;
303 if (!hadException) 303 if (!hadException)
304 global->Set(commandLineAPISymbolValue, commandLineAPI); 304 global->Set(commandLineAPISymbolValue, commandLineAPI);
305 } 305 }
306 306
307 v8::MaybeLocal<v8::Value> maybeValue = m_manager->debugger()->runCompiledScr ipt(context(), script); 307 v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context() , script);
308 if (includeCommandLineAPI) 308 if (includeCommandLineAPI)
309 global->Delete(context(), commandLineAPISymbolValue); 309 global->Delete(context(), commandLineAPISymbolValue);
310 310
311 return maybeValue; 311 return maybeValue;
312 } 312 }
313 313
314 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames) 314 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames)
315 { 315 {
316 v8::HandleScope handles(m_isolate); 316 v8::HandleScope handles(m_isolate);
317 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapCa llFrames"); 317 V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames");
318 function.appendArgument(callFrames); 318 function.appendArgument(callFrames);
319 bool hadException = false; 319 bool hadException = false;
320 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); 320 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException);
321 ASSERT(!hadException); 321 ASSERT(!hadException);
322 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ; 322 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ;
323 protocol::ErrorSupport errors; 323 protocol::ErrorSupport errors;
324 if (result && result->type() == protocol::Value::TypeArray) 324 if (result && result->type() == protocol::Value::TypeArray)
325 return Array<CallFrame>::parse(result.get(), &errors); 325 return Array<CallFrame>::parse(result.get(), &errors);
326 return Array<CallFrame>::create(); 326 return Array<CallFrame>::create();
327 } 327 }
328 328
329 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String16& groupName, bool generatePreview) const 329 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String16& groupName, bool generatePreview) const
330 { 330 {
331 v8::HandleScope handles(m_isolate); 331 v8::HandleScope handles(m_isolate);
332 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb ject"); 332 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject");
333 v8::Local<v8::Value> wrappedObject; 333 v8::Local<v8::Value> wrappedObject;
334 ErrorString errorString; 334 ErrorString errorString;
335 if (!wrapValue(&errorString, value, groupName, generatePreview).ToLocal(&wra ppedObject)) 335 if (!wrapValue(&errorString, value, groupName, generatePreview).ToLocal(&wra ppedObject))
336 return nullptr; 336 return nullptr;
337 protocol::ErrorSupport errors; 337 protocol::ErrorSupport errors;
338 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), wra ppedObject).get(), &errors); 338 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), wra ppedObject).get(), &errors);
339 } 339 }
340 340
341 bool InjectedScript::wrapObjectProperty(ErrorString* error, v8::Local<v8::Object > object, v8::Local<v8::Value> key, const String16& groupName, bool generatePrev iew) const 341 bool InjectedScript::wrapObjectProperty(ErrorString* error, v8::Local<v8::Object > object, v8::Local<v8::Value> key, const String16& groupName, bool generatePrev iew) const
342 { 342 {
343 v8::Local<v8::Value> property; 343 v8::Local<v8::Value> property;
344 if (!object->Get(context(), key).ToLocal(&property)) { 344 if (!object->Get(context(), key).ToLocal(&property)) {
345 *error = "Internal error."; 345 *error = "Internal error.";
346 return false; 346 return false;
347 } 347 }
348 v8::Local<v8::Value> wrappedProperty; 348 v8::Local<v8::Value> wrappedProperty;
349 if (!wrapValue(error, property, groupName, generatePreview).ToLocal(&wrapped Property)) 349 if (!wrapValue(error, property, groupName, generatePreview).ToLocal(&wrapped Property))
350 return false; 350 return false;
351 v8::Maybe<bool> success = object->Set(context(), key, wrappedProperty); 351 v8::Maybe<bool> success = object->Set(context(), key, wrappedProperty);
352 if (success.IsNothing() || !success.FromJust()) { 352 if (success.IsNothing() || !success.FromJust()) {
353 *error = "Internal error."; 353 *error = "Internal error.";
354 return false; 354 return false;
355 } 355 }
356 return true; 356 return true;
357 } 357 }
358 358
359 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca l<v8::Value> value, const String16& groupName, bool generatePreview) const 359 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca l<v8::Value> value, const String16& groupName, bool generatePreview) const
360 { 360 {
361 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb ject"); 361 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject");
362 function.appendArgument(value); 362 function.appendArgument(value);
363 function.appendArgument(groupName); 363 function.appendArgument(groupName);
364 function.appendArgument(canAccessInspectedWindow()); 364 function.appendArgument(canAccessInspectedWindow());
365 function.appendArgument(generatePreview); 365 function.appendArgument(generatePreview);
366 bool hadException = false; 366 bool hadException = false;
367 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ; 367 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ;
368 if (hadException) { 368 if (hadException) {
369 *error = "Internal error."; 369 *error = "Internal error.";
370 return v8::MaybeLocal<v8::Value>(); 370 return v8::MaybeLocal<v8::Value>();
371 } 371 }
372 return r; 372 return r;
373 } 373 }
374 374
375 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const 375 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const
376 { 376 {
377 v8::HandleScope handles(m_isolate); 377 v8::HandleScope handles(m_isolate);
378 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapTa ble"); 378 V8FunctionCall function(m_client, context(), v8Value(), "wrapTable");
379 function.appendArgument(canAccessInspectedWindow()); 379 function.appendArgument(canAccessInspectedWindow());
380 function.appendArgument(table); 380 function.appendArgument(table);
381 if (columns.IsEmpty()) 381 if (columns.IsEmpty())
382 function.appendArgument(false); 382 function.appendArgument(false);
383 else 383 else
384 function.appendArgument(columns); 384 function.appendArgument(columns);
385 bool hadException = false; 385 bool hadException = false;
386 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException ); 386 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException );
387 if (hadException) 387 if (hadException)
388 return nullptr; 388 return nullptr;
389 protocol::ErrorSupport errors; 389 protocol::ErrorSupport errors;
390 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); 390 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors);
391 } 391 }
392 392
393 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const 393 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const
394 { 394 {
395 return m_native->objectForId(objectId.id()); 395 return m_native->objectForId(objectId.id());
396 } 396 }
397 397
398 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const 398 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const
399 { 399 {
400 return m_native->groupName(objectId.id()); 400 return m_native->groupName(objectId.id());
401 } 401 }
402 402
403 void InjectedScript::releaseObjectGroup(const String16& objectGroup) 403 void InjectedScript::releaseObjectGroup(const String16& objectGroup)
404 { 404 {
405 v8::HandleScope handles(m_isolate); 405 v8::HandleScope handles(m_isolate);
406 m_native->releaseObjectGroup(objectGroup); 406 m_native->releaseObjectGroup(objectGroup);
407 if (objectGroup == "console") { 407 if (objectGroup == "console") {
408 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "cl earLastEvaluationResult"); 408 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua tionResult");
409 bool hadException = false; 409 bool hadException = false;
410 callFunctionWithEvalEnabled(function, hadException); 410 callFunctionWithEvalEnabled(function, hadException);
411 ASSERT(!hadException); 411 ASSERT(!hadException);
412 } 412 }
413 } 413 }
414 414
415 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) 415 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled)
416 { 416 {
417 v8::HandleScope handles(m_isolate); 417 v8::HandleScope handles(m_isolate);
418 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setCus tomObjectFormatterEnabled"); 418 V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectForm atterEnabled");
419 function.appendArgument(enabled); 419 function.appendArgument(enabled);
420 makeCall(function); 420 makeCall(function);
421 } 421 }
422 422
423 bool InjectedScript::canAccessInspectedWindow() const 423 bool InjectedScript::canAccessInspectedWindow() const
424 { 424 {
425 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); 425 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext();
426 if (callingContext.IsEmpty()) 426 if (callingContext.IsEmpty())
427 return true; 427 return true;
428 return m_manager->debugger()->client()->callingContextCanAccessContext(calli ngContext, context()); 428 return m_client->callingContextCanAccessContext(callingContext, context());
429 } 429 }
430 430
431 v8::Local<v8::Context> InjectedScript::context() const 431 v8::Local<v8::Context> InjectedScript::context() const
432 { 432 {
433 return m_context.Get(m_isolate); 433 return m_context.Get(m_isolate);
434 } 434 }
435 435
436 v8::Local<v8::Value> InjectedScript::v8Value() const 436 v8::Local<v8::Value> InjectedScript::v8Value() const
437 { 437 {
438 return m_value.Get(m_isolate); 438 return m_value.Get(m_isolate);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 525 }
526 return result.release(); 526 return result.release();
527 } 527 }
528 528
529 void InjectedScript::dispose() 529 void InjectedScript::dispose()
530 { 530 {
531 m_manager->discardInjectedScript(m_contextId); 531 m_manager->discardInjectedScript(m_contextId);
532 } 532 }
533 533
534 } // namespace blink 534 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698