Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: chrome/browser/history/url_index_private_data.cc

Issue 10909046: Boost HQP Scores for Bookmarks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Minor edits. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/url_index_private_data.cc
===================================================================
--- chrome/browser/history/url_index_private_data.cc (revision 154855)
+++ chrome/browser/history/url_index_private_data.cc (working copy)
@@ -18,10 +18,15 @@
#include "base/string_util.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/api/bookmarks/bookmark_service.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/autocomplete/url_prefix.h"
+// TODO(mrossetti): Remove these two includes one BookmarkService is available.
Peter Kasting 2012/09/05 19:06:30 Nit: one -> once I'm not actually sure what this
mrossetti 2012/09/05 20:15:43 Done. At some point, there will be an accessor to
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/history_database.h"
#include "chrome/browser/history/in_memory_url_index.h"
+#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
@@ -62,8 +67,9 @@
// Public Functions ------------------------------------------------------------
-URLIndexPrivateData::URLIndexPrivateData()
- : restored_cache_version_(0),
+URLIndexPrivateData::URLIndexPrivateData(Profile* profile)
+ : profile_(profile),
+ restored_cache_version_(0),
saved_cache_version_(kCurrentCacheFileVersion),
pre_filter_item_count_(0),
post_filter_item_count_(0),
@@ -259,14 +265,17 @@
// static
void URLIndexPrivateData::RestoreFromFileTask(
+ Profile* profile,
const FilePath& file_path,
scoped_refptr<URLIndexPrivateData> private_data,
const std::string& languages) {
- private_data = URLIndexPrivateData::RestoreFromFile(file_path, languages);
+ private_data =
+ URLIndexPrivateData::RestoreFromFile(profile, file_path, languages);
}
// static
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
+ Profile* profile,
HistoryDatabase* history_db,
const std::string& languages,
const std::set<std::string>& scheme_whitelist) {
@@ -275,7 +284,8 @@
base::TimeTicks beginning_time = base::TimeTicks::Now();
- scoped_refptr<URLIndexPrivateData> rebuilt_data(new URLIndexPrivateData);
+ scoped_refptr<URLIndexPrivateData>
+ rebuilt_data(new URLIndexPrivateData(profile));
URLDatabase::URLEnumerator history_enum;
if (!history_db->InitURLEnumeratorForSignificant(&history_enum))
return NULL;
@@ -304,7 +314,8 @@
}
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::Duplicate() const {
- scoped_refptr<URLIndexPrivateData> data_copy = new URLIndexPrivateData;
+ scoped_refptr<URLIndexPrivateData> data_copy =
+ new URLIndexPrivateData(profile_);
data_copy->word_list_ = word_list_;
data_copy->available_words_ = available_words_;
data_copy->word_map_ = word_map_;
@@ -377,8 +388,11 @@
WordStartsMap::const_iterator starts_pos =
private_data_.word_starts_map_.find(history_id);
DCHECK(starts_pos != private_data_.word_starts_map_.end());
+ // TODO(mrossetti): Change this to retrieve BookmarkService when available.
+ BookmarkService* bookmark_service =
+ BookmarkModelFactory::GetForProfile(private_data_.profile_);
ScoredHistoryMatch match(hist_item, lower_string_, lower_terms_,
- starts_pos->second, now_);
+ starts_pos->second, now_, bookmark_service);
if (match.raw_score > 0)
scored_matches_.push_back(match);
}
@@ -928,6 +942,7 @@
// static
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RestoreFromFile(
+ Profile* profile,
const FilePath& file_path,
const std::string& languages) {
base::TimeTicks beginning_time = base::TimeTicks::Now();
@@ -939,7 +954,8 @@
if (!file_util::ReadFileToString(file_path, &data))
return NULL;
- scoped_refptr<URLIndexPrivateData> restored_data(new URLIndexPrivateData);
+ scoped_refptr<URLIndexPrivateData>
+ restored_data(new URLIndexPrivateData(profile));
InMemoryURLIndexCacheItem index_cache;
if (!index_cache.ParseFromArray(data.c_str(), data.size())) {
LOG(WARNING) << "Failed to parse URLIndexPrivateData cache data read from "

Powered by Google App Engine
This is Rietveld 408576698