2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-02-03 02:04:47 +03:00
|
|
|
|
2006-10-25 01:47:40 +04:00
|
|
|
#include "nsIStreamListener.idl"
|
2000-02-03 02:04:47 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
interface nsIRequest;
|
2000-02-03 02:04:47 +03:00
|
|
|
interface nsIStreamLoader;
|
|
|
|
|
|
|
|
[scriptable, uuid(359F7990-D4E9-11d3-A1A5-0050041CAF44)]
|
|
|
|
interface nsIStreamLoaderObserver : nsISupports
|
|
|
|
{
|
2005-09-30 02:00:26 +04:00
|
|
|
/**
|
|
|
|
* Called when the entire stream has been loaded.
|
|
|
|
*
|
|
|
|
* @param loader the stream loader that loaded the stream.
|
2006-10-25 01:47:40 +04:00
|
|
|
* @param ctxt the context parameter of the underlying channel
|
2005-09-30 02:00:26 +04:00
|
|
|
* @param status the status of the underlying channel
|
|
|
|
* @param resultLength the length of the data loaded
|
|
|
|
* @param result the data
|
|
|
|
*
|
|
|
|
* This method will always be called asynchronously by the
|
|
|
|
* nsIStreamLoader involved, on the thread that called the
|
|
|
|
* loader's init() method.
|
2009-09-17 14:14:25 +04:00
|
|
|
*
|
|
|
|
* If the observer wants to take over responsibility for the
|
|
|
|
* data buffer (result), it returns NS_SUCCESS_ADOPTED_DATA
|
|
|
|
* in place of NS_OK as its success code. The loader will then
|
2015-02-19 07:51:06 +03:00
|
|
|
* "forget" about the data and not free() it after
|
|
|
|
* onStreamComplete() returns; observer must call free()
|
2014-04-17 18:59:54 +04:00
|
|
|
* when the data is no longer required.
|
2005-09-30 02:00:26 +04:00
|
|
|
*/
|
2000-02-03 02:04:47 +03:00
|
|
|
void onStreamComplete(in nsIStreamLoader loader,
|
|
|
|
in nsISupports ctxt,
|
|
|
|
in nsresult status,
|
|
|
|
in unsigned long resultLength,
|
2004-04-27 20:06:00 +04:00
|
|
|
[const,array,size_is(resultLength)] in octet result);
|
2000-02-03 02:04:47 +03:00
|
|
|
};
|
|
|
|
|
2004-04-20 17:54:47 +04:00
|
|
|
/**
|
|
|
|
* Asynchronously loads a channel into a memory buffer.
|
2005-01-09 23:43:35 +03:00
|
|
|
*
|
2006-10-25 01:47:40 +04:00
|
|
|
* To use this interface, first call init() with a nsIStreamLoaderObserver
|
|
|
|
* that will be notified when the data has been loaded. Then call asyncOpen()
|
|
|
|
* on the channel with the nsIStreamLoader as the listener. The context
|
|
|
|
* argument in the asyncOpen() call will be passed to the onStreamComplete()
|
|
|
|
* callback.
|
|
|
|
*
|
2005-01-09 23:43:35 +03:00
|
|
|
* XXX define behaviour for sizes >4 GB
|
2004-04-20 17:54:47 +04:00
|
|
|
*/
|
2006-10-25 01:47:40 +04:00
|
|
|
[scriptable, uuid(8ea7e890-8211-11d9-8bde-f66bad1e3f3a)]
|
|
|
|
interface nsIStreamLoader : nsIStreamListener
|
2000-02-03 02:04:47 +03:00
|
|
|
{
|
2004-04-20 17:54:47 +04:00
|
|
|
/**
|
|
|
|
* Initialize this stream loader, and start loading the data.
|
|
|
|
*
|
|
|
|
* @param aObserver
|
|
|
|
* An observer that will be notified when the data is complete.
|
|
|
|
*/
|
2006-10-25 01:47:40 +04:00
|
|
|
void init(in nsIStreamLoaderObserver aObserver);
|
2000-02-03 02:04:47 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of bytes read so far.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long numBytesRead;
|
2000-03-21 07:16:03 +03:00
|
|
|
|
|
|
|
/**
|
2004-04-20 17:54:47 +04:00
|
|
|
* Gets the request that loaded this file.
|
|
|
|
* null after the request has finished loading.
|
2000-04-14 06:46:28 +04:00
|
|
|
*/
|
2001-02-21 23:38:08 +03:00
|
|
|
readonly attribute nsIRequest request;
|
2000-02-03 02:04:47 +03:00
|
|
|
};
|