netwerk/base/public/nsIStreamLoader.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/public/nsIStreamLoader.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsIStreamListener.idl"
    1.10 +
    1.11 +interface nsIRequest;
    1.12 +interface nsIStreamLoader;
    1.13 +
    1.14 +[scriptable, uuid(359F7990-D4E9-11d3-A1A5-0050041CAF44)]
    1.15 +interface nsIStreamLoaderObserver : nsISupports
    1.16 +{
    1.17 +    /**
    1.18 +     * Called when the entire stream has been loaded.
    1.19 +     *
    1.20 +     * @param loader the stream loader that loaded the stream.
    1.21 +     * @param ctxt the context parameter of the underlying channel
    1.22 +     * @param status the status of the underlying channel
    1.23 +     * @param resultLength the length of the data loaded
    1.24 +     * @param result the data
    1.25 +     *
    1.26 +     * This method will always be called asynchronously by the
    1.27 +     * nsIStreamLoader involved, on the thread that called the
    1.28 +     * loader's init() method.
    1.29 +     *
    1.30 +     * If the observer wants to take over responsibility for the
    1.31 +     * data buffer (result), it returns NS_SUCCESS_ADOPTED_DATA
    1.32 +     * in place of NS_OK as its success code. The loader will then
    1.33 +     * "forget" about the data and not NS_Free() it after
    1.34 +     * onStreamComplete() returns; observer must call NS_Free()
    1.35 +     * when the data is no longer required.
    1.36 +     */
    1.37 +    void onStreamComplete(in nsIStreamLoader loader,
    1.38 +                          in nsISupports ctxt,
    1.39 +                          in nsresult status,
    1.40 +                          in unsigned long resultLength,
    1.41 +                          [const,array,size_is(resultLength)] in octet result);
    1.42 +};
    1.43 +
    1.44 +/**
    1.45 + * Asynchronously loads a channel into a memory buffer.
    1.46 + *
    1.47 + * To use this interface, first call init() with a nsIStreamLoaderObserver
    1.48 + * that will be notified when the data has been loaded. Then call asyncOpen()
    1.49 + * on the channel with the nsIStreamLoader as the listener. The context
    1.50 + * argument in the asyncOpen() call will be passed to the onStreamComplete()
    1.51 + * callback.
    1.52 + *
    1.53 + * XXX define behaviour for sizes >4 GB
    1.54 + */
    1.55 +[scriptable, uuid(8ea7e890-8211-11d9-8bde-f66bad1e3f3a)]
    1.56 +interface nsIStreamLoader : nsIStreamListener
    1.57 +{
    1.58 +    /**
    1.59 +     * Initialize this stream loader, and start loading the data.
    1.60 +     *
    1.61 +     * @param aObserver
    1.62 +     *        An observer that will be notified when the data is complete.
    1.63 +     */
    1.64 +    void init(in nsIStreamLoaderObserver aObserver);
    1.65 +
    1.66 +    /**
    1.67 +     * Gets the number of bytes read so far.
    1.68 +     */
    1.69 +    readonly attribute unsigned long numBytesRead;
    1.70 +
    1.71 +    /**
    1.72 +     * Gets the request that loaded this file.
    1.73 +     * null after the request has finished loading.
    1.74 +     */
    1.75 +    readonly attribute nsIRequest request;
    1.76 +};

mercurial