Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsSyncLoader Class Reference

This class manages loading a single XML document. More...

Inheritance diagram for nsSyncLoader:
Inheritance graph
[legend]
Collaboration diagram for nsSyncLoader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsSyncLoader ()
virtual ~nsSyncLoader ()
NS_DECL_ISUPPORTS nsresult LoadDocument (nsIChannel *aChannel, nsIURI *aLoaderURI, PRBool aChannelIsSync, PRBool aForceToXML, nsIDOMDocument **aResult)
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD Load (nsIDOMEvent *aEvent)
 Processes a page or image load event.
NS_IMETHOD BeforeUnload (nsIDOMEvent *aEvent)
 Processes a page beforeUnload event.
NS_IMETHOD Unload (nsIDOMEvent *aEvent)
 Processes a page unload event.
NS_IMETHOD Abort (nsIDOMEvent *aEvent)
 Processes a load abort event.
NS_IMETHOD Error (nsIDOMEvent *aEvent)
 Processes an load error event.
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.
void onChannelRedirect (in nsIChannel oldChannel, in nsIChannel newChannel, in unsigned long flags)
 Called when a redirect occurs.
void getInterface (in nsIIDRef uuid,[iid_is(uuid), retval] out nsQIResult result)
 Retrieves the specified interface pointer.

Public Attributes

const unsigned long REDIRECT_TEMPORARY = 1 << 0
 This is a temporary redirect.
const unsigned long REDIRECT_PERMANENT = 1 << 1
 This is a permanent redirect.
const unsigned long REDIRECT_INTERNAL = 1 << 2
 This is an internal redirect, i.e.

Protected Member Functions

nsresult PushAsyncStream (nsIStreamListener *aListener)
nsresult PushSyncStream (nsIStreamListener *aListener)

Protected Attributes

nsCOMPtr< nsIChannelmChannel
PRPackedBool mLoading
PRPackedBool mLoadSuccess

Detailed Description

This class manages loading a single XML document.

Definition at line 100 of file nsSyncLoadService.cpp.


Constructor & Destructor Documentation

Definition at line 185 of file nsSyncLoadService.cpp.

{
}

Definition at line 189 of file nsSyncLoadService.cpp.

{
    if (mLoading && mChannel) {
        mChannel->Cancel(NS_BINDING_ABORTED);
    }
}

Member Function Documentation

nsresult nsSyncLoader::Abort ( nsIDOMEvent aEvent) [virtual]

Processes a load abort event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMLoadListener.

Definition at line 397 of file nsSyncLoadService.cpp.

{
    if (mLoading) {
        mLoading = PR_FALSE;
    }

    return NS_OK;
}

Processes a page beforeUnload event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMLoadListener.

Definition at line 383 of file nsSyncLoadService.cpp.

{
    // Like, whatever.

    return NS_OK;
}
nsresult nsSyncLoader::Error ( nsIDOMEvent aEvent) [virtual]

Processes an load error event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMLoadListener.

Definition at line 407 of file nsSyncLoadService.cpp.

{
    if (mLoading) {
        mLoading = PR_FALSE;
    }

    return NS_OK;
}
void nsIInterfaceRequestor::getInterface ( in nsIIDRef  uuid,
[iid_is(uuid), retval] out nsQIResult  result 
) [inherited]

Retrieves the specified interface pointer.

Parameters:
uuidThe IID of the interface being requested.
result[out] The interface pointer to be filled in if the interface is accessible.
Returns:
NS_OK - interface was successfully returned. NS_NOINTERFACE - interface not accessible. NS_ERROR* - method failure.

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.

Definition at line 365 of file nsSyncLoadService.cpp.

{
    return NS_OK;
}
nsresult nsSyncLoader::Load ( nsIDOMEvent aEvent) [virtual]

Processes a page or image load event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMLoadListener.

Definition at line 372 of file nsSyncLoadService.cpp.

