Bug 1227474 - Promisify all client methods. r=jryans
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 03 Dec 2015 06:42:34 -0800
changeset 309623 1f527cd0e45af932a8b825ee1e24e74c7c85324a
parent 309622 30e7a3738645f55e9f492e063370775e9115af32
child 309624 3858001d34b3f237ce11f9685284bebc36515a2d
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1227474
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1227474 - Promisify all client methods. r=jryans
devtools/shared/client/main.js
--- a/devtools/shared/client/main.js
+++ b/devtools/shared/client/main.js
@@ -238,16 +238,19 @@ const DebuggerClient = exports.DebuggerC
  *        The function to call before sending the packet. Is passed the packet,
  *        and the return value is used as the new packet. The |this| context is
  *        the instance of the client object we are defining a method for.
  * @param after
  *        The function to call after the response is received. It is passed the
  *        response, and the return value is considered the new response that
  *        will be passed to the callback. The |this| context is the instance of
  *        the client object we are defining a method for.
+ * @return Request
+ *         The `Request` object that is a Promise object and resolves once
+ *         we receive the response. (See request method for more details)
  */
 DebuggerClient.requester = function (aPacketSkeleton,
                                      { telemetry, before, after }) {
   return DevToolsUtils.makeInfallible(function (...args) {
     let histogram, startTime;
     if (telemetry) {
       let transportType = this._transport.onOutputStreamReady === undefined
         ? "LOCAL_"
@@ -271,17 +274,17 @@ DebuggerClient.requester = function (aPa
         outgoingPacket[k] = aPacketSkeleton[k];
       }
     }
 
     if (before) {
       outgoingPacket = before.call(this, outgoingPacket);
     }
 
-    this.request(outgoingPacket, DevToolsUtils.makeInfallible((aResponse) => {
+    return this.request(outgoingPacket, DevToolsUtils.makeInfallible((aResponse) => {
       if (after) {
         let { from } = aResponse;
         aResponse = after.call(this, aResponse);
         if (!aResponse.from) {
           aResponse.from = from;
         }
       }