Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | Friends
imgRequestProxy Class Reference

#include <imgRequestProxy.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_IMGIREQUEST
NS_DECL_NSIREQUEST
NS_DECL_NSISUPPORTSPRIORITY 
imgRequestProxy ()
virtual ~imgRequestProxy ()
nsresult Init (imgRequest *request, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver)
nsresult ChangeOwner (imgRequest *aNewOwner)
void AddToLoadGroup ()
void RemoveFromLoadGroup (PRBool releaseLoadGroup)
imgIRequest clone (in imgIDecoderObserver aObserver)
 Clone this request; the returned request will have aObserver as the observer.
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.

Public Attributes

readonly attribute imgIContainer image
 the image container...
readonly attribute unsigned long imageStatus
 something
readonly attribute nsIURI URI
readonly attribute
imgIDecoderObserver 
decoderObserver
readonly attribute string mimeType
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.
statusflags

Bits set in the return value from imageStatus

const long STATUS_NONE = 0x0
const long STATUS_SIZE_AVAILABLE = 0x1
const long STATUS_LOAD_PARTIAL = 0x2
const long STATUS_LOAD_COMPLETE = 0x4
const long STATUS_ERROR = 0x8
const long STATUS_FRAME_COMPLETE = 0x10

Protected Member Functions

void OnStartDecode ()
 imgIDecoderObserver methods
void OnStartContainer (imgIContainer *aContainer)
void OnStartFrame (gfxIImageFrame *aFrame)
void OnDataAvailable (gfxIImageFrame *aFrame, const nsIntRect *aRect)
void OnStopFrame (gfxIImageFrame *aFrame)
void OnStopContainer (imgIContainer *aContainer)
void OnStopDecode (nsresult status, const PRUnichar *statusArg)
void FrameChanged (imgIContainer *aContainer, gfxIImageFrame *aFrame, nsIntRect *aDirtyRect)
 imgIContainerObserver methods
void OnStartRequest (nsIRequest *request, nsISupports *ctxt)
void OnStopRequest (nsIRequest *request, nsISupports *ctxt, nsresult statusCode, PRBool aLastPart)
PRBool HasObserver () const

Private Attributes

imgRequestmOwner
imgIDecoderObservermListener
nsCOMPtr< nsILoadGroupmLoadGroup
nsLoadFlags mLoadFlags
PRPackedBool mCanceled
PRPackedBool mIsInLoadGroup
PRLockmLock

Friends

class imgRequest
class imgCacheValidator

Detailed Description

Definition at line 63 of file imgRequestProxy.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_IMGIREQUEST NS_DECL_NSIREQUEST NS_DECL_NSISUPPORTSPRIORITY imgRequestProxy::imgRequestProxy ( )

Definition at line 75 of file imgRequestProxy.cpp.

