Back to index

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

#include <nsSHistory.h>

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

List of all members.

Public Member Functions

 nsSHistory ()
void goBack ()
 Tells the object to navigate to the previous session history item.
void goForward ()
 Tells the object to navigate to the next session history item.
void gotoIndex (in long index)
 Tells the object to navigate to the session history item at a given index.
void loadURI (in wstring aURI, in unsigned long aLoadFlags, in nsIURI aReferrer, in nsIInputStream aPostData, in nsIInputStream aHeaders)
 Loads a given URI.
void reload (in unsigned long aReloadFlags)
 Tells the Object to reload the current page.
void stop (in unsigned long aStopFlags)
 Stops a load of a URI.

Static Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISHISTORY
NS_DECL_NSISHISTORYINTERNAL
static
NS_DECL_NSIWEBNAVIGATION
nsresult 
Startup ()
static PRUint32 GetMaxTotalViewers ()

Public Attributes

readonly attribute boolean canGoBack
 Indicates if the object can go back.
readonly attribute boolean canGoForward
 Indicates if the object can go forward.
const unsigned long LOAD_FLAGS_MASK = 0xffff
 This flags defines the range of bits that may be specified.
const unsigned long LOAD_FLAGS_NONE = 0x0000
 This is the default value for the load flags parameter.
const unsigned long LOAD_FLAGS_IS_REFRESH = 0x0010
 This flag specifies that the load should have the semantics of an HTML META refresh (i.e., that the cache should be validated).
const unsigned long LOAD_FLAGS_IS_LINK = 0x0020
 This flag specifies that the load should have the semantics of a link click.
const unsigned long LOAD_FLAGS_BYPASS_HISTORY = 0x0040
 This flag specifies that history should not be updated.
const unsigned long LOAD_FLAGS_REPLACE_HISTORY = 0x0080
 This flag specifies that any existing history entry should be replaced.
const unsigned long LOAD_FLAGS_BYPASS_CACHE = 0x0100
 This flag specifies that the local web cache should be bypassed, but an intermediate proxy cache could still be used to satisfy the load.
const unsigned long LOAD_FLAGS_BYPASS_PROXY = 0x0200
 This flag specifies that any intermediate proxy caches should be bypassed (i.e., that the content should be loaded from the origin server).
const unsigned long LOAD_FLAGS_CHARSET_CHANGE = 0x0400
 This flag specifies that a reload was triggered as a result of detecting an incorrect character encoding while parsing a previously loaded document.
const unsigned long LOAD_FLAGS_STOP_CONTENT = 0x0800
 If this flag is set, Stop() will be called before the load starts and will stop both content and network activity (the default is to only stop network activity).
const unsigned long LOAD_FLAGS_FROM_EXTERNAL = 0x1000
 A hint this load was prompted by an external program: take care!
const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x2000
 This flag specifies that the URI may be submitted to a third-party server for correction.
const unsigned long LOAD_FLAGS_FIRST_LOAD = 0x4000
 This flag specifies that this is the first load in this object.
const unsigned long STOP_NETWORK = 0x01
 This flag specifies that all network activity should be stopped.
const unsigned long STOP_CONTENT = 0x02
 This flag specifies that all content activity should be stopped.
const unsigned long STOP_ALL = 0x03
 This flag specifies that all activity should be stopped.
readonly attribute nsIDOMDocument document
 Retrieves the current DOM document for the frame, or lazily creates a blank document if there is none.
readonly attribute nsIURI currentURI
 The currently loaded URI or null.
readonly attribute nsIURI referringURI
 The referring URI for the currently loaded URI or null.
attribute nsISHistory sessionHistory
 The session history object used by this web navigation instance.

Protected Member Functions

virtual ~nsSHistory ()
NS_IMETHOD GetEntryAtIndex (PRInt32 aIndex, PRBool aModifyIndex, nsISHEntry **aResult)
NS_IMETHOD GetTransactionAtIndex (PRInt32 aIndex, nsISHTransaction **aResult)
nsresult CompareFrames (nsISHEntry *prevEntry, nsISHEntry *nextEntry, nsIDocShell *rootDocShell, long aLoadType, PRBool *aIsFrameFound)
nsresult InitiateLoad (nsISHEntry *aFrameEntry, nsIDocShell *aFrameDS, long aLoadType)
NS_IMETHOD LoadEntry (PRInt32 aIndex, long aLoadType, PRUint32 histCmd)
void EvictWindowContentViewers (PRInt32 aFromIndex, PRInt32 aToIndex)

