B2G/gecko/netwerk/test/httpserver/test/test_async_response_sending.js
/**
   * Close the copier's source stream, then wait for the given number of bytes
   * and for the given series of arrays of bytes to be written to the sink, then
   * asynchronously continue to the next task.
   *
   * @param status : nsresult
   *   the status to provide when closing the copier's source stream
   * @param bytes : uint
   *   number of bytes of space to make available in the sink
   * @param dataQuantums : [[uint]]
   *   array of byte arrays to expect to be written in sequence to the sink
   */
Close the copier's source stream, then wait for the given number of bytes
and for the given series of arrays of bytes to be written to the sink, then
asynchronously continue to the next task.

@param status : nsresult
the status to provide when closing the copier's source stream
@param bytes : uint
number of bytes of space to make available in the sink
@param dataQuantums : [[uint]]
array of byte arrays to expect to be written in sequence to the sink
Close the copier ' s source stream then wait for the given number of bytes and for the given series of arrays of bytes to be written to the sink then asynchronously continue to the next task . @param status : nsresult the status to provide when closing the copier ' s source stream @param bytes : uint number of bytes of space to make available in the sink @param dataQuantums : [[ uint ]] array of byte arrays to expect to be written in sequence to the sink
function closeSourceAndWaitFor(status, bytes, dataQuantums)
  {
    var self = this;
    do_check_eq(bytes, sum(dataQuantums.map(function(v) { return v.length; })),
                "bytes/quantums mismatch");
    function closeSourceAndWaitForTask()
    {
      self._sink.makeWritable(bytes);
      self._copyableDataStream.closeWithStatus(status);
    }
    this._waitForHelper("closeSourceAndWaitForTask",
                        dataQuantums, closeSourceAndWaitForTask);
  }
function closeSourceAndWaitFor ( status , bytes , dataQuantums ) { var self = this ; do_check_eq ( bytes , sum ( dataQuantums . map ( function ( v ) { return v . length ; } ) ) , "bytes/quantums mismatch" ) ; function closeSourceAndWaitForTask ( ) { self . _sink . makeWritable ( bytes ) ; self . _copyableDataStream . closeWithStatus ( status ) ; } this . _waitForHelper ( "closeSourceAndWaitForTask" , dataQuantums , closeSourceAndWaitForTask ) ; }
Close the copier's source stream, then wait for the given number of bytes
 and for the given series of arrays of bytes to be written to the sink, then
 asynchronously continue to the next task.
Close the copier ' s source stream then wait for the given number of bytes and for the given series of arrays of bytes to be written to the sink then asynchronously continue to the next task .