[DevTools] Promisify RemoteObject methods

R=pfeldman@chromium.org

Review URL: https://codereview.chromium.org/1307383002

git-svn-id: svn://svn.chromium.org/blink/trunk@201143 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1af71ed4
......@@ -117,13 +117,44 @@ WebInspector.RemoteObject.prototype = {
/**
* @param {boolean} accessorPropertiesOnly
* @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebInspector.RemoteObjectProperty>)} callback
* @param {function(?Array<!WebInspector.RemoteObjectProperty>, ?Array<!WebInspector.RemoteObjectProperty>)} callback
*/
getAllProperties: function(accessorPropertiesOnly, callback)
{
throw "Not implemented";
},
/**
* @param {boolean} accessorPropertiesOnly
* @return {!Promise<!{properties: ?Array<!WebInspector.RemoteObjectProperty>, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>}>}
*/
getAllPropertiesPromise: function(accessorPropertiesOnly)
{
return new Promise(promiseConstructor.bind(this));
/**
* @param {function(!{properties: ?Array<!WebInspector.RemoteObjectProperty>, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} success
* @this {WebInspector.RemoteObject}
*/
function promiseConstructor(success)
{
this.getAllProperties(accessorPropertiesOnly, getAllPropertiesCallback.bind(null, success));
}
/**
* @param {function(!{properties: ?Array<!WebInspector.RemoteObjectProperty>, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>})} callback
* @param {?Array<!WebInspector.RemoteObjectProperty>} properties
* @param {?Array<!WebInspector.RemoteObjectProperty>} internalProperties
*/
function getAllPropertiesCallback(callback, properties, internalProperties)
{
callback({
properties: properties,
internalProperties: internalProperties
});
}
},
/**
* @return {!Promise<?Array<!WebInspector.EventListener>>}
*/
......@@ -185,7 +216,7 @@ WebInspector.RemoteObject.prototype = {
/**
* @param {function(this:Object)} functionDeclaration
* @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args
* @param {!Array<!RuntimeAgent.CallArgument>|undefined} args
* @param {function(*)} callback
*/
callFunctionJSON: function(functionDeclaration, args, callback)
......@@ -193,6 +224,24 @@ WebInspector.RemoteObject.prototype = {
throw "Not implemented";
},
/**
* @param {function(this:Object)} functionDeclaration
* @param {!Array<!RuntimeAgent.CallArgument>|undefined} args
* @return {!Promise<*>}
*/
callFunctionJSONPromise: function(functionDeclaration, args)
{
return new Promise(promiseConstructor.bind(this));
/**
* @this {WebInspector.RemoteObject}
*/
function promiseConstructor(success)
{
this.callFunctionJSON(functionDeclaration, args, success);
}
},
/**
* @return {!WebInspector.Target}
*/
......@@ -225,6 +274,23 @@ WebInspector.RemoteObject.prototype = {
callback(null);
},
/**
* @return {!Promise<?WebInspector.DebuggerModel.FunctionDetails>}
*/
functionDetailsPromise: function()
{
return new Promise(promiseConstructor.bind(this));
/**
* @param {function(?WebInspector.DebuggerModel.FunctionDetails)} success
* @this {WebInspector.RemoteObject}
*/
function promiseConstructor(success)
{
this.functionDetails(success);
}
},
/**
* @param {function(?WebInspector.DebuggerModel.GeneratorObjectDetails)} callback
*/
......@@ -234,7 +300,7 @@ WebInspector.RemoteObject.prototype = {
},
/**
* @param {function(?Array.<!DebuggerAgent.CollectionEntry>)} callback
* @param {function(?Array<!DebuggerAgent.CollectionEntry>)} callback
*/
collectionEntries: function(callback)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment