Back to index

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

#include <nsLoadGroup.h>

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

List of all members.

Public Member Functions

NS_DECL_AGGREGATED
NS_DECL_NSIREQUEST
NS_DECL_NSILOADGROUP
NS_DECL_NSISUPPORTSPRIORITY 
nsLoadGroup (nsISupports *outer)
void addRequest (in nsIRequest aRequest, in nsISupports aContext)
 Adds a new request to the group.
void removeRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatus)
 Removes a request from the group.
boolean isPending ()
 Indicates whether the request is pending.
void cancel (in nsresult aStatus)
 Cancels the current request.
void suspend ()
 Suspends the current request.
void resume ()
 Resumes the current request.
void adjustPriority (in long delta)
 This method adjusts the priority attribute by a given delta.

Static Public Member Functions

static NS_METHOD Create (nsISupports *aOuter, REFNSIID aIID, void **aResult)

Public Attributes

attribute nsIRequestObserver groupObserver
 The group observer is notified when requests are added to and removed from this load group.
attribute nsIRequest defaultLoadRequest
 Accesses the default load request for the group.
readonly attribute
nsISimpleEnumerator 
requests
 Returns the requests contained directly in this group.
readonly attribute unsigned long activeCount
 Returns the count of "active" requests (ie.
attribute nsIInterfaceRequestor notificationCallbacks
 Notification callbacks for the load group.
readonly attribute AUTF8String name
 The name of the request.
readonly attribute nsresult status
 The error status associated with the request.
attribute nsILoadGroup loadGroup
 The load group of this request.
attribute nsLoadFlags loadFlags
 The load flags of this request.
const unsigned long LOAD_NORMAL = 0
 No special load flags:
const unsigned long LOAD_BACKGROUND = 1 << 0
 Don't deliver status notifications to the nsIProgressEventSink, or keep this load from completing the nsILoadGroup it may belong to.
const unsigned long INHIBIT_CACHING = 1 << 7
 This flag prevents caching of any kind.
const unsigned long INHIBIT_PERSISTENT_CACHING = 1 << 8
 This flag prevents caching on disk (or other persistent media), which may be needed to preserve privacy.
const unsigned long LOAD_BYPASS_CACHE = 1 << 9
 Force an end-to-end download of content data from the origin server.
const unsigned long LOAD_FROM_CACHE = 1 << 10
 Load from the cache, bypassing protocol specific validation logic.
const unsigned long VALIDATE_ALWAYS = 1 << 11
 The following flags control the frequency of cached content validation when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set.
const unsigned long VALIDATE_NEVER = 1 << 12
const unsigned long VALIDATE_ONCE_PER_SESSION = 1 << 13
const long PRIORITY_HIGHEST = -20
 Typical priority values.
const long PRIORITY_HIGH = -10
const long PRIORITY_NORMAL = 0
const long PRIORITY_LOW = 10
const long PRIORITY_LOWEST = 20
attribute long priority
 This attribute may be modified to change the priority of this object.

Protected Member Functions

virtual ~nsLoadGroup ()
nsresult Init ()
nsresult MergeLoadFlags (nsIRequest *aRequest, nsLoadFlags &flags)

Protected Attributes

PRUint32 mForegroundCount
PRUint32 mLoadFlags
nsCOMPtr< nsILoadGroupmLoadGroup
nsCOMPtr< nsIInterfaceRequestormCallbacks
nsCOMPtr< nsIRequestmDefaultLoadRequest
PLDHashTable mRequests
nsWeakPtr mObserver
nsresult mStatus
PRInt32 mPriority
PRBool mIsCanceling

Detailed Description

Definition at line 55 of file nsLoadGroup.h.


Constructor & Destructor Documentation

nsLoadGroup::nsLoadGroup ( nsISupports *  outer)

Definition at line 146 of file nsLoadGroup.cpp.

    : mForegroundCount(0)
    , mLoadFlags(LOAD_NORMAL)
    , mStatus(NS_OK)
    , mPriority(PRIORITY_NORMAL)
    , mIsCanceling(PR_FALSE)
{
    NS_INIT_AGGREGATED(outer);

#if defined(PR_LOGGING)
    // Initialize the global PRLogModule for nsILoadGroup logging
    if (nsnull == gLoadGroupLog)
        gLoadGroupLog = PR_NewLogModule("LoadGroup");
#endif

    LOG(("LOADGROUP [%x]: Created.\n", this));

    // Initialize the ops in the hash to null to make sure we get
    // consistent errors if someone fails to call ::Init() on an
    // nsLoadGroup.
    mRequests.ops = nsnull;
}

Here is the caller graph for this function:

nsLoadGroup::~nsLoadGroup ( ) [protected, virtual]

Definition at line 169 of file nsLoadGroup.cpp.

{
    nsresult rv;

    rv = Cancel(NS_BINDING_ABORTED);
    NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");

    if (mRequests.ops) {
        PL_DHashTableFinish(&mRequests);
    }

    mDefaultLoadRequest = 0;

    LOG(("LOADGROUP [%x]: Destroyed.\n", this));
}

Here is the call graph for this function:


Member Function Documentation

void nsILoadGroup::addRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Adds a new request to the group.

This will cause the default load flags to be applied to the request. If this is a foreground request then the groupObserver's onStartRequest will be called.

If the request is the default load request or if the default load request is null, then the load group will inherit its load flags from the request.

This method adjusts the priority attribute by a given delta.

It helps reduce the amount of coding required to increment or decrement the value of the priority attribute.

void nsIRequest::cancel ( in nsresult  aStatus) [inherited]

Cancels the current request.

This will close any open input or output streams and terminate any async requests. Users should normally pass NS_BINDING_ABORTED, although other errors may also be passed. The error passed in will become the value of the status attribute.

Parameters:
aStatusthe reason for canceling this request.

NOTE: most nsIRequest implementations expect aStatus to be a failure code; however, some implementations may allow aStatus to be a success code such as NS_OK. In general, aStatus should be a failure code.

NS_METHOD nsLoadGroup::Create ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 213 of file nsLoadGroup.cpp.

{
    NS_ENSURE_ARG_POINTER(aResult);
    NS_ENSURE_PROPER_AGGREGATION(aOuter, aIID);

    nsresult rv;
    nsLoadGroup* group = new nsLoadGroup(aOuter);
    if (group == nsnull) {
        *aResult = nsnull;
        return NS_ERROR_OUT_OF_MEMORY;
    }

    rv = group->Init();
    if (NS_SUCCEEDED(rv)) {
        rv = group->AggregatedQueryInterface(aIID, aResult);
    }

    if (NS_FAILED(rv))
        delete group;

    return rv;
}

Here is the call graph for this function:

nsresult nsLoadGroup::Init ( void  ) [protected]

Definition at line 186 of file nsLoadGroup.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIRequest::isPending ( ) [inherited]

Indicates whether the request is pending.

nsIRequest::isPending is true when there is an outstanding asynchronous event that will make the request no longer be pending. Requests do not necessarily start out pending; in some cases, requests have to be explicitly initiated (e.g. nsIChannel implementations are only pending once asyncOpen returns successfully).

Requests can become pending multiple times during their lifetime.

Returns:
TRUE if the request has yet to reach completion.
FALSE if the request has reached completion (e.g., after OnStopRequest has fired).
Note:
Suspended requests are still considered pending.
nsresult nsLoadGroup::MergeLoadFlags ( nsIRequest aRequest,
nsLoadFlags flags 
) [protected]

Definition at line 857 of file nsLoadGroup.cpp.

{
    nsresult rv;
    nsLoadFlags flags, oldFlags;

    rv = aRequest->GetLoadFlags(&flags);
    if (NS_FAILED(rv)) 
        return rv;

    oldFlags = flags;

    // Inherit the following bits...
    flags |= (mLoadFlags & (LOAD_BACKGROUND |
                            LOAD_BYPASS_CACHE |
                            LOAD_FROM_CACHE |
                            VALIDATE_ALWAYS |
                            VALIDATE_ONCE_PER_SESSION |
                            VALIDATE_NEVER));

    if (flags != oldFlags)
        rv = aRequest->SetLoadFlags(flags);

    outFlags = flags;
    return rv;
}
void nsILoadGroup::removeRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatus 
) [inherited]

Removes a request from the group.

If this is a foreground request then the groupObserver's onStopRequest will be called.

void nsIRequest::resume ( ) [inherited]

Resumes the current request.

This may have the effect of re-opening any underlying transport and will resume the delivery of data to any open streams.

void nsIRequest::suspend ( ) [inherited]

Suspends the current request.

This may have the effect of closing any underlying transport (in order to free up resources), although any open streams remain logically opened and will continue delivering data when the transport is resumed.

NOTE: some implementations are unable to immediately suspend, and may continue to deliver events already posted to an event queue. In general, callers should be capable of handling events even after suspending a request.


Member Data Documentation

readonly attribute unsigned long nsILoadGroup::activeCount [inherited]

Returns the count of "active" requests (ie.

requests without the LOAD_BACKGROUND bit set).

Definition at line 99 of file nsILoadGroup.idl.

Accesses the default load request for the group.

Each time a number of requests are added to a group, the defaultLoadRequest may be set to indicate that all of the requests are related to a base request.

The load group inherits its load flags from the default load request. If the default load request is NULL, then the group's load flags are not changed.

Definition at line 67 of file nsILoadGroup.idl.

The group observer is notified when requests are added to and removed from this load group.

The groupObserver is weak referenced.

Definition at line 56 of file nsILoadGroup.idl.

const unsigned long nsIRequest::INHIBIT_CACHING = 1 << 7 [inherited]

This flag prevents caching of any kind.

It does not, however, prevent cached content from being used to satisfy this request.

Definition at line 153 of file nsIRequest.idl.

const unsigned long nsIRequest::INHIBIT_PERSISTENT_CACHING = 1 << 8 [inherited]

This flag prevents caching on disk (or other persistent media), which may be needed to preserve privacy.

For HTTPS, this flag is set auto- matically.

Definition at line 160 of file nsIRequest.idl.

const unsigned long nsIRequest::LOAD_BACKGROUND = 1 << 0 [inherited]

Don't deliver status notifications to the nsIProgressEventSink, or keep this load from completing the nsILoadGroup it may belong to.

Definition at line 143 of file nsIRequest.idl.

const unsigned long nsIRequest::LOAD_BYPASS_CACHE = 1 << 9 [inherited]

Force an end-to-end download of content data from the origin server.

This flag is used for a shift-reload.

Definition at line 172 of file nsIRequest.idl.

const unsigned long nsIRequest::LOAD_FROM_CACHE = 1 << 10 [inherited]

Load from the cache, bypassing protocol specific validation logic.

This flag is used when browsing via history. It is not recommended for normal browsing as it may likely violate reasonable assumptions made by the server and confuse users.

Definition at line 180 of file nsIRequest.idl.

const unsigned long nsIRequest::LOAD_NORMAL = 0 [inherited]

No special load flags:

Definition at line 137 of file nsIRequest.idl.

The load flags of this request.

Bits 0-15 are reserved.

When added to a load group, this request's load flags are merged with the load flags of the load group.

Definition at line 128 of file nsIRequest.idl.

The load group of this request.

While pending, the request is a member of the load group. It is the responsibility of the request to implement this policy.

Definition at line 120 of file nsIRequest.idl.

Definition at line 93 of file nsLoadGroup.h.

Definition at line 95 of file nsLoadGroup.h.

Definition at line 89 of file nsLoadGroup.h.

Definition at line 102 of file nsLoadGroup.h.

Definition at line 90 of file nsLoadGroup.h.

Definition at line 92 of file nsLoadGroup.h.

Definition at line 98 of file nsLoadGroup.h.

Definition at line 101 of file nsLoadGroup.h.

Definition at line 96 of file nsLoadGroup.h.

Definition at line 100 of file nsLoadGroup.h.

readonly attribute AUTF8String nsIRequest::name [inherited]

The name of the request.

Often this is the URI of the request.

Definition at line 55 of file nsIRequest.idl.

Notification callbacks for the load group.

Definition at line 104 of file nsILoadGroup.idl.

This attribute may be modified to change the priority of this object.

The implementation of this interface is free to truncate a given priority value to whatever limits are appropriate. Typically, this attribute is initialized to PRIORITY_NORMAL, but implementations may choose to assign a different initial value.

Definition at line 69 of file nsISupportsPriority.idl.

Definition at line 57 of file nsISupportsPriority.idl.

Typical priority values.

Definition at line 56 of file nsISupportsPriority.idl.

Definition at line 59 of file nsISupportsPriority.idl.

Definition at line 60 of file nsISupportsPriority.idl.

Definition at line 58 of file nsISupportsPriority.idl.

Returns the requests contained directly in this group.

Enumerator element type: nsIRequest.

Definition at line 93 of file nsILoadGroup.idl.

readonly attribute nsresult nsIRequest::status [inherited]

The error status associated with the request.

Definition at line 77 of file nsIRequest.idl.

const unsigned long nsIRequest::VALIDATE_ALWAYS = 1 << 11 [inherited]

The following flags control the frequency of cached content validation when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set.

By default, cached content is automatically validated if necessary before reuse.

VALIDATE_ALWAYS forces validation of any cached content independent of its expiration time.

VALIDATE_NEVER disables validation of expired content.

VALIDATE_ONCE_PER_SESSION disables validation of expired content, provided it has already been validated (at least once) since the start of this session.

NOTE TO IMPLEMENTORS: These flags are intended for normal browsing, and they should therefore not apply to content that must be validated before each use. Consider, for example, a HTTP response with a "Cache-control: no-cache" header. According to RFC2616, this response must be validated before it can be taken from a cache. Breaking this requirement could result in incorrect and potentially undesirable side-effects.

Definition at line 204 of file nsIRequest.idl.

const unsigned long nsIRequest::VALIDATE_NEVER = 1 << 12 [inherited]

Definition at line 205 of file nsIRequest.idl.

const unsigned long nsIRequest::VALIDATE_ONCE_PER_SESSION = 1 << 13 [inherited]

Definition at line 206 of file nsIRequest.idl.


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