Static Protected Member Functions

static void EvictGlobalContentViewer ()
static void EvictAllContentViewers ()

Protected Attributes

nsCOMPtr< nsISHTransactionmListRoot
PRInt32 mIndex
PRInt32 mLength
PRInt32 mRequestedIndex
nsWeakPtr mListener
nsIDocShellmRootDocShell

Static Protected Attributes

static PRInt32 sHistoryMaxTotalViewers = -1

Friends

class nsSHEnumerator
class nsSHistoryObserver

Detailed Description

Definition at line 63 of file nsSHistory.h.


Constructor & Destructor Documentation

Definition at line 131 of file nsSHistory.cpp.

                       : mListRoot(nsnull), mIndex(-1), mLength(0), mRequestedIndex(-1)
{
  // Add this new SHistory object to the list
  PR_APPEND_LINK(this, &gSHistoryList);
}
nsSHistory::~nsSHistory ( ) [protected, virtual]

Definition at line 138 of file nsSHistory.cpp.

{
  // Remove this SHistory object from the list
  PR_REMOVE_LINK(this);
}

Member Function Documentation

nsresult nsSHistory::CompareFrames ( nsISHEntry prevEntry,
nsISHEntry nextEntry,
nsIDocShell rootDocShell,
long  aLoadType,
PRBool aIsFrameFound 
) [protected]

Definition at line 1138 of file nsSHistory.cpp.

{
  if (!aPrevEntry || !aNextEntry || !aParent)
    return PR_FALSE;

  nsresult result = NS_OK;
  PRUint32 prevID, nextID;

  aPrevEntry->GetID(&prevID);
  aNextEntry->GetID(&nextID);
 
  // Check the IDs to verify if the pages are different.
  if (prevID != nextID) {
    if (aIsFrameFound)
      *aIsFrameFound = PR_TRUE;
    // Set the Subframe flag of the entry to indicate that
    // it is subframe navigation        
    aNextEntry->SetIsSubFrame(PR_TRUE);
    InitiateLoad(aNextEntry, aParent, aLoadType);
    return NS_OK;
  }

  /* The root entries are the same, so compare any child frames */
  PRInt32 pcnt=0, ncnt=0, dsCount=0;
  nsCOMPtr<nsISHContainer>  prevContainer(do_QueryInterface(aPrevEntry));
  nsCOMPtr<nsISHContainer>  nextContainer(do_QueryInterface(aNextEntry));
  nsCOMPtr<nsIDocShellTreeNode> dsTreeNode(do_QueryInterface(aParent));

  if (!dsTreeNode)
    return NS_ERROR_FAILURE;
  if (!prevContainer || !nextContainer)
    return NS_ERROR_FAILURE;

  prevContainer->GetChildCount(&pcnt);
  nextContainer->GetChildCount(&ncnt);
  dsTreeNode->GetChildCount(&dsCount);

  //XXX What to do if the children count don't match
    
  for (PRInt32 i=0; i<ncnt; i++){
         nsCOMPtr<nsISHEntry> pChild, nChild;
    nsCOMPtr<nsIDocShellTreeItem> dsTreeItemChild;
         
    prevContainer->GetChildAt(i, getter_AddRefs(pChild));
         nextContainer->GetChildAt(i, getter_AddRefs(nChild));
    if (dsCount > 0)
           dsTreeNode->GetChildAt(i, getter_AddRefs(dsTreeItemChild));

         if (!dsTreeItemChild)
      return NS_ERROR_FAILURE;

    nsCOMPtr<nsIDocShell> dsChild(do_QueryInterface(dsTreeItemChild));

         CompareFrames(pChild, nChild, dsChild, aLoadType, aIsFrameFound);
       }     
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSHistory::EvictAllContentViewers ( ) [static, protected]

Definition at line 949 of file nsSHistory.cpp.

Here is the call graph for this function:

void nsSHistory::EvictGlobalContentViewer ( ) [static, protected]

Definition at line 830 of file nsSHistory.cpp.

{
  // true until the total number of content viewers is <= total max
  // The usual case is that we only need to evict one content viewer.
  // However, if somebody resets the pref value, we might occasionally
  // need to evict more than one.
  PRBool shouldTryEviction = PR_TRUE;
  while (shouldTryEviction) {
    // Walk through our list of SHistory objects, looking for content
    // viewers in the possible active window of all of the SHEntry objects.
    // Keep track of the SHEntry object that has a ContentViewer and is
    // farthest from the current focus in any SHistory object.  The
    // ContentViewer associated with that SHEntry will be evicted
    PRInt32 distanceFromFocus = 0;
    nsCOMPtr<nsISHEntry> evictFromSHE;
    nsCOMPtr<nsIContentViewer> evictViewer;
    PRInt32 totalContentViewers = 0;
    nsSHistory* shist = NS_STATIC_CAST(nsSHistory*,
                                       PR_LIST_HEAD(&gSHistoryList));
    while (shist != &gSHistoryList) {
      // Calculate the window of SHEntries that could possibly have a content
      // viewer.  There could be up to gHistoryMaxViewers content viewers,
      // but we don't know whether they are before or after the mIndex position
      // in the SHEntry list.  Just check both sides, to be safe.
      PRInt32 startIndex = PR_MAX(0, shist->mIndex - gHistoryMaxViewers);
      PRInt32 endIndex = PR_MIN(shist->mLength - 1,
                                shist->mIndex + gHistoryMaxViewers);
      nsCOMPtr<nsISHTransaction> trans;
      shist->GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
      
      for (PRInt32 i = startIndex; i <= endIndex; ++i) {
        nsCOMPtr<nsISHEntry> entry;
        trans->GetSHEntry(getter_AddRefs(entry));
        nsCOMPtr<nsIContentViewer> viewer;
        nsCOMPtr<nsISHEntry> ownerEntry;
        entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
                                   getter_AddRefs(viewer));

#ifdef DEBUG_PAGE_CACHE
        nsCOMPtr<nsIURI> uri;
        if (ownerEntry) {
          ownerEntry->GetURI(getter_AddRefs(uri));
        } else {
          entry->GetURI(getter_AddRefs(uri));
        }
        nsCAutoString spec;
        if (uri) {
          uri->GetSpec(spec);
          printf("Considering for eviction: %s\n", spec.get());
        }
#endif
        
        // This SHEntry has a ContentViewer, so check how far away it is from
        // the currently used SHEntry within this SHistory object
        if (viewer) {
          PRInt32 distance = PR_ABS(shist->mIndex - i);
          
#ifdef DEBUG_PAGE_CACHE
          printf("Has a cached content viewer: %s\n", spec.get());
          printf("mIndex: %d i: %d\n", shist->mIndex, i);
#endif
          totalContentViewers++;
          if (distance > distanceFromFocus) {
            
#ifdef DEBUG_PAGE_CACHE
            printf("Choosing as new eviction candidate: %s\n", spec.get());
#endif

            distanceFromFocus = distance;
            evictFromSHE = ownerEntry;
            evictViewer = viewer;
          }
        }
        nsISHTransaction* temp = trans;
        temp->GetNext(getter_AddRefs(trans));
      }
      shist = NS_STATIC_CAST(nsSHistory*, PR_NEXT_LINK(shist));
    }

#ifdef DEBUG_PAGE_CACHE
    printf("Distance from focus: %d\n", distanceFromFocus);
    printf("Total max viewers: %d\n", sHistoryMaxTotalViewers);
    printf("Total number of viewers: %d\n", totalContentViewers);
#endif

    if (totalContentViewers > sHistoryMaxTotalViewers && evictViewer) {
#ifdef DEBUG_PAGE_CACHE
      nsCOMPtr<nsIURI> uri;
      evictFromSHE->GetURI(getter_AddRefs(uri));
      nsCAutoString spec;
      if (uri) {
        uri->GetSpec(spec);
        printf("Evicting content viewer: %s\n", spec.get());
      }
#endif

      evictViewer->Destroy();
      evictFromSHE->SetContentViewer(nsnull);
      evictFromSHE->SyncPresentationState();

      // If we only needed to evict one content viewer, then we are done.
      // Otherwise, continue evicting until we reach the max total limit.
      if (totalContentViewers - sHistoryMaxTotalViewers == 1) {
        shouldTryEviction = PR_FALSE;
      }
    } else {
      // couldn't find a content viewer to evict, so we are done
      shouldTryEviction = PR_FALSE;
    }
  }  // while shouldTryEviction
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSHistory::EvictWindowContentViewers ( PRInt32  aFromIndex,
PRInt32  aToIndex 
) [protected]

Definition at line 767 of file nsSHistory.cpp.

{
  // To enforce the per SHistory object limit on cached content viewers, we
  // need to release all of the content viewers that are no longer in the
  // "window" that now ends/begins at aToIndex.

  // This can happen on the first load of a page in a particular window
  if (aFromIndex < 0 || aToIndex < 0) {
    return;
  }

  // These indices give the range of SHEntries whose content viewers will be
  // evicted
  PRInt32 startIndex, endIndex;
  if (aToIndex > aFromIndex) { // going forward
    endIndex = aToIndex - gHistoryMaxViewers;
    if (endIndex <= 0) {
      return;
    }
    startIndex = PR_MAX(0, aFromIndex - gHistoryMaxViewers);
  } else { // going backward
    startIndex = aToIndex + gHistoryMaxViewers + 1;
    if (startIndex >= mLength) {
      return;
    }
    endIndex = PR_MIN(mLength, aFromIndex + gHistoryMaxViewers);
  }

  nsCOMPtr<nsISHTransaction> trans;
  GetTransactionAtIndex(startIndex, getter_AddRefs(trans));

  for (PRInt32 i = startIndex; i < endIndex; ++i) {
    nsCOMPtr<nsISHEntry> entry;
    trans->GetSHEntry(getter_AddRefs(entry));
    nsCOMPtr<nsIContentViewer> viewer;
    nsCOMPtr<nsISHEntry> ownerEntry;
    entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
                               getter_AddRefs(viewer));
    if (viewer) {
      NS_ASSERTION(ownerEntry,
                   "ContentViewer exists but its SHEntry is null");
#ifdef DEBUG_PAGE_CACHE 
      nsCOMPtr<nsIURI> uri;
      ownerEntry->GetURI(getter_AddRefs(uri));
      nsCAutoString spec;
      if (uri)
        uri->GetSpec(spec);

      printf("per SHistory limit: evicting content viewer: %s\n", spec.get());
#endif

      viewer->Destroy();
      ownerEntry->SetContentViewer(nsnull);
      ownerEntry->SyncPresentationState();
    }

    nsISHTransaction *temp = trans;
    temp->GetNext(getter_AddRefs(trans));
  }
}

