Back to index

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

#include <nsDocLoader.h>

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

List of all members.

Public Member Functions

 NS_DEFINE_STATIC_IID_ACCESSOR (NS_THIS_DOCLOADER_IMPL_CID)
 nsDocLoader ()
virtual nsresult Init ()
NS_DECL_ISUPPORTS
NS_DECL_NSIDOCUMENTLOADER
NS_DECL_NSIPROGRESSEVENTSINK
NS_DECL_NSISECURITYEVENTSINK
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIWEBPROGRESS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSISUPPORTSPRIORITY
nsresult 
RemoveChildLoader (nsDocLoader *aChild)
nsresult AddChildLoader (nsDocLoader *aChild)
nsDocLoaderGetParent () const
void stop ()
void onStartRequest (in nsIRequest aRequest, in nsISupports aContext)
 Called to signify the beginning of an asynchronous request.
void onStopRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatusCode)
 Called to signify the end of an asynchronous request.
void onProgress (in nsIRequest aRequest, in nsISupports aContext, in unsigned long long aProgress, in unsigned long long aProgressMax)
 Called to notify the event sink that progress has occurred for the given request.
void onStatus (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatus, in wstring aStatusArg)
 Called to notify the event sink with a status message for the given request.
void addProgressListener (in nsIWebProgressListener aListener, in unsigned long aNotifyMask)
 Registers a listener to receive web progress events.
void removeProgressListener (in nsIWebProgressListener aListener)
 Removes a previously registered listener of progress events.
void getInterface (in nsIIDRef uuid,[iid_is(uuid), retval] out nsQIResult result)
 Retrieves the specified interface pointer.
void onChannelRedirect (in nsIChannel oldChannel, in nsIChannel newChannel, in unsigned long flags)
 Called when a redirect occurs.
void onSecurityChange (in nsISupports i_Context, in unsigned long state)
 Fired when a security change occurs due to page transitions, or end document load.
void adjustPriority (in long delta)
 This method adjusts the priority attribute by a given delta.

Static Public Member Functions

static already_AddRefed
< nsDocLoader
GetAsDocLoader (nsISupports *aSupports)
static nsISupports * GetAsSupports (nsDocLoader *aDocLoader)
static nsresult AddDocLoaderAsChildOfRoot (nsDocLoader *aDocLoader)

Public Attributes

readonly attribute nsISupports container
readonly attribute nsILoadGroup loadGroup
readonly attribute nsIChannel documentChannel
const unsigned long NOTIFY_STATE_REQUEST = 0x00000001
 The following flags may be combined to form the aNotifyMask parameter for the addProgressListener method.
const unsigned long NOTIFY_STATE_DOCUMENT = 0x00000002
const unsigned long NOTIFY_STATE_NETWORK = 0x00000004
const unsigned long NOTIFY_STATE_WINDOW = 0x00000008
const unsigned long NOTIFY_STATE_ALL = 0x0000000f
const unsigned long NOTIFY_PROGRESS = 0x00000010
 These flags indicate the other events to observe, corresponding to the other four methods defined on nsIWebProgressListener.
const unsigned long NOTIFY_STATUS = 0x00000020
const unsigned long NOTIFY_SECURITY = 0x00000040
const unsigned long NOTIFY_LOCATION = 0x00000080
const unsigned long NOTIFY_ALL = 0x000000ff
 This flag enables all notifications.
readonly attribute nsIDOMWindow DOMWindow
 The DOM window associated with this nsIWebProgress instance.
