Avoid rebuilding the history data source on shutdown (because of an end-batch coming out of entry expiration); this makes quitting faster if you have a big history DB.

This commit is contained in:
smfr%smfr.org 2005-10-04 23:09:26 +00:00
parent c45204aeea
commit cf8cebe217
4 changed files with 34 additions and 7 deletions

View File

@ -544,7 +544,13 @@ public:
NS_IMETHOD HistoryLoaded()
{
// we build the Obj-C data source lazily, so do nothing here
return NS_OK;
}
NS_IMETHOD HistoryClosing()
{
[mDataSource cleanupHistory];
return NS_OK;
}

View File

@ -45,12 +45,12 @@
#include "nsIHistoryItems.h"
// CB1059D7-5BC5-11D9-8254-000393D7254A
#define NS_IHISTORYOBSERVER_IID_STR "cb1059d7-5bc5-11d9-8254-000393d7254a"
// BDF54C7D-83C6-406F-84D3-D5ABB9D978B2
#define NS_IHISTORYOBSERVER_IID_STR "bdf54c7d-83c6-406f-84d3-d5abb9d978b2"
#define NS_IHISTORYOBSERVER_IID \
{0xcb1059d7, 0x5bc5, 0x11d9, \
{ 0x82, 0x54, 0x00, 0x03, 0x39, 0xd7, 0x25, 0x4a }}
{0xbdf54c7d, 0x83c6, 0x406f, \
{ 0x84, 0xd3, 0xd5, 0xab, 0xb9, 0xd9, 0x78, 0xb2 }}
class nsIHistoryObserver : public nsISupports
{
@ -59,6 +59,7 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHISTORYOBSERVER_IID)
NS_IMETHOD HistoryLoaded() = 0;
NS_IMETHOD HistoryClosing() = 0;
NS_IMETHOD ItemLoaded(nsIHistoryItem* inHistoryItem, PRBool inFirstVisit) = 0;

View File

@ -840,6 +840,24 @@ nsSimpleGlobalHistory::NotifyObserversHistoryLoaded()
return NS_OK;
}
nsresult
nsSimpleGlobalHistory::NotifyObserversHistoryClosing()
{
PRUint32 numObservers;
mHistoryObservers.Count(&numObservers);
for (PRUint32 i = 0; i < numObservers; i ++)
{
nsCOMPtr<nsISupports> element;
mHistoryObservers.GetElementAt(i, getter_AddRefs(element));
nsCOMPtr<nsIHistoryObserver> historyObserver = do_QueryInterface(element);
if (historyObserver)
historyObserver->HistoryClosing();
}
return NS_OK;
}
nsresult
nsSimpleGlobalHistory::NotifyObserversItemLoaded(nsIMdbRow* inRow, PRBool inFirstVisit)
{
@ -1763,6 +1781,7 @@ nsSimpleGlobalHistory::OpenDB()
// See if we need to byte-swap.
InitByteOrder(PR_FALSE);
NotifyObserversHistoryLoaded();
return NS_OK;
}
@ -2198,10 +2217,10 @@ nsSimpleGlobalHistory::CloseDB()
if (!mStore)
return NS_OK;
mdb_err err;
NotifyObserversHistoryClosing();
ExpireEntries(PR_FALSE /* don't notify */);
err = Commit(kSessionCommit);
mdb_err err = Commit(kSessionCommit);
// order is important here - logically smallest objects first
mMetaRow = nsnull;

View File

@ -209,6 +209,7 @@ protected:
//
nsresult NotifyObserversHistoryLoaded();
nsresult NotifyObserversHistoryClosing();
nsresult NotifyObserversItemLoaded(nsIMdbRow* inRow, PRBool inFirstVisit);
nsresult NotifyObserversItemRemoved(nsIMdbRow* inRow);
nsresult NotifyObserversItemTitleChanged(nsIMdbRow* inRow);