Here is the call graph for this function:

NS_IMETHODIMP nsSHistory::GetEntryAtIndex ( PRInt32  aIndex,
PRBool  aModifyIndex,
nsISHEntry **  aResult 
) [protected]

Definition at line 363 of file nsSHistory.cpp.

{
  nsresult rv;
  nsCOMPtr<nsISHTransaction> txn;

  /* GetTransactionAtIndex ensures aResult is valid and validates aIndex */
  rv = GetTransactionAtIndex(aIndex, getter_AddRefs(txn));
  if (NS_SUCCEEDED(rv) && txn) {
    //Get the Entry from the transaction
    rv = txn->GetSHEntry(aResult);
    if (NS_SUCCEEDED(rv) && (*aResult)) {
      // Set mIndex to the requested index, if asked to do so..
      if (aModifyIndex) {
        mIndex = aIndex;
      }
    } //entry
  }  //Transaction
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 171 of file nsSHistory.cpp.

{
  // Calculate an estimate of how many ContentViewers we should cache based
  // on RAM.  This assumes that the average ContentViewer is 4MB (conservative)
  // and caps the max at 8 ContentViewers
  //
  // TODO: Should we split the cache memory betw. ContentViewer caching and
  // nsCacheService?
  //
  // RAM      ContentViewers
  // -----------------------
  // 32   Mb       0
  // 64   Mb       1
  // 128  Mb       2
  // 256  Mb       3
  // 512  Mb       5
  // 1024 Mb       8
  // 2048 Mb       8
  // 4096 Mb       8
  PRUint64 bytes = PR_GetPhysicalMemorySize();

  if (LL_IS_ZERO(bytes))
    return 0;

  // Conversion from unsigned int64 to double doesn't work on all platforms.
  // We need to truncate the value at LL_MAXINT to make sure we don't
  // overflow.
  if (LL_CMP(bytes, >, LL_MAXINT))
    bytes = LL_MAXINT;

  PRUint64 kbytes;
  LL_SHR(kbytes, bytes, 10);

  double kBytesD;
  LL_L2D(kBytesD, (PRInt64) kbytes);

  // This is essentially the same calculation as for nsCacheService,
  // except that we divide the final memory calculation by 4, since
  // we assume each ContentViewer takes on average 4MB
  PRUint32 viewers = 0;
  double x = log(kBytesD)/log(2.0) - 14;
  if (x > 0) {
    viewers    = (PRUint32)(x * x - x + 2.001); // add .001 for rounding
    viewers   /= 4;
  }

  // Cap it off at 8 max
  if (viewers > 8) {
    viewers = 8;
  }
  return viewers;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsSHistory::GetTransactionAtIndex ( PRInt32  aIndex,
nsISHTransaction **  aResult 
) [protected]

Definition at line 399 of file nsSHistory.cpp.

{
     nsresult rv;
     NS_ENSURE_ARG_POINTER(aResult);

     if ((mLength <= 0) || (aIndex < 0) || (aIndex >= mLength))
          return NS_ERROR_FAILURE;

     if (!mListRoot) 
         return NS_ERROR_FAILURE;

     if (aIndex == 0)
        {
           *aResult = mListRoot;
           NS_ADDREF(*aResult);
           return NS_OK;
        } 
        PRInt32   cnt=0;
        nsCOMPtr<nsISHTransaction>  tempPtr;
       
       rv = GetRootTransaction(getter_AddRefs(tempPtr));
       if (NS_FAILED(rv) || !tempPtr)
               return NS_ERROR_FAILURE;

     while(1) {
       nsCOMPtr<nsISHTransaction> ptr;
          rv = tempPtr->GetNext(getter_AddRefs(ptr));
          if (NS_SUCCEEDED(rv) && ptr) {
          cnt++;
                if (cnt == aIndex) {
                       *aResult = ptr;
                       NS_ADDREF(*aResult);
                       break;
                }
                else {
            tempPtr = ptr;
            continue;
                }
          }  //NS_SUCCEEDED
          else 
                 return NS_ERROR_FAILURE;
       }  // while 
  
   return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIWebNavigation::goBack ( ) [inherited]

Tells the object to navigate to the previous session history item.

When a page is loaded from session history, all content is loaded from the cache (if available) and page state (such as form values and scroll position) is restored.

Exceptions:
NS_ERROR_UNEXPECTEDIndicates that the call was unexpected at this time, which implies that canGoBack is false.

Tells the object to navigate to the next session history item.

When a page is loaded from session history, all content is loaded from the cache (if available) and page state (such as form values and scroll position) is restored.

Exceptions:
NS_ERROR_UNEXPECTEDIndicates that the call was unexpected at this time, which implies that canGoForward is false.
void nsIWebNavigation::gotoIndex ( in long  index) [inherited]

Tells the object to navigate to the session history item at a given index.

Exceptions:
NS_ERROR_UNEXPECTEDIndicates that the call was unexpected at this time, which implies that session history entry at the given index does not exist.
nsresult nsSHistory::InitiateLoad ( nsISHEntry aFrameEntry,
nsIDocShell aFrameDS,
long  aLoadType 
) [protected]

Definition at line 1198 of file nsSHistory.cpp.

{
  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;

  /* Set the loadType in the SHEntry too to  what was passed on.
   * This will be passed on to child subframes later in nsDocShell,
   * so that proper loadType is maintained through out a frameset
   */
  aFrameEntry->SetLoadType(aLoadType);    
  aFrameDS->CreateLoadInfo (getter_AddRefs(loadInfo));

  loadInfo->SetLoadType(aLoadType);
  loadInfo->SetSHEntry(aFrameEntry);

  nsCOMPtr<nsIURI> nextURI;
  nsCOMPtr<nsIHistoryEntry> hEntry(do_QueryInterface(aFrameEntry));
  hEntry->GetURI(getter_AddRefs(nextURI));
  // Time   to initiate a document load
  return aFrameDS->LoadURI(nextURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_FALSE);

}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsSHistory::LoadEntry ( PRInt32  aIndex,
long  aLoadType,
PRUint32  histCmd 
) [protected]

Definition at line 1041 of file nsSHistory.cpp.

{
  nsCOMPtr<nsIDocShell> docShell;
  nsCOMPtr<nsISHEntry> shEntry;
  // Keep note of requested history index in mRequestedIndex.
  mRequestedIndex = aIndex;

  nsCOMPtr<nsISHEntry> prevEntry;
  GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(prevEntry));  
   
  nsCOMPtr<nsISHEntry> nextEntry;   
  GetEntryAtIndex(mRequestedIndex, PR_FALSE, getter_AddRefs(nextEntry));
  nsCOMPtr<nsIHistoryEntry> nHEntry(do_QueryInterface(nextEntry));
  if (!nextEntry || !prevEntry || !nHEntry) {    
    mRequestedIndex = -1;
    return NS_ERROR_FAILURE;
  }
  
  // Send appropriate listener notifications
  PRBool canNavigate = PR_TRUE;
  // Get the uri for the entry we are about to visit
  nsCOMPtr<nsIURI> nextURI;
  nHEntry->GetURI(getter_AddRefs(nextURI));
 
  if(mListener) {    
    nsCOMPtr<nsISHistoryListener> listener(do_QueryReferent(mListener));
    if (listener) {
      if (aHistCmd == HIST_CMD_BACK) {
        // We are going back one entry. Send GoBack notifications
        listener->OnHistoryGoBack(nextURI, &canNavigate);
      }
      else if (aHistCmd == HIST_CMD_FORWARD) {
        // We are going forward. Send GoForward notification
        listener->OnHistoryGoForward(nextURI, &canNavigate);
      }
      else if (aHistCmd == HIST_CMD_GOTOINDEX) {
        // We are going somewhere else. This is not reload either
        listener->OnHistoryGotoIndex(aIndex, nextURI, &canNavigate);
      }
    }
  }

  if (!canNavigate) {
    // If the listener asked us not to proceed with 
    // the operation, simply return.    
    return NS_OK;  // XXX Maybe I can return some other error code?
  }

  nsCOMPtr<nsIURI> nexturi;
  PRInt32 pCount=0, nCount=0;
  nsCOMPtr<nsISHContainer> prevAsContainer(do_QueryInterface(prevEntry));
  nsCOMPtr<nsISHContainer> nextAsContainer(do_QueryInterface(nextEntry));
  if (prevAsContainer && nextAsContainer) {
    prevAsContainer->GetChildCount(&pCount);
    nextAsContainer->GetChildCount(&nCount);
  }
  
  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
  if (mRequestedIndex == mIndex) {
    // Possibly a reload case 
    docShell = mRootDocShell;
  }
  else {
    // Going back or forward.
    if ((pCount > 0) && (nCount > 0)) {
      /* THis is a subframe navigation. Go find 
       * the docshell in which load should happen
       */
      PRBool frameFound = PR_FALSE;
      nsresult rv = CompareFrames(prevEntry, nextEntry, mRootDocShell, aLoadType, &frameFound);
      if (!frameFound) {
        // we did not successfully find the subframe in which
        // the new url was to be loaded. return error.
        mRequestedIndex = -1;
        return NS_ERROR_FAILURE; 
      }
      return rv;
    }   // (pCount >0)
    else
      docShell = mRootDocShell;
    }
  

  if (!docShell) {
     // we did not successfully go to the proper index.
     // return error.
      mRequestedIndex = -1;
      return NS_ERROR_FAILURE;
  }

  // Start the load on the appropriate docshell
  return InitiateLoad(nextEntry, docShell, aLoadType);
}

Here is the call graph for this function:

void nsIWebNavigation::loadURI ( in wstring  aURI,
in unsigned long  aLoadFlags,
in nsIURI  aReferrer,
in nsIInputStream  aPostData,
in nsIInputStream  aHeaders 
) [inherited]

Loads a given URI.

This will give priority to loading the requested URI in the object implementing this interface. If it can't be loaded here however, the URI dispatcher will go through its normal process of content loading.

Parameters:
aURIThe URI string to load. For HTTP and FTP URLs and possibly others, characters above U+007F will be converted to UTF-8 and then URL- escaped per the rules of RFC 2396.
aLoadFlagsFlags modifying load behaviour. This parameter is a bitwise combination of the load flags defined above. (Undefined bits are reserved for future use.) Generally you will pass LOAD_FLAGS_NONE for this parameter.
aReferrerThe referring URI. If this argument is null, then the referring URI will be inferred internally.
aPostDataIf the URI corresponds to a HTTP request, then this stream is appended directly to the HTTP request headers. It may be prefixed with additional HTTP headers. This stream must contain a "\r\n" sequence separating any HTTP headers from the HTTP request body. This parameter is optional and may be null.
aHeadersIf the URI corresponds to a HTTP request, then any HTTP headers contained in this stream are set on the HTTP request. The HTTP header stream is formatted as: ( HEADER "\r\n" )* This parameter is optional and may be null.
void nsIWebNavigation::reload ( in unsigned long  aReloadFlags) [inherited]

Tells the Object to reload the current page.

There may be cases where the user will be asked to confirm the reload (for example, when it is determined that the request is non-idempotent).

Parameters:
aReloadFlagsFlags modifying load behaviour. This parameter is a bitwise combination of the Load Flags defined above. (Undefined bits are reserved for future use.) Generally you will pass LOAD_FLAGS_NONE for this parameter.
Exceptions:
NS_BINDING_ABORTEDIndicating that the user canceled the reload.

Definition at line 226 of file nsSHistory.cpp.

{
  nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
  if (prefs) {
    // Session history size is only taken from the default prefs branch.
    // This means that it's only configurable on a per-application basis.
    // The goal of this is to unbreak users who have inadvertently set their
    // session history size to -1.
    nsCOMPtr<nsIPrefBranch> defaultBranch;
    prefs->GetDefaultBranch(nsnull, getter_AddRefs(defaultBranch));
    if (defaultBranch) {
      defaultBranch->GetIntPref(PREF_SHISTORY_SIZE, &gHistoryMaxSize);
    }
    
    // Allow the user to override the max total number of cached viewers,
    // but keep the per SHistory cached viewer limit constant
    nsCOMPtr<nsIPrefBranch2> branch = do_QueryInterface(prefs);
    if (branch) {
      branch->GetIntPref(PREF_SHISTORY_MAX_TOTAL_VIEWERS,
                         &sHistoryMaxTotalViewers);
      nsSHistoryObserver* obs = new nsSHistoryObserver();
      if (!obs) {
        return NS_ERROR_OUT_OF_MEMORY;
      }
      branch->AddObserver(PREF_SHISTORY_MAX_TOTAL_VIEWERS,
                          obs, PR_FALSE);

      nsCOMPtr<nsIObserverService> obsSvc =
        do_GetService("@mozilla.org/observer-service;1");
      if (obsSvc) {
        // Observe empty-cache notifications so tahat clearing the disk/memory
        // cache will also evict all content viewers.
        obsSvc->AddObserver(obs,
                            NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID, PR_FALSE);

        // Same for memory-pressure notifications
        obsSvc->AddObserver(obs, "memory-pressure", PR_FALSE);
      }
    }
  }
  // If the pref is negative, that means we calculate how many viewers
  // we think we should cache, based on total memory
  if (sHistoryMaxTotalViewers < 0) {
    sHistoryMaxTotalViewers = GetMaxTotalViewers();
  }

  // Initialize the global list of all SHistory objects
  PR_INIT_CLIST(&gSHistoryList);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIWebNavigation::stop ( in unsigned long  aStopFlags) [inherited]

Stops a load of a URI.

Parameters:
aStopFlagsThis parameter is one of the stop flags defined above.

Friends And Related Function Documentation

friend class nsSHEnumerator [friend]

Definition at line 85 of file nsSHistory.h.

friend class nsSHistoryObserver [friend]

Definition at line 86 of file nsSHistory.h.


Member Data Documentation

Indicates if the object can go back.

If true this indicates that there is back session history available for navigation.

Definition at line 62 of file nsIWebNavigation.idl.

Indicates if the object can go forward.

If true this indicates that there is forward session history available for navigation

Definition at line 68 of file nsIWebNavigation.idl.

The currently loaded URI or null.

Definition at line 286 of file nsIWebNavigation.idl.

Retrieves the current DOM document for the frame, or lazily creates a blank document if there is none.

This attribute never returns null except for unexpected error situations.

Definition at line 281 of file nsIWebNavigation.idl.

This flag specifies that the URI may be submitted to a third-party server for correction.

This should only be applied to non-sensitive URIs entered by users.

Definition at line 183 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE = 0x0100 [inherited]

This flag specifies that the local web cache should be bypassed, but an intermediate proxy cache could still be used to satisfy the load.

Definition at line 150 of file nsIWebNavigation.idl.

This flag specifies that history should not be updated.

This flag is only applicable to loadURI.

Definition at line 138 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY = 0x0200 [inherited]

This flag specifies that any intermediate proxy caches should be bypassed (i.e., that the content should be loaded from the origin server).

Definition at line 156 of file nsIWebNavigation.idl.

This flag specifies that a reload was triggered as a result of detecting an incorrect character encoding while parsing a previously loaded document.

Definition at line 163 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD = 0x4000 [inherited]

This flag specifies that this is the first load in this object.

Set with care, since setting incorrectly can cause us to assume that nothing was actually loaded in this object if the load ends up being handled by an external application.

Definition at line 191 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL = 0x1000 [inherited]

A hint this load was prompted by an external program: take care!

Definition at line 176 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_IS_LINK = 0x0020 [inherited]

This flag specifies that the load should have the semantics of a link click.

This flag is only applicable to loadURI. XXX the meaning of this flag is poorly defined.

Definition at line 132 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_IS_REFRESH = 0x0010 [inherited]

This flag specifies that the load should have the semantics of an HTML META refresh (i.e., that the cache should be validated).

This flag is only applicable to loadURI. XXX the meaning of this flag is poorly defined.

Definition at line 125 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_MASK = 0xffff [inherited]

This flags defines the range of bits that may be specified.

Definition at line 112 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_NONE = 0x0000 [inherited]

This is the default value for the load flags parameter.

Definition at line 117 of file nsIWebNavigation.idl.

This flag specifies that any existing history entry should be replaced.

This flag is only applicable to loadURI.

Definition at line 144 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT = 0x0800 [inherited]

If this flag is set, Stop() will be called before the load starts and will stop both content and network activity (the default is to only stop network activity).

Effectively, this passes the STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.

Definition at line 171 of file nsIWebNavigation.idl.

Definition at line 106 of file nsSHistory.h.

Definition at line 107 of file nsSHistory.h.

Definition at line 110 of file nsSHistory.h.

Definition at line 105 of file nsSHistory.h.

Definition at line 108 of file nsSHistory.h.

Definition at line 112 of file nsSHistory.h.

The referring URI for the currently loaded URI or null.

Definition at line 291 of file nsIWebNavigation.idl.

The session history object used by this web navigation instance.

Definition at line 296 of file nsIWebNavigation.idl.

PRInt32 nsSHistory::sHistoryMaxTotalViewers = -1 [static, protected]

Definition at line 115 of file nsSHistory.h.

const unsigned long nsIWebNavigation::STOP_ALL = 0x03 [inherited]

This flag specifies that all activity should be stopped.

Definition at line 266 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::STOP_CONTENT = 0x02 [inherited]

This flag specifies that all content activity should be stopped.

This includes animated images, plugins and pending Javascript timeouts.

Definition at line 261 of file nsIWebNavigation.idl.

const unsigned long nsIWebNavigation::STOP_NETWORK = 0x01 [inherited]

This flag specifies that all network activity should be stopped.

This includes both active network loads and pending META-refreshes.

Definition at line 255 of file nsIWebNavigation.idl.


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