{
    if (mLoading) {
        mLoading = PR_FALSE;
        mLoadSuccess = PR_TRUE;
    }

    return NS_OK;
}
NS_DECL_ISUPPORTS nsresult nsSyncLoader::LoadDocument ( nsIChannel aChannel,
nsIURI aLoaderURI,
PRBool  aChannelIsSync,
PRBool  aForceToXML,
nsIDOMDocument **  aResult 
)
void nsIChannelEventSink::onChannelRedirect ( in nsIChannel  oldChannel,
in nsIChannel  newChannel,
in unsigned long  flags 
) [inherited]

Called when a redirect occurs.

This may happen due to an HTTP 3xx status code.

Parameters:
oldChannelThe channel that's being redirected.
newChannelThe new channel. This channel is not opened yet.
flagsFlags indicating the type of redirect. A bitmask consisting of flags from above. One of REDIRECT_TEMPORARY and REDIRECT_PERMANENT will always be set.
Exceptions:
<any>Throwing an exception will cancel the load. No network request for the new channel will be made.

Definition at line 308 of file nsSyncLoadService.cpp.

{
    nsresult rv = NS_OK;

    // Set up a new eventqueue
    nsCOMPtr<nsIEventQueueService> service = 
        do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIEventQueue> currentThreadQ;
    rv = service->PushThreadEventQueue(getter_AddRefs(currentThreadQ));
    NS_ENSURE_SUCCESS(rv, rv);

    // Hook us up to listen to redirects and the like
    mChannel->SetNotificationCallbacks(this);

    // Start reading from the channel
    rv = mChannel->AsyncOpen(aListener, nsnull);

    if (NS_SUCCEEDED(rv)) {
        mLoading = PR_TRUE;

        // process events until we're finished.
        PLEvent *event;
        while (mLoading && NS_SUCCEEDED(rv)) {
            rv = currentThreadQ->WaitForEvent(&event);
            NS_ASSERTION(NS_SUCCEEDED(rv), ": currentThreadQ->WaitForEvent failed...\n");
            if (NS_SUCCEEDED(rv)) {
                rv = currentThreadQ->HandleEvent(event);
                NS_ASSERTION(NS_SUCCEEDED(rv), ": currentThreadQ->HandleEvent failed...\n");
            }
        }
    }

    // Note that if AsyncOpen failed that's ok -- the only caller of
    // this method nulls out mChannel immediately after we return.

    service->PopThreadEventQueue(currentThreadQ);
    
    return rv;
}

Here is the call graph for this function:

Definition at line 351 of file nsSyncLoadService.cpp.

Here is the call graph for this function:

nsresult nsSyncLoader::Unload ( nsIDOMEvent aEvent) [virtual]

Processes a page unload event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMLoadListener.

Definition at line 391 of file nsSyncLoadService.cpp.

{
    return NS_OK;
}

Member Data Documentation

Definition at line 133 of file nsSyncLoadService.cpp.

Definition at line 134 of file nsSyncLoadService.cpp.

Definition at line 135 of file nsSyncLoadService.cpp.

const unsigned long nsIChannelEventSink::REDIRECT_INTERNAL = 1 << 2 [inherited]

This is an internal redirect, i.e.

it was not initiated by the remote server, but is specific to the channel implementation.

The new URI may be identical to the old one.

Definition at line 81 of file nsIChannelEventSink.idl.

const unsigned long nsIChannelEventSink::REDIRECT_PERMANENT = 1 << 1 [inherited]

This is a permanent redirect.

New requests for this resource should use the URI of the new channel (This might be an HTTP 301 reponse). If this flag is not set, this is a temporary redirect.

The new URI may be identical to the old one.

Definition at line 73 of file nsIChannelEventSink.idl.

const unsigned long nsIChannelEventSink::REDIRECT_TEMPORARY = 1 << 0 [inherited]

This is a temporary redirect.

New requests for this resource should continue to use the URI of the old channel.

The new URI may be identical to the old one.

Definition at line 64 of file nsIChannelEventSink.idl.


The documentation for this class was generated from the following file: