gecko-dev/netwerk/base/public/nsIStreamObserver.h

82 lines
3.0 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIStreamObserver_h___
#define nsIStreamObserver_h___
#include "nsISupports.h"
#include "nsIEventQueue.h"
class nsIUrl;
class nsIString;
// XXX regenerate:
#define NS_ISTREAMOBSERVER_IID \
{ /* 00ca4510-f14a-11d2-9322-000000000000 */ \
0x00ca4510, \
0xf14a, \
0x11d2, \
{0x93, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
class nsIStreamObserver : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTREAMOBSERVER_IID);
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartBinding(nsISupports* context) = 0;
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnStopBinding(nsISupports* context,
nsresult aStatus,
nsIString* aMsg) = 0;
};
// An asynchronous stream observer is used to ship data over to another thread specified
// by the thread's event queue. The receiver stream observer is then used to receive
// the notifications on the other thread.
extern nsresult
NS_NewAsyncStreamObserver(nsIStreamObserver* *result,
nsIEventQueue* eventQueue,
nsIStreamObserver* receiver);
// Generic status codes for OnStopBinding:
#define NS_BINDING_SUCCEEDED NS_OK
#define NS_BINDING_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 1)
#define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
#endif /* nsIIStreamObserver_h___ */