Bug 414489 - Change default search chunk size and timeout and let users adjust them. r=sspitzer, a1.9=mconnor

This commit is contained in:
edward.lee%engineering.uiuc.edu 2008-01-29 06:53:20 +00:00
Родитель ca290b130c
Коммит a1de54f6fe
4 изменённых файлов: 21 добавлений и 14 удалений

Просмотреть файл

@ -213,6 +213,11 @@ pref("browser.urlbar.matchOnlyTyped", false);
// the maximum number of results to show in autocomplete when doing richResults
pref("browser.urlbar.maxRichResults", 25);
// Size of "chunks" affects the number of places to process between each search
// timeout (ms). Too big and the UI will be unresponsive; too small and we'll
// be waiting on the timeout too often without many results.
pref("browser.urlbar.search.chunkSize", 100);
pref("browser.urlbar.search.timeout", 100);
pref("browser.download.useDownloadDir", true);
pref("browser.download.folderList", 0);

Просмотреть файл

@ -113,6 +113,8 @@
#define PREF_AUTOCOMPLETE_ONLY_TYPED "urlbar.matchOnlyTyped"
#define PREF_AUTOCOMPLETE_ENABLED "urlbar.autocomplete.enabled"
#define PREF_AUTOCOMPLETE_MAX_RICH_RESULTS "urlbar.maxRichResults"
#define PREF_AUTOCOMPLETE_SEARCH_CHUNK_SIZE "urlbar.search.chunkSize"
#define PREF_AUTOCOMPLETE_SEARCH_TIMEOUT "urlbar.search.timeout"
#define PREF_DB_CACHE_PERCENTAGE "history_cache_percentage"
#define PREF_FRECENCY_NUM_VISITS "places.frecency.numVisits"
#define PREF_FRECENCY_UPDATE_IDLE_TIME "places.frecency.updateIdleTime"
@ -311,6 +313,8 @@ nsNavHistory::nsNavHistory() : mNowValid(PR_FALSE),
mExpireSites(0),
mAutoCompleteOnlyTyped(PR_FALSE),
mAutoCompleteMaxResults(25),
mAutoCompleteSearchChunkSize(100),
mAutoCompleteSearchTimeout(100),
mBatchLevel(0),
mLock(nsnull),
mBatchHasTransaction(PR_FALSE),
@ -453,6 +457,8 @@ nsNavHistory::Init()
if (pbi) {
pbi->AddObserver(PREF_AUTOCOMPLETE_ONLY_TYPED, this, PR_FALSE);
pbi->AddObserver(PREF_AUTOCOMPLETE_MAX_RICH_RESULTS, this, PR_FALSE);
pbi->AddObserver(PREF_AUTOCOMPLETE_SEARCH_CHUNK_SIZE, this, PR_FALSE);
pbi->AddObserver(PREF_AUTOCOMPLETE_SEARCH_TIMEOUT, this, PR_FALSE);
pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX, this, PR_FALSE);
pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN, this, PR_FALSE);
pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_SITES, this, PR_FALSE);
@ -1668,6 +1674,10 @@ nsNavHistory::LoadPrefs(PRBool aInitializing)
&mAutoCompleteOnlyTyped);
mPrefBranch->GetBoolPref(PREF_AUTOCOMPLETE_MAX_RICH_RESULTS,
&mAutoCompleteMaxResults);
mPrefBranch->GetBoolPref(PREF_AUTOCOMPLETE_SEARCH_CHUNK_SIZE,
&mAutoCompleteSearchChunkSize);
mPrefBranch->GetBoolPref(PREF_AUTOCOMPLETE_SEARCH_TIMEOUT,
&mAutoCompleteSearchTimeout);
if (!aInitializing && oldCompleteOnlyTyped != mAutoCompleteOnlyTyped) {
// update the autocomplete statements if the option has changed.
nsresult rv = CreateAutoCompleteQueries();

Просмотреть файл

@ -616,6 +616,8 @@ protected:
nsresult CreateAutoCompleteQueries();
PRBool mAutoCompleteOnlyTyped;
PRInt32 mAutoCompleteMaxResults;
PRInt32 mAutoCompleteSearchChunkSize;
PRInt32 mAutoCompleteSearchTimeout;
nsCOMPtr<nsITimer> mAutoCompleteTimer;
nsString mCurrentSearchString;

Просмотреть файл

@ -45,7 +45,7 @@
* Autocomplete algorithm:
*
* Searches moz_places by frecency (in descending order)
* in chunks (AUTOCOMPLETE_SEARCH_CHUNK_SIZE). We currently
* in chunks (mAutoCompleteSearchChunkSize). We currently
* do SQL LIKE searches of the search term in the place title, place url
* and bookmark titles (since a "place" can have multiple bookmarks)
* within in each chunk. The results are ordered by frecency.
@ -178,16 +178,6 @@ nsNavHistory::StartAutoCompleteTimer(PRUint32 aMilliseconds)
return NS_OK;
}
// number of places to search per chunk
// too big, and the UI will be unresponsive
// as we will be off searching the database.
// too small, and because of AUTOCOMPLETE_SEARCH_TIMEOUT
// results won't come back in fast enough to feel snappy.
#define AUTOCOMPLETE_SEARCH_CHUNK_SIZE 100
// wait this many milliseconds between searches
#define AUTOCOMPLETE_SEARCH_TIMEOUT 100
// nsNavHistory::AutoCompleteTimerCallback
void // static
@ -248,8 +238,8 @@ nsNavHistory::PerformAutoComplete()
// if we're not done searching, adjust our current offset
// and search the next chunk
if (moreChunksToSearch) {
mCurrentChunkOffset += AUTOCOMPLETE_SEARCH_CHUNK_SIZE;
rv = StartAutoCompleteTimer(AUTOCOMPLETE_SEARCH_TIMEOUT);
mCurrentChunkOffset += mAutoCompleteSearchChunkSize;
rv = StartAutoCompleteTimer(mAutoCompleteSearchTimeout);
NS_ENSURE_SUCCESS(rv, rv);
} else {
DoneSearching();
@ -565,7 +555,7 @@ nsNavHistory::AutoCompleteFullHistorySearch(PRBool* aHasMoreResults)
nsresult rv = mDBAutoCompleteQuery->BindStringParameter(0, NS_LITERAL_STRING("%") + mCurrentSearchStringEscaped + NS_LITERAL_STRING("%"));
NS_ENSURE_SUCCESS(rv, rv);
rv = mDBAutoCompleteQuery->BindInt32Parameter(1, AUTOCOMPLETE_SEARCH_CHUNK_SIZE);
rv = mDBAutoCompleteQuery->BindInt32Parameter(1, mAutoCompleteSearchChunkSize);
NS_ENSURE_SUCCESS(rv, rv);
rv = mDBAutoCompleteQuery->BindInt32Parameter(2, mCurrentChunkOffset);