netwerk/base/public/nsIStreamLoader.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     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/. */
     6 #include "nsIStreamListener.idl"
     8 interface nsIRequest;
     9 interface nsIStreamLoader;
    11 [scriptable, uuid(359F7990-D4E9-11d3-A1A5-0050041CAF44)]
    12 interface nsIStreamLoaderObserver : nsISupports
    13 {
    14     /**
    15      * Called when the entire stream has been loaded.
    16      *
    17      * @param loader the stream loader that loaded the stream.
    18      * @param ctxt the context parameter of the underlying channel
    19      * @param status the status of the underlying channel
    20      * @param resultLength the length of the data loaded
    21      * @param result the data
    22      *
    23      * This method will always be called asynchronously by the
    24      * nsIStreamLoader involved, on the thread that called the
    25      * loader's init() method.
    26      *
    27      * If the observer wants to take over responsibility for the
    28      * data buffer (result), it returns NS_SUCCESS_ADOPTED_DATA
    29      * in place of NS_OK as its success code. The loader will then
    30      * "forget" about the data and not NS_Free() it after
    31      * onStreamComplete() returns; observer must call NS_Free()
    32      * when the data is no longer required.
    33      */
    34     void onStreamComplete(in nsIStreamLoader loader,
    35                           in nsISupports ctxt,
    36                           in nsresult status,
    37                           in unsigned long resultLength,
    38                           [const,array,size_is(resultLength)] in octet result);
    39 };
    41 /**
    42  * Asynchronously loads a channel into a memory buffer.
    43  *
    44  * To use this interface, first call init() with a nsIStreamLoaderObserver
    45  * that will be notified when the data has been loaded. Then call asyncOpen()
    46  * on the channel with the nsIStreamLoader as the listener. The context
    47  * argument in the asyncOpen() call will be passed to the onStreamComplete()
    48  * callback.
    49  *
    50  * XXX define behaviour for sizes >4 GB
    51  */
    52 [scriptable, uuid(8ea7e890-8211-11d9-8bde-f66bad1e3f3a)]
    53 interface nsIStreamLoader : nsIStreamListener
    54 {
    55     /**
    56      * Initialize this stream loader, and start loading the data.
    57      *
    58      * @param aObserver
    59      *        An observer that will be notified when the data is complete.
    60      */
    61     void init(in nsIStreamLoaderObserver aObserver);
    63     /**
    64      * Gets the number of bytes read so far.
    65      */
    66     readonly attribute unsigned long numBytesRead;
    68     /**
    69      * Gets the request that loaded this file.
    70      * null after the request has finished loading.
    71      */
    72     readonly attribute nsIRequest request;
    73 };

mercurial