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

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

mercurial