{
  /* destructor code */
  NS_PRECONDITION(!mListener, "Someone forgot to properly cancel this request!");
  // Explicitly set mListener to null to ensure that the RemoveProxy
  // call below can't send |this| to an arbitrary listener while |this|
  // is being destroyed.
  mListener = nsnull;

  if (mOwner) {
    if (!mCanceled) {
      PR_Lock(mLock);

      mCanceled = PR_TRUE;

      PR_Unlock(mLock);

      /* Call RemoveProxy with a successful status.  This will keep the
         channel, if still downloading data, from being canceled if 'this' is
         the last observer.  This allows the image to continue to download and
         be cached even if no one is using it currently.
         
         Passing false to aNotify means that we will still get
         OnStopRequest, if needed.
       */
      mOwner->RemoveProxy(this, NS_OK, PR_FALSE);
    }

    NS_RELEASE(mOwner);
  }

  PR_DestroyLock(mLock);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 157 of file imgRequestProxy.cpp.

{
  NS_ASSERTION(!mIsInLoadGroup, "Whaa, we're already in the loadgroup!");

  if (!mIsInLoadGroup && mLoadGroup) {
    mLoadGroup->AddRequest(this, nsnull);
    mIsInLoadGroup = PR_TRUE;
  }
}

Here is the caller graph for this function:

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.

Definition at line 135 of file imgRequestProxy.cpp.

{
  if (mCanceled)
    return NS_OK;

  PR_Lock(mLock);

  // Passing false to aNotify means that mListener will still get
  // OnStopRequest, if needed.
  mOwner->RemoveProxy(this, NS_IMAGELIB_CHANGING_OWNER, PR_FALSE);
  NS_RELEASE(mOwner);

  mOwner = aNewOwner;
  NS_ADDREF(mOwner);

  mOwner->AddProxy(this, PR_FALSE);

  PR_Unlock(mLock);

  return NS_OK;
}

Here is the call graph for this function:

Clone this request; the returned request will have aObserver as the observer.

aObserver will be notified synchronously (before the clone() call returns) with all the notifications that have already been dispatched for this image load.

void imgRequestProxy::FrameChanged ( imgIContainer aContainer,
gfxIImageFrame aFrame,
nsIntRect aDirtyRect 
) [protected]

imgIContainerObserver methods

Definition at line 396 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::FrameChanged");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->FrameChanged(container, newframe, dirtyRect);
  }
}
PRBool imgRequestProxy::HasObserver ( ) const [inline, protected]

Definition at line 103 of file imgRequestProxy.h.

                                    {
    return mListener != nsnull;
  }

Here is the caller graph for this function:

nsresult imgRequestProxy::Init ( imgRequest request,
nsILoadGroup aLoadGroup,
imgIDecoderObserver aObserver 
)

Definition at line 111 of file imgRequestProxy.cpp.

{
  NS_PRECONDITION(request, "no request");
  if (!request)
    return NS_ERROR_NULL_POINTER;

  LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequestProxy::Init", "request", request);

  PR_Lock(mLock);

  mOwner = request;
  NS_ADDREF(mOwner);

  mListener = aObserver;

  mLoadGroup = aLoadGroup;

  PR_Unlock(mLock);

  request->AddProxy(this, PR_FALSE); // Pass PR_FALSE here so that AddProxy doesn't send all the On* notifications immediatly

  return NS_OK;
}

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.
void imgRequestProxy::OnDataAvailable ( gfxIImageFrame aFrame,
const nsIntRect aRect 
) [protected]

Definition at line 442 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnDataAvailable");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnDataAvailable(this, frame, rect);
  }
}

Here is the caller graph for this function:

void imgRequestProxy::OnStartContainer ( imgIContainer aContainer) [protected]

Definition at line 420 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnStartContainer");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnStartContainer(this, image);
  }
}

Here is the caller graph for this function:

imgIDecoderObserver methods

Definition at line 409 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnStartDecode");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnStartDecode(this);
  }
}

Here is the caller graph for this function:

Definition at line 431 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnStartFrame");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnStartFrame(this, frame);
  }
}

Here is the caller graph for this function:

void imgRequestProxy::OnStartRequest ( nsIRequest request,
nsISupports *  ctxt 
) [protected]

Definition at line 488 of file imgRequestProxy.cpp.

{
#ifdef PR_LOGGING
  nsCAutoString name;
  GetName(name);
  LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnStartRequest", "name", name.get());
#endif

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver_MOZILLA_1_8_BRANCH> listener = do_QueryInterface(mListener);
    if (listener)
      listener->OnStartRequest(this);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void imgRequestProxy::OnStopContainer ( imgIContainer aContainer) [protected]

Definition at line 464 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnStopContainer");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnStopContainer(this, image);
  }
}

Here is the caller graph for this function:

void imgRequestProxy::OnStopDecode ( nsresult  status,
const PRUnichar statusArg 
) [protected]

Definition at line 475 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnStopDecode");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnStopDecode(this, status, statusArg);
  }
}

Here is the caller graph for this function:

