Index: chrome/browser/history/url_index_private_data.h |
=================================================================== |
--- chrome/browser/history/url_index_private_data.h (revision 125621) |
+++ chrome/browser/history/url_index_private_data.h (working copy) |
@@ -23,6 +23,9 @@ |
class HistoryDatabase; |
+// Current version of the cache file. |
+static const int kCurrentCacheFileVersion = 1; |
+ |
// A structure describing the InMemoryURLIndex's internal data and providing for |
// restoring, rebuilding and updating that internal data. |
class URLIndexPrivateData { |
@@ -177,8 +180,9 @@ |
// was actually updated. |
bool DeleteURL(const GURL& url); |
- // Parses and indexes the words in the URL and page title of |row|. |
- void AddRowWordsToIndex(const URLRow& row); |
+ // Parses and indexes the words in the URL and page title of |row| and |
+ // calculate the word starts in each, saving the starts in |word_starts|. |
+ void AddRowWordsToIndex(const URLRow& row, RowWordStarts* word_starts); |
// Removes |row| and all associated words and characters from the index. |
void RemoveRowFromIndex(const URLRow& row); |
@@ -222,7 +226,8 @@ |
static ScoredHistoryMatch ScoredMatchForURL( |
const URLRow& row, |
const string16& lower_string, |
- const String16Vector& terms_vector); |
+ const String16Vector& terms_vector, |
+ const RowWordStarts& word_starts); |
// Calculates a component score based on position, ordering and total |
// substring match size using metrics recorded in |matches|. |max_length| |
@@ -233,6 +238,10 @@ |
// Determines if |gurl| has a whitelisted scheme and returns true if so. |
bool URLSchemeIsWhitelisted(const GURL& gurl) const; |
+ // Sets the version of the cache file that will be saved when calling |
+ // SavePrivateData(). For unit testing only. |
+ void set_saved_cache_version(int version) { saved_cache_version_ = version; } |
+ |
// Encode a data structure into the protobuf |cache|. |
void SavePrivateData(imui::InMemoryURLIndexCacheItem* cache) const; |
void SaveWordList(imui::InMemoryURLIndexCacheItem* cache) const; |
@@ -240,6 +249,7 @@ |
void SaveCharWordMap(imui::InMemoryURLIndexCacheItem* cache) const; |
void SaveWordIDHistoryMap(imui::InMemoryURLIndexCacheItem* cache) const; |
void SaveHistoryInfoMap(imui::InMemoryURLIndexCacheItem* cache) const; |
+ void SaveWordStartsMap(imui::InMemoryURLIndexCacheItem* cache) const; |
// Decode a data structure from the protobuf |cache|. Return false if there |
// is any kind of failure. |
@@ -249,6 +259,7 @@ |
bool RestoreCharWordMap(const imui::InMemoryURLIndexCacheItem& cache); |
bool RestoreWordIDHistoryMap(const imui::InMemoryURLIndexCacheItem& cache); |
bool RestoreHistoryInfoMap(const imui::InMemoryURLIndexCacheItem& cache); |
+ bool RestoreWordStartsMap(const imui::InMemoryURLIndexCacheItem& cache); |
// Cache of search terms. |
SearchTermCacheMap search_term_cache_; |
@@ -261,6 +272,11 @@ |
// Start of data members that are cached ------------------------------------- |
+ // The version of the cache file most recently used to restore this instance |
+ // of the private data. If the private data was rebuilt from the history |
+ // database this will be 0. |
+ int restored_cache_version_; |
+ |
// A list of all of indexed words. The index of a word in this list is the |
// ID of the word in the word_map_. It reduces the memory overhead by |
// replacing a potentially long and repeated string with a simple index. |
@@ -297,8 +313,17 @@ |
// index inclusion and relevance scoring. |
HistoryInfoMap history_info_map_; |
+ // A one-to-one mapping from HistoryID to the word starts detected in each |
+ // item's URL and page title. |
+ WordStartsMap word_starts_map_; |
+ |
// End of data members that are cached --------------------------------------- |
+ // For unit testing only. Specifies the version of the cache file to be saved. |
+ // Used only for testing upgrading of an older version of the cache upon |
+ // restore. |
+ int saved_cache_version_; |
+ |
// Used for unit testing only. Records the number of candidate history items |
// at three stages in the index searching process. |
size_t pre_filter_item_count_; // After word index is queried. |