зеркало из https://github.com/mozilla/gecko-dev.git
Test code for the new Session History all wrapped inside #ifdef DEBUG_radha.
r=dp
This commit is contained in:
Родитель
2193620570
Коммит
e19e12405c
|
@ -83,6 +83,8 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
|||
#include "nsIWalletService.h"
|
||||
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
||||
|
@ -98,6 +100,14 @@ static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
|||
#include "nsINameSpaceManager.h"
|
||||
#include "nsFileStream.h"
|
||||
|
||||
#ifdef DEBUG_radha
|
||||
#include "nsISHTransaction.h"
|
||||
#include "nsISHEntry.h"
|
||||
PRBool isDoingHistory=PR_FALSE;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Stuff to implement find/findnext
|
||||
#include "nsIFindComponent.h"
|
||||
#ifdef DEBUG_warren
|
||||
|
@ -219,7 +229,16 @@ nsBrowserAppCore::Init()
|
|||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
#ifdef DEBUG_radha
|
||||
printf("Successfully created instance of session history\n");
|
||||
|
||||
rv = nsComponentManager::CreateInstance(NS_SHISTORY_PROGID,
|
||||
nsnull,
|
||||
nsISHistory::GetIID(),
|
||||
(void **) &mNewSHistory);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
printf("**** Successfully created new Session History ****\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add this object of observer of various events.
|
||||
BeginObserving();
|
||||
}
|
||||
|
@ -229,7 +248,8 @@ nsBrowserAppCore::Init()
|
|||
NS_WITH_SERVICE(nsIURILoader, dispatcher, NS_URI_LOADER_PROGID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = dispatcher->RegisterContentListener(this);
|
||||
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1512,6 +1532,69 @@ nsBrowserAppCore::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* chan
|
|||
NS_SUCCEEDED(aStatus) ? kEndDocumentLoad.GetUnicode() : kFailDocumentLoad.GetUnicode(),
|
||||
urlStr.GetUnicode());
|
||||
|
||||
|
||||
#ifdef DEBUG_radha
|
||||
if (!isDoingHistory) {
|
||||
nsCOMPtr<nsISHEntry> shEntry;
|
||||
rv = nsComponentManager::CreateInstance(NS_SHENTRY_PROGID,
|
||||
nsnull,
|
||||
nsISHEntry::GetIID(),
|
||||
(void **) &shEntry);
|
||||
|
||||
const PRUnichar * title=nsnull;
|
||||
webshell->GetName(&title);
|
||||
nsString titlestr(title);
|
||||
nsCOMPtr<nsIURI> histURI;
|
||||
NS_NewURI(getter_AddRefs(histURI), url, nsnull);
|
||||
nsCOMPtr<nsISupports> histLayoutState;
|
||||
webshell->GetHistoryState(getter_AddRefs(histLayoutState));
|
||||
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
printf("******* Successfully created nsSHEntry ********* \n");
|
||||
shEntry->Create(histURI, titlestr.ToNewUnicode(), nsnull, nsnull, histLayoutState);
|
||||
|
||||
}
|
||||
if (mNewSHistory) {
|
||||
rv = mNewSHistory->Add(shEntry);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
printf("*** Successfully added entry to New SH ***\n");
|
||||
PRInt32 index=0, ccount=0;
|
||||
mNewSHistory->GetIndex(&index);
|
||||
mNewSHistory->GetLength(&ccount);
|
||||
printf("%%%% Session History Index = %d, count = %d %%%%\n", index, ccount);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsCOMPtr<nsISHTransaction> shTransaction;
|
||||
rv = nsComponentManager::CreateInstance(NS_SHTRANSACTION_PROGID,
|
||||
nsnull,
|
||||
nsISHTransaction::GetIID(),
|
||||
(void **) &shTransaction);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
printf("******* Successfully created nsSHEntry ********* \n");
|
||||
|
||||
if (mNewSHistory) {
|
||||
// If there is already a transaction
|
||||
shTransaction->Create(shEntry, mNewSHistory);
|
||||
}
|
||||
else {
|
||||
// This is the first transaction
|
||||
mNewSHistory = shTransaction;
|
||||
shTransaction->Create(shEntry, nsnull);
|
||||
mNewSHistoryIndex++;
|
||||
mNewSHistoryCount++;
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
if (isDoingHistory)
|
||||
isDoingHistory = PR_FALSE;
|
||||
#endif /* DEBUG_radha */
|
||||
|
||||
|
||||
// XXX Ignore rv for now. They are using nsIEnumerator instead of
|
||||
// nsISimpleEnumerator.
|
||||
/*
|
||||
|
@ -1664,6 +1747,27 @@ nsBrowserAppCore::GoBack(nsIWebShell * aPrev)
|
|||
//mSHistory checks for null pointers
|
||||
return mSHistory->GoBack(aPrev);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_radha
|
||||
isDoingHistory= PR_TRUE;
|
||||
PRInt32 index=0, ccount = 0;
|
||||
nsresult rv;
|
||||
if (mNewSHistory) {
|
||||
mNewSHistory->GetLength(&ccount);
|
||||
mNewSHistory->GetIndex(&index);
|
||||
|
||||
if (index > -1) {
|
||||
index -=1;
|
||||
nsCOMPtr<nsISHTransaction> backTXN;
|
||||
rv = mNewSHistory->GetTransactionForIndex(index, getter_AddRefs(backTXN));
|
||||
if (NS_SUCCEEDED(rv) && backTXN)
|
||||
printf("##### Got the back Transaction successfully #####\n");
|
||||
else
|
||||
printf("@@@@@ Error getting back Transaction @@@@@\n");
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG_radha */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1674,10 +1778,34 @@ nsBrowserAppCore::GoForward(nsIWebShell * aPrev)
|
|||
SetLoadingFlag(PR_FALSE);
|
||||
}
|
||||
mIsLoadingHistory = PR_TRUE;
|
||||
|
||||
if (mSHistory) {
|
||||
//mSHistory checks for null pointers
|
||||
return mSHistory->GoForward(aPrev);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_radha
|
||||
isDoingHistory = PR_TRUE;
|
||||
PRInt32 index=0, ccount = 0;
|
||||
nsresult rv;
|
||||
if (mNewSHistory) {
|
||||
mNewSHistory->GetLength(&ccount);
|
||||
mNewSHistory->GetIndex(&index);
|
||||
|
||||
if (index < ccount) {
|
||||
index +=1;
|
||||
nsCOMPtr<nsISHTransaction> forwardTXN;
|
||||
rv = mNewSHistory->GetTransactionForIndex(index, getter_AddRefs(forwardTXN));
|
||||
if (NS_SUCCEEDED(rv) && forwardTXN)
|
||||
printf("##### Got the forward Transaction successfully #####\n");
|
||||
else
|
||||
printf("@@@@@ Error getting forwardTransaction @@@@@\n");
|
||||
}
|
||||
} // mNewSHistory
|
||||
#endif /* DEBUG_radha */
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1752,13 +1880,14 @@ nsBrowserAppCore::CanGoForward(PRBool * aResult)
|
|||
if (mSHistory) {
|
||||
mSHistory->CanGoForward(aResult);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::CanGoBack(PRBool * aResult)
|
||||
{
|
||||
|
||||
if (mSHistory)
|
||||
mSHistory->CanGoBack(aResult);
|
||||
return NS_OK;
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
#include "nsISessionHistory.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
|
||||
#ifdef DEBUG_radha
|
||||
#include "nsISHistory.h"
|
||||
#endif
|
||||
|
||||
class nsIBrowserWindow;
|
||||
class nsIWebShell;
|
||||
class nsIScriptContext;
|
||||
|
@ -116,6 +120,9 @@ class nsBrowserInstance : public nsIBrowserInstance,
|
|||
|
||||
nsCOMPtr<nsISupports> mSearchContext; // at last, something we really own
|
||||
nsInstanceCounter mInstanceCounter;
|
||||
#ifdef DEBUG_radha
|
||||
nsISHistory * mNewSHistory;
|
||||
#endif /* DEBUG_radha */
|
||||
PRBool mIsLoadingHistory;
|
||||
#ifdef DEBUG_warren
|
||||
PRIntervalTime mLoadStartTime;
|
||||
|
|
Загрузка…
Ссылка в новой задаче