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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js

Issue 2236033002: [DevTools] Simplify evaluation callbacks on frontend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-was-thrown
Patch Set: Created 4 years, 4 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 getOwnProperties: function(callback) 88 getOwnProperties: function(callback)
89 { 89 {
90 throw "Not implemented"; 90 throw "Not implemented";
91 }, 91 },
92 92
93 /** 93 /**
94 * @return {!Promise<!{properties: ?Array.<!WebInspector.RemoteObjectPropert y>, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>}>} 94 * @return {!Promise<!{properties: ?Array.<!WebInspector.RemoteObjectPropert y>, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>}>}
95 */ 95 */
96 getOwnPropertiesPromise: function() 96 getOwnPropertiesPromise: function()
97 { 97 {
98 return new Promise(promiseConstructor.bind(this)); 98 return new Promise((fulfill) => this.getOwnProperties((properties, inter nalProperties) => fulfill({ properties: properties, internalProperties: internal Properties })));
lushnikov 2016/08/11 00:55:44 drop () lets' not nest arrow functions - looks fu
kozy 2016/08/13 00:11:36 Done.
99
100 /**
101 * @param {function(!{properties: ?Array.<!WebInspector.RemoteObjectProp erty>, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} succes s
102 * @this {WebInspector.RemoteObject}
103 */
104 function promiseConstructor(success)
105 {
106 this.getOwnProperties(getOwnPropertiesCallback.bind(null, success));
107 }
108
109 /**
110 * @param {function(!{properties: ?Array.<!WebInspector.RemoteObjectProp erty>, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} callba ck
111 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties
112 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperti es
113 */
114 function getOwnPropertiesCallback(callback, properties, internalProperti es)
115 {
116 callback({
117 properties: properties,
118 internalProperties: internalProperties
119 });
120 }
121 }, 99 },
122 100
123 /** 101 /**
124 * @param {boolean} accessorPropertiesOnly 102 * @param {boolean} accessorPropertiesOnly
125 * @param {function(?Array<!WebInspector.RemoteObjectProperty>, ?Array<!WebI nspector.RemoteObjectProperty>)} callback 103 * @param {function(?Array<!WebInspector.RemoteObjectProperty>, ?Array<!WebI nspector.RemoteObjectProperty>)} callback
126 */ 104 */
127 getAllProperties: function(accessorPropertiesOnly, callback) 105 getAllProperties: function(accessorPropertiesOnly, callback)
128 { 106 {
129 throw "Not implemented"; 107 throw "Not implemented";
130 }, 108 },
131 109
132 /** 110 /**
133 * @param {boolean} accessorPropertiesOnly 111 * @param {boolean} accessorPropertiesOnly
134 * @return {!Promise<!{properties: ?Array<!WebInspector.RemoteObjectProperty >, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>}>} 112 * @return {!Promise<!{properties: ?Array<!WebInspector.RemoteObjectProperty >, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>}>}
135 */ 113 */
136 getAllPropertiesPromise: function(accessorPropertiesOnly) 114 getAllPropertiesPromise: function(accessorPropertiesOnly)
137 { 115 {
138 return new Promise(promiseConstructor.bind(this)); 116 return new Promise((fulfill) => this.getAllProperties(accessorProperties Only, (properties, internalProperties) => fulfill({ properties: properties, inte rnalProperties: internalProperties })));
139
140 /**
141 * @param {function(!{properties: ?Array<!WebInspector.RemoteObjectPrope rty>, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} success
142 * @this {WebInspector.RemoteObject}
143 */
144 function promiseConstructor(success)
145 {
146 this.getAllProperties(accessorPropertiesOnly, getAllPropertiesCallba ck.bind(null, success));
147 }
148
149 /**
150 * @param {function(!{properties: ?Array<!WebInspector.RemoteObjectPrope rty>, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>})} callback
151 * @param {?Array<!WebInspector.RemoteObjectProperty>} properties
152 * @param {?Array<!WebInspector.RemoteObjectProperty>} internalPropertie s
153 */
154 function getAllPropertiesCallback(callback, properties, internalProperti es)
155 {
156 callback({
157 properties: properties,
158 internalProperties: internalProperties
159 });
160 }
161 }, 117 },
162 118
163 /** 119 /**
164 * @return {!Promise<?Array<!WebInspector.EventListener>>} 120 * @return {!Promise<?Array<!WebInspector.EventListener>>}
165 */ 121 */
166 eventListeners: function() 122 eventListeners: function()
167 { 123 {
168 throw "Not implemented"; 124 throw "Not implemented";
169 }, 125 },
170 126
(...skipping 26 matching lines...) Expand all
197 throw "Not implemented"; 153 throw "Not implemented";
198 }, 154 },
199 155
200 /** 156 /**
201 * @param {function(this:Object, ...)} functionDeclaration 157 * @param {function(this:Object, ...)} functionDeclaration
202 * @param {!Array<!RuntimeAgent.CallArgument>=} args 158 * @param {!Array<!RuntimeAgent.CallArgument>=} args
203 * @return {!Promise<!WebInspector.CallFunctionResult>} 159 * @return {!Promise<!WebInspector.CallFunctionResult>}
204 */ 160 */
205 callFunctionPromise: function(functionDeclaration, args) 161 callFunctionPromise: function(functionDeclaration, args)
206 { 162 {
207 return new Promise(promiseConstructor.bind(this)); 163 return new Promise((fulfill) => this.callFunction(functionDeclaration, a rgs, (object, wasThrown) => fulfill({ object: object, wasThrown: wasThrown })));
lushnikov 2016/08/11 00:55:44 ditto
kozy 2016/08/13 00:11:36 Done.
208
209 /**
210 * @param {function(!WebInspector.CallFunctionResult)} success
211 * @this {WebInspector.RemoteObject}
212 */
213 function promiseConstructor(success)
214 {
215 this.callFunction(functionDeclaration, args, callFunctionCallback.bi nd(null, success));
216 }
217
218 /**
219 * @param {function(!WebInspector.CallFunctionResult)} callback
220 * @param {?WebInspector.RemoteObject} object
221 * @param {boolean=} wasThrown
222 */
223 function callFunctionCallback(callback, object, wasThrown)
224 {
225 callback({
226 object: object,
227 wasThrown: wasThrown
228 });
229 }
230 }, 164 },
231 165
232 /** 166 /**
233 * @template T 167 * @template T
234 * @param {function(this:Object, ...):T} functionDeclaration 168 * @param {function(this:Object, ...):T} functionDeclaration
235 * @param {!Array<!RuntimeAgent.CallArgument>|undefined} args 169 * @param {!Array<!RuntimeAgent.CallArgument>|undefined} args
236 * @param {function(T)} callback 170 * @param {function(T)} callback
237 */ 171 */
238 callFunctionJSON: function(functionDeclaration, args, callback) 172 callFunctionJSON: function(functionDeclaration, args, callback)
239 { 173 {
240 throw "Not implemented"; 174 throw "Not implemented";
241 }, 175 },
242 176
243 /** 177 /**
244 * @param {function(this:Object, ...):T} functionDeclaration 178 * @param {function(this:Object, ...):T} functionDeclaration
245 * @param {!Array<!RuntimeAgent.CallArgument>|undefined} args 179 * @param {!Array<!RuntimeAgent.CallArgument>|undefined} args
246 * @return {!Promise<T>} 180 * @return {!Promise<T>}
247 * @template T 181 * @template T
248 */ 182 */
249 callFunctionJSONPromise: function(functionDeclaration, args) 183 callFunctionJSONPromise: function(functionDeclaration, args)
250 { 184 {
251 return new Promise(promiseConstructor.bind(this)); 185 return new Promise((fulfill) => this.callFunctionJSON(functionDeclaratio n, args, fulfill));
252
253 /**
254 * @this {WebInspector.RemoteObject}
255 */
256 function promiseConstructor(success)
257 {
258 this.callFunctionJSON(functionDeclaration, args, success);
259 }
260 }, 186 },
261 187
262 /** 188 /**
263 * @return {!WebInspector.Target} 189 * @return {!WebInspector.Target}
264 */ 190 */
265 target: function() 191 target: function()
266 { 192 {
267 throw new Error("Target-less object"); 193 throw new Error("Target-less object");
268 }, 194 },
269 195
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 this._type = type; 313 this._type = type;
388 this._subtype = subtype; 314 this._subtype = subtype;
389 if (objectId) { 315 if (objectId) {
390 // handle 316 // handle
391 this._objectId = objectId; 317 this._objectId = objectId;
392 this._description = description; 318 this._description = description;
393 this._hasChildren = (type !== "symbol"); 319 this._hasChildren = (type !== "symbol");
394 this._preview = preview; 320 this._preview = preview;
395 } else { 321 } else {
396 // Primitive or null object. 322 // Primitive or null object.
397 this._description = description || (value + ""); 323 this._description = description;
324 if (!this._description && (typeof value !== "object" || value === null))
325 this._description = value + "";
398 this._hasChildren = false; 326 this._hasChildren = false;
399 if (typeof unserializableValue !== "undefined") { 327 if (typeof unserializableValue !== "undefined") {
400 this._unserializableValue = unserializableValue; 328 this._unserializableValue = unserializableValue;
401 if (unserializableValue === RuntimeAgent.UnserializableValue.Infinit y || 329 if (unserializableValue === RuntimeAgent.UnserializableValue.Infinit y ||
402 unserializableValue === RuntimeAgent.UnserializableValue.Negativ eInfinity || 330 unserializableValue === RuntimeAgent.UnserializableValue.Negativ eInfinity ||
403 unserializableValue === RuntimeAgent.UnserializableValue.Negativ e0 || 331 unserializableValue === RuntimeAgent.UnserializableValue.Negativ e0 ||
404 unserializableValue === RuntimeAgent.UnserializableValue.NaN) { 332 unserializableValue === RuntimeAgent.UnserializableValue.NaN) {
405 this.value = Number(unserializableValue); 333 this.value = Number(unserializableValue);
406 } else { 334 } else {
407 this.value = unserializableValue; 335 this.value = unserializableValue;
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 }, 1438 },
1511 1439
1512 /** 1440 /**
1513 * @return {!WebInspector.RemoteObject} 1441 * @return {!WebInspector.RemoteObject}
1514 */ 1442 */
1515 object: function() 1443 object: function()
1516 { 1444 {
1517 return this._object; 1445 return this._object;
1518 } 1446 }
1519 } 1447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698