readonly attribute PRBool isLoadingDocument
 Indicates whether or not a document is currently being loaded in the context of this nsIWebProgress instance.
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.
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 ~nsDocLoader ()
virtual nsresult SetDocLoaderParent (nsDocLoader *aLoader)
void DocLoaderIsEmpty ()
PRBool IsBusy ()
void Destroy ()
virtual void DestroyChildren ()
nsIDocumentLoaderChildAt (PRInt32 i)
nsIDocumentLoaderSafeChildAt (PRInt32 i)
void FireOnProgressChange (nsDocLoader *aLoadInitiator, nsIRequest *request, PRInt64 aProgress, PRInt64 aProgressMax, PRInt64 aProgressDelta, PRInt64 aTotalProgress, PRInt64 aMaxTotalProgress)
void FireOnStateChange (nsIWebProgress *aProgress, nsIRequest *request, PRInt32 aStateFlags, nsresult aStatus)
void FireOnStatusChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
void FireOnLocationChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *aUri)
virtual void OnRedirectStateChange (nsIChannel *aOldChannel, nsIChannel *aNewChannel, PRUint32 aRedirectFlags, PRUint32 aStateFlags)
void doStartDocumentLoad ()
void doStartURLLoad (nsIRequest *request)
void doStopURLLoad (nsIRequest *request, nsresult aStatus)
void doStopDocumentLoad (nsIRequest *request, nsresult aStatus)

Protected Attributes

nsCOMPtr< nsIRequestmDocumentRequest
nsDocLoadermParent
nsVoidArray mListenerInfoList
PRBool mIsLoadingDocument
nsCOMPtr< nsILoadGroupmLoadGroup
nsVoidArray mChildList
PRInt32 mProgressStateFlags
nsInt64 mCurrentSelfProgress
nsInt64 mMaxSelfProgress
nsInt64 mCurrentTotalProgress
nsInt64 mMaxTotalProgress
PLDHashTable mRequestInfoHash
PRBool mIsRestoringDocument

Private Member Functions

nsListenerInfoGetListenerInfo (nsIWebProgressListener *aListener)
PRInt64 GetMaxTotalProgress ()
nsresult AddRequestInfo (nsIRequest *aRequest)
nsRequestInfoGetRequestInfo (nsIRequest *aRequest)
void ClearRequestInfoHash ()
PRInt64 CalculateMaxProgress ()
void ClearInternalProgress ()
 void DumpChannelInfo(void);

Detailed Description

Definition at line 79 of file nsDocLoader.h.


Constructor & Destructor Documentation

Definition at line 133 of file nsDocLoader.cpp.

  : mListenerInfoList(8)
{
#if defined(PR_LOGGING)
  if (nsnull == gDocLoaderLog) {
      gDocLoaderLog = PR_NewLogModule("DocLoader");
  }
#endif /* PR_LOGGING */

  mParent    = nsnull;

  mIsLoadingDocument = PR_FALSE;
  mIsRestoringDocument = PR_FALSE;

  static PLDHashTableOps hash_table_ops =
  {
    PL_DHashAllocTable,
    PL_DHashFreeTable,
    PL_DHashGetKeyStub,
    PL_DHashVoidPtrKeyStub,
    PL_DHashMatchEntryStub,
    PL_DHashMoveEntryStub,
    PL_DHashClearEntryStub,
    PL_DHashFinalizeStub,
    RequestInfoHashInitEntry
  };

  if (!PL_DHashTableInit(&mRequestInfoHash, &hash_table_ops, nsnull,
                         sizeof(nsRequestInfo), 16)) {
    mRequestInfoHash.ops = nsnull;
  }

  ClearInternalProgress();

  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: created.\n", this));
}

Here is the call graph for this function:

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

Definition at line 194 of file nsDocLoader.cpp.

{
              /*
                     |ClearWeakReferences()| here is intended to prevent people holding weak references
                     from re-entering this destructor since |QueryReferent()| will |AddRef()| me, and the
                     subsequent |Release()| will try to destroy me.  At this point there should be only
                     weak references remaining (otherwise, we wouldn't be getting destroyed).

                     An alternative would be incrementing our refcount (consider it a compressed flag
                     saying "Don't re-destroy.").  I haven't yet decided which is better. [scc]
              */
  // XXXbz now that NS_IMPL_RELEASE stabilizes by setting refcount to 1, is
  // this needed?
  ClearWeakReferences();

  Destroy();

  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
         ("DocLoader:%p: deleted.\n", this));

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

