Chromium Code Reviews| Index: chrome/browser/history/url_index_private_data.cc |
| diff --git a/chrome/browser/history/url_index_private_data.cc b/chrome/browser/history/url_index_private_data.cc |
| index 8af97fa70032f2997b38002c8454be5868315374..ad389c2fcc211b8e2ac41bcf4f368496a8b93e58 100644 |
| --- a/chrome/browser/history/url_index_private_data.cc |
| +++ b/chrome/browser/history/url_index_private_data.cc |
| @@ -444,6 +444,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory( |
| URLDatabase::URLEnumerator history_enum; |
| if (!history_db->InitURLEnumeratorForSignificant(&history_enum)) |
| return NULL; |
| + rebuilt_data->last_time_rebuilt_from_history_ = base::Time::Now(); |
| for (URLRow row; history_enum.GetNextURL(&row); ) { |
| rebuilt_data->IndexRow(history_db, NULL, row, languages, |
| scheme_whitelist); |
| @@ -475,6 +476,7 @@ void URLIndexPrivateData::CancelPendingUpdates() { |
| scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::Duplicate() const { |
| scoped_refptr<URLIndexPrivateData> data_copy = new URLIndexPrivateData; |
| + data_copy->last_time_rebuilt_from_history_ = last_time_rebuilt_from_history_; |
| data_copy->word_list_ = word_list_; |
| data_copy->available_words_ = available_words_; |
| data_copy->word_map_ = word_map_; |
| @@ -496,6 +498,7 @@ bool URLIndexPrivateData::Empty() const { |
| } |
| void URLIndexPrivateData::Clear() { |
| + last_time_rebuilt_from_history_ = base::Time(); |
| word_list_.clear(); |
| available_words_.clear(); |
| word_map_.clear(); |
| @@ -908,7 +911,8 @@ bool URLIndexPrivateData::SaveToFile(const base::FilePath& file_path) { |
| void URLIndexPrivateData::SavePrivateData( |
| InMemoryURLIndexCacheItem* cache) const { |
| DCHECK(cache); |
| - cache->set_timestamp(base::Time::Now().ToInternalValue()); |
| + cache->set_last_rebuild_timestamp( |
| + last_time_rebuilt_from_history_.ToInternalValue()); |
| cache->set_version(saved_cache_version_); |
| // history_item_count_ is no longer used but rather than change the protobuf |
| // definition use a placeholder. This will go away with the switch to SQLite. |
| @@ -1040,6 +1044,17 @@ void URLIndexPrivateData::SaveWordStartsMap( |
| bool URLIndexPrivateData::RestorePrivateData( |
| const InMemoryURLIndexCacheItem& cache, |
| const std::string& languages) { |
| + last_time_rebuilt_from_history_ = |
| + base::Time::FromInternalValue(cache.last_rebuild_timestamp()); |
| + const base::TimeDelta rebuilt_ago = |
| + base::Time::Now() - last_time_rebuilt_from_history_; |
| + if ((rebuilt_ago > base::TimeDelta::FromDays(7)) || |
| + (rebuilt_ago < base::TimeDelta::FromDays(0))) { |
| + // Cache is more than a week old or, somehow, from some time in the future. |
|
Peter Kasting
2013/06/07 00:39:55
Now() can change with system clock changes like ti
Mark P
2013/06/07 00:50:27
Sounds good to me. Done.
|
| + // It's probably a good time to rebuild the index from history to |
| + // allow synced entries to now appear, expired entries to disappear, etc. |
| + return false; |
| + } |
| if (cache.has_version()) { |
| if (cache.version() < kCurrentCacheFileVersion) { |
| // Don't try to restore an old format cache file. (This will cause |