tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsIStreamListener.idl (2016B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "nsIRequestObserver.idl"
      7 
      8 interface nsIInputStream;
      9 
     10 /**
     11 * nsIStreamListener
     12 *
     13 * Extends nsIRequestObserver to asynchronously receive and process data from a network request.
     14 * After successfully calling nsIRequest.asyncOpen the nsIRequestObserver.onStartRequest
     15 * must be called exactly once. That can be followed by 0 or more calls to onDataAvailable.
     16 * After all onDataAvailable calls have been made, nsIRequestObserver.onStopRequest must
     17 * be called exactly once to signal the request is complete.
     18 *
     19 */
     20 [scriptable, uuid(3b4c8a77-76ba-4610-b316-678c73a3b88c)]
     21 interface nsIStreamListener : nsIRequestObserver
     22 {
     23    /**
     24     * Called when the next chunk of data (corresponding to the request) may
     25     * be read without blocking the calling thread.  The onDataAvailable impl
     26     * must read exactly |aCount| bytes of data before returning.
     27     *
     28     * @param aRequest request corresponding to the source of the data
     29     * @param aInputStream input stream containing the data chunk
     30     * @param aOffset
     31     *        Number of bytes that were sent in previous onDataAvailable calls
     32     *        for this request. In other words, the sum of all previous count
     33     *        parameters.
     34     * @param aCount number of bytes available in the stream.  aCount may not
     35     *        be 0.
     36     *
     37     * NOTE: The aInputStream parameter must implement readSegments.
     38     *
     39     * An exception thrown from onDataAvailable has the side-effect of
     40     * causing the request to be canceled.
     41     */
     42    void onDataAvailable(in nsIRequest aRequest,
     43                         in nsIInputStream aInputStream,
     44                         in unsigned long long aOffset,
     45                         in unsigned long aCount);
     46 };