Here is the call graph for this function:


Member Function Documentation

Definition at line 682 of file nsDocLoader.cpp.

{
  nsresult rv = mChildList.AppendElement(aChild) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
  if (NS_SUCCEEDED(rv)) {
    aChild->SetDocLoaderParent(this);
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 278 of file nsDocLoader.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIDocumentLoader> docLoaderService =
    do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsRefPtr<nsDocLoader> rootDocLoader = GetAsDocLoader(docLoaderService);
  NS_ENSURE_TRUE(rootDocLoader, NS_ERROR_UNEXPECTED);

  return rootDocLoader->AddChildLoader(aDocLoader);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIWebProgress::addProgressListener ( in nsIWebProgressListener  aListener,
in unsigned long  aNotifyMask 
) [inherited]

Registers a listener to receive web progress events.

Parameters:
aListenerThe listener interface to be called when a progress event occurs. This object must also implement nsISupportsWeakReference.
aNotifyMaskThe types of notifications to receive.
Exceptions:
NS_ERROR_INVALID_ARGIndicates that aListener was either null or that it does not support weak references.
NS_ERROR_FAILUREIndicates that aListener was already registered.
nsresult nsDocLoader::AddRequestInfo ( nsIRequest aRequest) [private]

Definition at line 1326 of file nsDocLoader.cpp.

Here is the call 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.

Definition at line 1392 of file nsDocLoader.cpp.

Here is the call graph for this function:

nsIDocumentLoader* nsDocLoader::ChildAt ( PRInt32  i) [inline, protected]

Definition at line 146 of file nsDocLoader.h.

Here is the caller graph for this function:

void DumpChannelInfo(void);

Definition at line 1073 of file nsDocLoader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1362 of file nsDocLoader.cpp.

{
  if (!mRequestInfoHash.ops || !mRequestInfoHash.entryCount) {
    // No hash, or the hash is empty, nothing to do here then...

    return;
  }

  PL_DHashTableEnumerate(&mRequestInfoHash, RemoveInfoCallback, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::Destroy ( void  ) [protected]

Definition at line 391 of file nsDocLoader.cpp.

{
  Stop();

  // Remove the document loader from the parent list of loaders...
  if (mParent) 
  {
    mParent->RemoveChildLoader(this);
  }

  // Release all the information about network requests...
  ClearRequestInfoHash();

  // Release all the information about registered listeners...
  PRInt32 count = mListenerInfoList.Count();
  for(PRInt32 i = 0; i < count; i++) {
    nsListenerInfo *info =
      NS_STATIC_CAST(nsListenerInfo*, mListenerInfoList.ElementAt(i));

    delete info;
  }

  mListenerInfoList.Clear();
  mListenerInfoList.Compact();

  mDocumentRequest = 0;

  if (mLoadGroup)
    mLoadGroup->SetGroupObserver(nsnull);

  DestroyChildren();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::DestroyChildren ( ) [protected, virtual]

Reimplemented in nsDocShell.

Definition at line 425 of file nsDocLoader.cpp.

{
  PRInt32 i, count;
  
  count = mChildList.Count();
  // if the doc loader still has children...we need to enumerate the
  // children and make them null out their back ptr to the parent doc
  // loader
  for (i=0; i < count; i++)
  {
    nsIDocumentLoader* loader = ChildAt(i);

    if (loader) {
      // This is a safe cast, as we only put nsDocLoader objects into the
      // array
      NS_STATIC_CAST(nsDocLoader*, loader)->SetDocLoaderParent(nsnull);
    }
  }
  mChildList.Clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 702 of file nsDocLoader.cpp.

{
  if (mIsLoadingDocument) {
    /* In the unimagineably rude circumstance that onload event handlers
       triggered by this function actually kill the window ... ok, it's
       not unimagineable; it's happened ... this deathgrip keeps this object
       alive long enough to survive this function call. */
    nsCOMPtr<nsIDocumentLoader> kungFuDeathGrip(this);

    if (!IsBusy()) {
      PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
             ("DocLoader:%p: Is now idle...\n", this));

      nsCOMPtr<nsIRequest> docRequest = mDocumentRequest;

      NS_ASSERTION(mDocumentRequest, "No Document Request!");
      mDocumentRequest = 0;
      mIsLoadingDocument = PR_FALSE;

      // Update the progress status state - the document is done
      mProgressStateFlags = nsIWebProgressListener::STATE_STOP;


      nsresult loadGroupStatus = NS_OK; 
      mLoadGroup->GetStatus(&loadGroupStatus);

      // 
      // New code to break the circular reference between 
      // the load group and the docloader... 
      // 
      mLoadGroup->SetDefaultLoadRequest(nsnull); 

      //
      // Do nothing after firing the OnEndDocumentLoad(...). The document
      // loader may be loading a *new* document - if LoadDocument()
      // was called from a handler!
      //
      doStopDocumentLoad(docRequest, loadGroupStatus);

      if (mParent) {
        mParent->DocLoaderIsEmpty();
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 748 of file nsDocLoader.cpp.

{

#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(mDocumentRequest, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: ++ Firing OnStateChange for start document load (...)."
          "\tURI: %s \n",
          this, buffer.get()));
#endif /* DEBUG */

  // Fire an OnStatus(...) notification STATE_START.  This indicates
  // that the document represented by mDocumentRequest has started to
  // load...
  FireOnStateChange(this,
                    mDocumentRequest,
                    nsIWebProgressListener::STATE_START |
                    nsIWebProgressListener::STATE_IS_DOCUMENT |
                    nsIWebProgressListener::STATE_IS_REQUEST |
                    nsIWebProgressListener::STATE_IS_WINDOW |
                    nsIWebProgressListener::STATE_IS_NETWORK,
                    NS_OK);
}

Here is the call graph for this function:

void nsDocLoader::doStartURLLoad ( nsIRequest request) [protected]

Definition at line 774 of file nsDocLoader.cpp.

{
#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
    PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
          ("DocLoader:%p: ++ Firing OnStateChange start url load (...)."
           "\tURI: %s\n",
            this, buffer.get()));
#endif /* DEBUG */

  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_START |
                    nsIWebProgressListener::STATE_IS_REQUEST,
                    NS_OK);
}

Here is the call graph for this function:

void nsDocLoader::doStopDocumentLoad ( nsIRequest request,
nsresult  aStatus 
) [protected]

Definition at line 812 of file nsDocLoader.cpp.

{
#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: ++ Firing OnStateChange for end document load (...)."
         "\tURI: %s Status=%x\n",
          this, buffer.get(), aStatus));
#endif /* DEBUG */

  //
  // Fire an OnStateChange(...) notification indicating the the
  // current document has finished loading...
  //
  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_STOP |
                    nsIWebProgressListener::STATE_IS_DOCUMENT,
                    aStatus);

  //
  // Fire a final OnStateChange(...) notification indicating the the
  // current document has finished loading...
  //
  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_STOP |
                    nsIWebProgressListener::STATE_IS_WINDOW |
                    nsIWebProgressListener::STATE_IS_NETWORK,
                    aStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::doStopURLLoad ( nsIRequest request,
nsresult  aStatus 
) [protected]

Definition at line 793 of file nsDocLoader.cpp.

{
#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
    PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
          ("DocLoader:%p: ++ Firing OnStateChange for end url load (...)."
           "\tURI: %s status=%x\n",
            this, buffer.get(), aStatus));
#endif /* DEBUG */

  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_STOP |
                    nsIWebProgressListener::STATE_IS_REQUEST,
                    aStatus);
}

Here is the call graph for this function:

void nsDocLoader::FireOnLocationChange ( nsIWebProgress aWebProgress,
nsIRequest aRequest,
nsIURI aUri 
) [protected]

Definition at line 1224 of file nsDocLoader.cpp.

{
  /*                                                                           
   * First notify any listeners of the new state info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & nsIWebProgress::NOTIFY_LOCATION)) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    listener->OnLocationChange(aWebProgress, aRequest, aUri);
  }

  mListenerInfoList.Compact();

  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnLocationChange(aWebProgress, aRequest, aUri);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::FireOnProgressChange ( nsDocLoader aLoadInitiator,
nsIRequest request,
PRInt64  aProgress,
PRInt64  aProgressMax,
PRInt64  aProgressDelta,
PRInt64  aTotalProgress,
PRInt64  aMaxTotalProgress 
) [protected]

Definition at line 1084 of file nsDocLoader.cpp.

{
  if (mIsLoadingDocument) {
    mCurrentTotalProgress += aProgressDelta;
    mMaxTotalProgress = GetMaxTotalProgress();

    aTotalProgress    = mCurrentTotalProgress;
    aMaxTotalProgress = mMaxTotalProgress;
  }

#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: Progress (%s): curSelf: %d maxSelf: %d curTotal: %d maxTotal %d\n",
          this, buffer.get(), aProgress, aProgressMax, aTotalProgress, aMaxTotalProgress));
#endif /* DEBUG */

  /*
   * First notify any listeners of the new progress info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & nsIWebProgress::NOTIFY_PROGRESS)) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    // XXX truncates 64-bit to 32-bit
    listener->OnProgressChange(aLoadInitiator,request,
                               PRInt32(aProgress), PRInt32(aProgressMax),
                               PRInt32(aTotalProgress), PRInt32(aMaxTotalProgress));
  }

  mListenerInfoList.Compact();

  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnProgressChange(aLoadInitiator, request,
                                  aProgress, aProgressMax,
                                  aProgressDelta,
                                  aTotalProgress, aMaxTotalProgress);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::FireOnStateChange ( nsIWebProgress aProgress,
nsIRequest request,
PRInt32  aStateFlags,
nsresult  aStatus 
) [protected]

Definition at line 1152 of file nsDocLoader.cpp.

{
  //
  // Remove the STATE_IS_NETWORK bit if necessary.
  //
  // The rule is to remove this bit, if the notification has been passed
  // up from a child WebProgress, and the current WebProgress is already
  // active...
  //
  if (mIsLoadingDocument &&
      (aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) && 
      (this != aProgress)) {
    aStateFlags &= ~nsIWebProgressListener::STATE_IS_NETWORK;
  }

  // Add the STATE_RESTORING bit if necessary.
  if (mIsRestoringDocument)
    aStateFlags |= nsIWebProgressListener::STATE_RESTORING;

#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(aRequest, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: Status (%s): code: %x\n",
         this, buffer.get(), aStateFlags));
#endif /* DEBUG */

  NS_ASSERTION(aRequest, "Firing OnStateChange(...) notification with a NULL request!");

  /*                                                                           
   * First notify any listeners of the new state info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & (aStateFlags >>16))) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    listener->OnStateChange(aProgress, aRequest, aStateFlags, aStatus);
  }

  mListenerInfoList.Compact();

  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnStateChange(aProgress, aRequest, aStateFlags, aStatus);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::FireOnStatusChange ( nsIWebProgress aWebProgress,
nsIRequest aRequest,
nsresult  aStatus,
const PRUnichar aMessage 
) [protected]

Definition at line 1265 of file nsDocLoader.cpp.

{
  /*                                                                           
   * First notify any listeners of the new state info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & nsIWebProgress::NOTIFY_STATUS)) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
  }
  mListenerInfoList.Compact();
  
  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

already_AddRefed< nsDocLoader > nsDocLoader::GetAsDocLoader ( nsISupports *  aSupports) [static]

Definition at line 265 of file nsDocLoader.cpp.

{
  if (!aSupports) {
    return nsnull;
  }
  
  nsDocLoader* ptr;
  CallQueryInterface(aSupports, &ptr);
  return ptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsISupports* nsDocLoader::GetAsSupports ( nsDocLoader aDocLoader) [inline, static]

Definition at line 98 of file nsDocLoader.h.

                                                               {
        return NS_STATIC_CAST(nsIDocumentLoader*, aDocLoader);
    }

Here is the caller graph for this function:

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.

Definition at line 1306 of file nsDocLoader.cpp.

{
  PRInt32 i, count;
  nsListenerInfo *info;

  nsCOMPtr<nsISupports> listener1 = do_QueryInterface(aListener);
  count = mListenerInfoList.Count();
  for (i=0; i<count; i++) {
    info = NS_STATIC_CAST(nsListenerInfo* ,mListenerInfoList.SafeElementAt(i));

    NS_ASSERTION(info, "There should NEVER be a null listener in the list");
    if (info) {
      nsCOMPtr<nsISupports> listener2 = do_QueryReferent(info->mWeakListener);
      if (listener1 == listener2)
        return info;
    }
  }
  return nsnull;
}

Here is the call graph for this function:

Definition at line 907 of file nsDocLoader.cpp.

{
  nsInt64 newMaxTotal = 0;

  PRInt32 count = mChildList.Count();
  nsCOMPtr<nsIWebProgress> webProgress;
  for (PRInt32 i=0; i < count; i++) 
  {
    nsInt64 individualProgress = 0;
    nsIDocumentLoader* docloader = ChildAt(i);
    if (docloader)
    {
      // Cast is safe since all children are nsDocLoader too
      individualProgress = ((nsDocLoader *) docloader)->GetMaxTotalProgress();
    }
    if (individualProgress < nsInt64(0)) // if one of the elements doesn't know it's size
                                         // then none of them do
    {
       newMaxTotal = nsInt64(-1);
       break;
    }
    else
     newMaxTotal += individualProgress;
  }

  nsInt64 progress = -1;
  if (mMaxSelfProgress >= nsInt64(0) && newMaxTotal >= nsInt64(0))
    progress = newMaxTotal + mMaxSelfProgress;
  
  return progress;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsDocLoader* nsDocLoader::GetParent ( ) const [inline]

Definition at line 129 of file nsDocLoader.h.

{ return mParent; }

Definition at line 1335 of file nsDocLoader.cpp.

{
  nsRequestInfo *info =
    NS_STATIC_CAST(nsRequestInfo *,
                   PL_DHashTableOperate(&mRequestInfoHash, aRequest,
                                        PL_DHASH_LOOKUP));

  if (PL_DHASH_ENTRY_IS_FREE(info)) {
    // Nothing found in the hash, return null.

    return nsnull;
  }

  // Return what we found in the hash...

  return info;
}

Here is the call graph for this function:

nsresult nsDocLoader::Init ( void  ) [virtual]

Reimplemented in nsDocShell.

Definition at line 179 of file nsDocLoader.cpp.

{
  if (!mRequestInfoHash.ops) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  nsresult rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), this);
  if (NS_FAILED(rv)) return rv;

  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: load group %x.\n", this, mLoadGroup.get()));

  return NS_OK;
}

Here is the call graph for this function:

PRBool nsDocLoader::IsBusy ( ) [protected]

Definition at line 330 of file nsDocLoader.cpp.

{
  nsresult rv;

  //
  // A document loader is busy if either:
  //
  //   1. It is currently loading a document (ie. one or more URIs)
  //   2. One of it's child document loaders is busy...
  //

  /* Is this document loader busy? */
  if (mIsLoadingDocument) {
    PRBool busy;
    rv = mLoadGroup->IsPending(&busy);
    if (NS_FAILED(rv))
      return PR_FALSE;
    if (busy)
      return PR_TRUE;
  }

  /* Otherwise, check its child document loaders... */
  PRInt32 count, i;

  count = mChildList.Count();

  for (i=0; i < count; i++) {
    nsIDocumentLoader* loader = ChildAt(i);

    // This is a safe cast, because we only put nsDocLoader objects into the
    // array
    if (loader && NS_STATIC_CAST(nsDocLoader*, loader)->IsBusy())
        return PR_TRUE;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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.
void nsIProgressEventSink::onProgress ( in nsIRequest  aRequest,
in nsISupports  aContext,
in unsigned long long  aProgress,
in unsigned long long  aProgressMax 
) [inherited]

Called to notify the event sink that progress has occurred for the given request.

Parameters:
aRequestthe request being observed (may QI to nsIChannel).
aContextif aRequest is a channel, then this parameter is the listener context passed to nsIChannel::asyncOpen.
aProgressnumeric value in the range 0 to aProgressMax indicating the number of bytes transfered thus far.
aProgressMaxnumeric value indicating maximum number of bytes that will be transfered (or 0xFFFFFFFFFFFFFFFF if total is unknown).
virtual void nsDocLoader::OnRedirectStateChange ( nsIChannel aOldChannel,
nsIChannel aNewChannel,
PRUint32  aRedirectFlags,
PRUint32  aStateFlags 
) [inline, protected, virtual]

Reimplemented in nsDocShell.

Definition at line 182 of file nsDocLoader.h.

                                                             {}
void nsISecurityEventSink::onSecurityChange ( in nsISupports  i_Context,
in unsigned long  state 
) [inherited]

Fired when a security change occurs due to page transitions, or end document load.

This interface should be called by a security package (eg Netscape Personal Security Manager) to notify nsIWebProgressListeners that security state has changed. State flags are in nsIWebProgressListener.idl

void nsIRequestObserver::onStartRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Called to signify the beginning of an asynchronous request.

Parameters:
aRequestrequest being observed
aContextuser defined context

An exception thrown from onStartRequest has the side-effect of causing the request to be canceled.

Here is the caller graph for this function:

void nsIProgressEventSink::onStatus ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatus,
in wstring  aStatusArg 
) [inherited]

Called to notify the event sink with a status message for the given request.

Parameters:
aRequestthe request being observed (may QI to nsIChannel).
aContextif aRequest is a channel, then this parameter is the listener context passed to nsIChannel::asyncOpen.
aStatusstatus code (not necessarily an error code) indicating the state of the channel (usually the state of the underlying transport). see nsISocketTransport for socket specific status codes.
aStatusArgstatus code argument to be used with the string bundle service to convert the status message into localized, human readable text. the meaning of this parameter is specific to the value of the status code. for socket status codes, this parameter indicates the host:port associated with the status code.
void nsIRequestObserver::onStopRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatusCode 
) [inherited]

Called to signify the end of an asynchronous request.

This call is always preceded by a call to onStartRequest.

Parameters:
aRequestrequest being observed
aContextuser defined context
aStatusCodereason for stopping (NS_OK if completed successfully)

An exception thrown from onStopRequest is generally ignored.

Here is the caller graph for this function:

Definition at line 673 of file nsDocLoader.cpp.

{
  nsresult rv = mChildList.RemoveElement(aChild) ? NS_OK : NS_ERROR_FAILURE;
  if (NS_SUCCEEDED(rv)) {
    aChild->SetDocLoaderParent(nsnull);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Removes a previously registered listener of progress events.

Parameters:
aListenerThe listener interface previously registered with a call to addProgressListener.
Exceptions:
NS_ERROR_FAILUREIndicates that aListener was not registered.
nsIDocumentLoader* nsDocLoader::SafeChildAt ( PRInt32  i) [inline, protected]

Definition at line 150 of file nsDocLoader.h.

                                              {
        return NS_STATIC_CAST(nsDocLoader*, mChildList.SafeElementAt(i));
    }
nsresult nsDocLoader::SetDocLoaderParent ( nsDocLoader aLoader) [protected, virtual]

Reimplemented in nsDocShell.

Definition at line 172 of file nsDocLoader.cpp.

{
  mParent = aParent;
  return NS_OK; 
}

Here is the caller graph for this function:

void nsIDocumentLoader::stop ( ) [inherited]

Member Data Documentation

readonly attribute nsISupports nsIDocumentLoader::container [inherited]

Definition at line 60 of file nsIDocumentLoader.idl.

Definition at line 66 of file nsIDocumentLoader.idl.

The DOM window associated with this nsIWebProgress instance.

Exceptions:
NS_ERROR_FAILUREIndicates that there is no associated DOM window.

Definition at line 165 of file nsIWebProgress.idl.

Indicates whether or not a document is currently being loaded in the context of this nsIWebProgress instance.

Definition at line 171 of file nsIWebProgress.idl.

Definition at line 63 of file nsIDocumentLoader.idl.

Definition at line 213 of file nsDocLoader.h.

Definition at line 219 of file nsDocLoader.h.

Definition at line 222 of file nsDocLoader.h.

Definition at line 199 of file nsDocLoader.h.

Definition at line 209 of file nsDocLoader.h.

Definition at line 228 of file nsDocLoader.h.

Definition at line 203 of file nsDocLoader.h.

Definition at line 211 of file nsDocLoader.h.

Definition at line 220 of file nsDocLoader.h.

Definition at line 223 of file nsDocLoader.h.

Definition at line 201 of file nsDocLoader.h.

Definition at line 217 of file nsDocLoader.h.

Definition at line 225 of file nsDocLoader.h.

const unsigned long nsIWebProgress::NOTIFY_ALL = 0x000000ff [inherited]

This flag enables all notifications.

Definition at line 127 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_LOCATION = 0x00000080 [inherited]

Definition at line 122 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_PROGRESS = 0x00000010 [inherited]

These flags indicate the other events to observe, corresponding to the other four methods defined on nsIWebProgressListener.

NOTIFY_PROGRESS Receive onProgressChange events.

NOTIFY_STATUS Receive onStatusChange events.

NOTIFY_SECURITY Receive onSecurityChange events.

NOTIFY_LOCATION Receive onLocationChange events.

Definition at line 119 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_SECURITY = 0x00000040 [inherited]

Definition at line 121 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_STATE_ALL = 0x0000000f [inherited]

Definition at line 101 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_STATE_DOCUMENT = 0x00000002 [inherited]

Definition at line 98 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_STATE_NETWORK = 0x00000004 [inherited]

Definition at line 99 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_STATE_REQUEST = 0x00000001 [inherited]

The following flags may be combined to form the aNotifyMask parameter for the addProgressListener method.

They limit the set of events that are delivered to an nsIWebProgressListener instance. These flags indicate the state transistions to observe, corresponding to nsIWebProgressListener::onStateChange.

NOTIFY_STATE_REQUEST Only receive the onStateChange event if the aStateFlags parameter includes nsIWebProgressListener::STATE_IS_REQUEST.

NOTIFY_STATE_DOCUMENT Only receive the onStateChange event if the aStateFlags parameter includes nsIWebProgressListener::STATE_IS_DOCUMENT.

NOTIFY_STATE_NETWORK Only receive the onStateChange event if the aStateFlags parameter includes nsIWebProgressListener::STATE_IS_NETWORK.

NOTIFY_STATE_WINDOW Only receive the onStateChange event if the aStateFlags parameter includes nsIWebProgressListener::STATE_IS_WINDOW.

NOTIFY_STATE_ALL Receive all onStateChange events.

Definition at line 97 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_STATE_WINDOW = 0x00000008 [inherited]

Definition at line 100 of file nsIWebProgress.idl.

const unsigned long nsIWebProgress::NOTIFY_STATUS = 0x00000020 [inherited]

Definition at line 120 of file nsIWebProgress.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.

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 files: