summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 18:32:21 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 18:32:21 +0000
commit3828d6f949346e071e06b10dc47d644510b53392 (patch)
treee766a38cdf72be12f1cf646aa6b143907552e208 /chrome/browser/autocomplete
parent90d3120dfbe571edc29527a4f6733accc4fd99b7 (diff)
downloadchromium_src-3828d6f949346e071e06b10dc47d644510b53392.zip
chromium_src-3828d6f949346e071e06b10dc47d644510b53392.tar.gz
chromium_src-3828d6f949346e071e06b10dc47d644510b53392.tar.bz2
Add caching of the InMemoryURLIndex (part of the HistoryQuickProvider) part 1. (Transactions will be introduced in the next submission.) Fixed a problem in the caching of search results as the user types each character in a search term. Updated the unit test associated with that code.
Added (temporary) flag which can be used to turn on the HQP (enable-history-quick-provider); also added it to about:flags. Previously reviewed as http://codereview.chromium.org/6286029/. BUG=19736, 60107 TEST=Added unit tests. Review URL: http://codereview.chromium.org/6578018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc6
-rw-r--r--chrome/browser/autocomplete/history_provider_util.cc13
-rw-r--r--chrome/browser/autocomplete/history_provider_util.h13
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.h5
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc5
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc15
6 files changed, 17 insertions, 40 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index daad189..e10c3c8 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -789,8 +789,10 @@ AutocompleteController::AutocompleteController(
in_start_(false) {
search_provider_ = new SearchProvider(this, profile);
providers_.push_back(search_provider_);
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableHistoryQuickProvider))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableHistoryQuickProvider) &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableHistoryQuickProvider))
providers_.push_back(new HistoryQuickProvider(this, profile));
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableHistoryURLProvider))
diff --git a/chrome/browser/autocomplete/history_provider_util.cc b/chrome/browser/autocomplete/history_provider_util.cc
index 4325b6b..a8b23d7 100644
--- a/chrome/browser/autocomplete/history_provider_util.cc
+++ b/chrome/browser/autocomplete/history_provider_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,10 +6,6 @@
namespace history {
-const int kLowQualityMatchTypedLimit = 1;
-const int kLowQualityMatchVisitLimit = 3;
-const int kLowQualityMatchAgeLimitInDays = 3;
-
HistoryMatch::HistoryMatch()
: url_info(),
input_location(string16::npos),
@@ -31,9 +27,4 @@ bool HistoryMatch::operator==(const GURL& url) const {
return url_info.url() == url;
}
-base::Time AutocompleteAgeThreshold() {
- return (base::Time::Now() -
- base::TimeDelta::FromDays(kLowQualityMatchAgeLimitInDays));
-}
-
-}
+} // namespace history
diff --git a/chrome/browser/autocomplete/history_provider_util.h b/chrome/browser/autocomplete/history_provider_util.h
index aa4b444..5866df9 100644
--- a/chrome/browser/autocomplete/history_provider_util.h
+++ b/chrome/browser/autocomplete/history_provider_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,13 +13,6 @@
namespace history {
-// Constants which specify, when considered altogether, 'significant'
-// history items. These are used to filter out insignificant items
-// for consideration as autocomplete candidates.
-extern const int kLowQualityMatchTypedLimit;
-extern const int kLowQualityMatchVisitLimit;
-extern const int kLowQualityMatchAgeLimitInDays;
-
// Used for intermediate history result operations.
struct HistoryMatch {
// Required for STL, we don't use this directly.
@@ -71,10 +64,6 @@ struct Prefix {
int num_components;
};
typedef std::vector<Prefix> Prefixes;
-
-// Returns the date threshold for considering an history item as significant.
-base::Time AutocompleteAgeThreshold();
-
}
#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_
diff --git a/chrome/browser/autocomplete/history_quick_provider.h b/chrome/browser/autocomplete/history_quick_provider.h
index 561336b..befb8bc 100644
--- a/chrome/browser/autocomplete/history_quick_provider.h
+++ b/chrome/browser/autocomplete/history_quick_provider.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,9 +22,6 @@ class HistoryBackend;
// the history system) which quickly (and synchronously) provides matching
// results from recently or frequently visited sites in the profile's
// history.
-//
-// TODO(mrossetti): Review to see if the following applies since we're not
-// using the database during the autocomplete pass.
class HistoryQuickProvider : public HistoryProvider {
public:
HistoryQuickProvider(ACProviderListener* listener, Profile* profile);
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index d5b5e0d..c640456 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -139,7 +139,8 @@ void HistoryQuickProviderTest::FillData() {
history::SOURCE_BROWSED);
}
- history::InMemoryURLIndex* index = new history::InMemoryURLIndex();
+ history::InMemoryURLIndex* index =
+ new history::InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy")));
PrefService* prefs = profile_->GetPrefs();
std::string languages(prefs->GetString(prefs::kAcceptLanguages));
index->Init(db, languages);
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 1db38f0..0dafe8e 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,6 +15,7 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/history_database.h"
+#include "chrome/browser/history/history_types.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -689,16 +690,12 @@ void HistoryURLProvider::SortMatches(HistoryMatches* matches) const {
}
void HistoryURLProvider::CullPoorMatches(HistoryMatches* matches) const {
- Time recent_threshold = history::AutocompleteAgeThreshold();
+ const base::Time& threshold(history::AutocompleteAgeThreshold());
for (HistoryMatches::iterator i(matches->begin()); i != matches->end();) {
- const history::URLRow& url_info(i->url_info);
- if ((url_info.typed_count() <= history::kLowQualityMatchTypedLimit) &&
- (url_info.visit_count() <= history::kLowQualityMatchVisitLimit) &&
- (url_info.last_visit() < recent_threshold)) {
- i = matches->erase(i);
- } else {
+ if (RowQualifiesAsSignificant(i->url_info, threshold))
++i;
- }
+ else
+ i = matches->erase(i);
}
}