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

Side by Side Diff: Source/core/inspector/InjectedScript.cpp

Issue 1020233002: [bindings] [devtools] Migrate the usage of ScriptValue.toJSONValue() to ScriptValue::to<JSONValuePt… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue& callFrames, int asyncOrdinal) 274 PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue& callFrames, int asyncOrdinal)
275 { 275 {
276 ASSERT(!isEmpty()); 276 ASSERT(!isEmpty());
277 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"); 277 ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames");
278 function.appendArgument(callFrames); 278 function.appendArgument(callFrames);
279 function.appendArgument(asyncOrdinal); 279 function.appendArgument(asyncOrdinal);
280 bool hadException = false; 280 bool hadException = false;
281 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep tion); 281 ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadExcep tion);
282 ASSERT(!hadException); 282 ASSERT(!hadException);
283 RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState()); 283 RefPtr<JSONValue> result = toJSONValue(callFramesValue);
284 if (result && result->type() == JSONValue::TypeArray) 284 if (result && result->type() == JSONValue::TypeArray)
285 return Array<CallFrame>::runtimeCast(result); 285 return Array<CallFrame>::runtimeCast(result);
286 return Array<CallFrame>::create(); 286 return Array<CallFrame>::create();
287 } 287 }
288 288
289 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const 289 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const
290 { 290 {
291 ASSERT(!isEmpty()); 291 ASSERT(!isEmpty());
292 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); 292 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject");
293 wrapFunction.appendArgument(value); 293 wrapFunction.appendArgument(value);
294 wrapFunction.appendArgument(groupName); 294 wrapFunction.appendArgument(groupName);
295 wrapFunction.appendArgument(canAccessInspectedWindow()); 295 wrapFunction.appendArgument(canAccessInspectedWindow());
296 wrapFunction.appendArgument(generatePreview); 296 wrapFunction.appendArgument(generatePreview);
297 bool hadException = false; 297 bool hadException = false;
298 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); 298 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException);
299 if (hadException) 299 if (hadException)
300 return nullptr; 300 return nullptr;
301 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); 301 RefPtr<JSONObject> rawResult = toJSONValue(r)->asObject();
302 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); 302 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
303 } 303 }
304 304
305 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S criptValue& table, const ScriptValue& columns) const 305 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const S criptValue& table, const ScriptValue& columns) const
306 { 306 {
307 ASSERT(!isEmpty()); 307 ASSERT(!isEmpty());
308 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"); 308 ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable");
309 wrapFunction.appendArgument(canAccessInspectedWindow()); 309 wrapFunction.appendArgument(canAccessInspectedWindow());
310 wrapFunction.appendArgument(table); 310 wrapFunction.appendArgument(table);
311 if (columns.isEmpty()) 311 if (columns.isEmpty())
312 wrapFunction.appendArgument(false); 312 wrapFunction.appendArgument(false);
313 else 313 else
314 wrapFunction.appendArgument(columns); 314 wrapFunction.appendArgument(columns);
315 bool hadException = false; 315 bool hadException = false;
316 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); 316 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException);
317 if (hadException) 317 if (hadException)
318 return nullptr; 318 return nullptr;
319 RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject(); 319 RefPtr<JSONObject> rawResult = toJSONValue(r)->asObject();
320 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult); 320 return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
321 } 321 }
322 322
323 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no de, const String& groupName) 323 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* no de, const String& groupName)
324 { 324 {
325 return wrapObject(nodeAsScriptValue(node), groupName); 325 return wrapObject(nodeAsScriptValue(node), groupName);
326 } 326 }
327 327
328 ScriptValue InjectedScript::findObjectById(const String& objectId) const 328 ScriptValue InjectedScript::findObjectById(const String& objectId) const
329 { 329 {
(...skipping 28 matching lines...) Expand all
358 { 358 {
359 ASSERT(!isEmpty()); 359 ASSERT(!isEmpty());
360 ScriptFunctionCall function(injectedScriptObject(), "setCustomObjectFormatte rEnabled"); 360 ScriptFunctionCall function(injectedScriptObject(), "setCustomObjectFormatte rEnabled");
361 function.appendArgument(enabled); 361 function.appendArgument(enabled);
362 RefPtr<JSONValue> result; 362 RefPtr<JSONValue> result;
363 makeCall(function, &result); 363 makeCall(function, &result);
364 } 364 }
365 365
366 } // namespace blink 366 } // namespace blink
367 367
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp ('k') | Source/core/inspector/InjectedScriptBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698