Definition at line 453 of file imgRequestProxy.cpp.

{
  LOG_FUNC(gImgLog, "imgRequestProxy::OnStopFrame");

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
    mListener->OnStopFrame(this, frame);
  }
}

Here is the caller graph for this function:

void imgRequestProxy::OnStopRequest ( nsIRequest request,
nsISupports *  ctxt,
nsresult  statusCode,
PRBool  aLastPart 
) [protected]

Definition at line 504 of file imgRequestProxy.cpp.

{
#ifdef PR_LOGGING
  nsCAutoString name;
  GetName(name);
  LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnStopRequest", "name", name.get());
#endif

  if (mListener) {
    // Hold a ref to the listener while we call it, just in case.
    nsCOMPtr<imgIDecoderObserver_MOZILLA_1_8_BRANCH> listener = do_QueryInterface(mListener);
    if (listener)
      listener->OnStopRequest(this, lastPart);
  }

  // If we're expecting more data from a multipart channel, re-add ourself
  // to the loadgroup so that the document doesn't lose track of the load.
  // If the request is already a background request and there's more data
  // coming, we can just leave the request in the loadgroup as-is.
  if (lastPart || (mLoadFlags & nsIRequest::LOAD_BACKGROUND) == 0) {
    RemoveFromLoadGroup(lastPart);
    // More data is coming, so change the request to be a background request
    // and put it back in the loadgroup.
    if (!lastPart) {
      mLoadFlags |= nsIRequest::LOAD_BACKGROUND;
      AddToLoadGroup();
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 167 of file imgRequestProxy.cpp.

{
  if (!mIsInLoadGroup)
    return;

  /* calling RemoveFromLoadGroup may cause the document to finish
     loading, which could result in our death.  We need to make sure
     that we stay alive long enough to fight another battle... at
     least until we exit this function.
  */
  nsCOMPtr<imgIRequest> kungFuDeathGrip(this);

  mLoadGroup->RemoveRequest(this, NS_OK, nsnull);
  mIsInLoadGroup = PR_FALSE;

  if (releaseLoadGroup) {
    // We're done with the loadgroup, release it.
    mLoadGroup = nsnull;
  }
}

Here is the caller graph for this function:

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.


Friends And Related Function Documentation

friend class imgCacheValidator [friend]

Definition at line 108 of file imgRequestProxy.h.

friend class imgRequest [friend]

Definition at line 85 of file imgRequestProxy.h.


Member Data Documentation

Definition at line 85 of file imgIRequest.idl.

the image container...

Returns:
the image object associated with the request.
Attention:
NEED DOCS

Definition at line 62 of file imgIRequest.idl.

readonly attribute unsigned long imgIRequest::imageStatus [inherited]

something

Attention:
NEED DOCS

Definition at line 81 of file imgIRequest.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 116 of file imgRequestProxy.h.

readonly attribute string imgIRequest::mimeType [inherited]

Definition at line 87 of file imgIRequest.idl.

Definition at line 117 of file imgRequestProxy.h.

Definition at line 112 of file imgRequestProxy.h.

Definition at line 115 of file imgRequestProxy.h.

Definition at line 113 of file imgRequestProxy.h.

Definition at line 119 of file imgRequestProxy.h.

Definition at line 110 of file imgRequestProxy.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.

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.

readonly attribute nsresult nsIRequest::status [inherited]

The error status associated with the request.

Definition at line 77 of file nsIRequest.idl.

Definition at line 73 of file imgIRequest.idl.

Definition at line 74 of file imgIRequest.idl.

Definition at line 72 of file imgIRequest.idl.

Definition at line 71 of file imgIRequest.idl.

const long imgIRequest::STATUS_NONE = 0x0 [inherited]

Definition at line 69 of file imgIRequest.idl.

Definition at line 70 of file imgIRequest.idl.

readonly attribute nsIURI imgIRequest::URI [inherited]

Definition at line 83 of file imgIRequest.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: