| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/history/in_memory_url_index.h" | 5 #include "chrome/browser/history/in_memory_url_index.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: | 76 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: |
| 77 ~RebuildPrivateDataFromHistoryDBTask() { | 77 ~RebuildPrivateDataFromHistoryDBTask() { |
| 78 } | 78 } |
| 79 | 79 |
| 80 // InMemoryURLIndex ------------------------------------------------------------ | 80 // InMemoryURLIndex ------------------------------------------------------------ |
| 81 | 81 |
| 82 InMemoryURLIndex::InMemoryURLIndex(HistoryService* history_service, | 82 InMemoryURLIndex::InMemoryURLIndex(HistoryService* history_service, |
| 83 const base::FilePath& history_dir, | 83 const base::FilePath& history_dir, |
| 84 const std::string& languages, | 84 const std::string& languages) |
| 85 HistoryClient* history_client) | |
| 86 : history_service_(history_service), | 85 : history_service_(history_service), |
| 87 history_client_(history_client), | |
| 88 history_dir_(history_dir), | 86 history_dir_(history_dir), |
| 89 languages_(languages), | 87 languages_(languages), |
| 90 private_data_(new URLIndexPrivateData), | 88 private_data_(new URLIndexPrivateData), |
| 91 restore_cache_observer_(NULL), | 89 restore_cache_observer_(NULL), |
| 92 save_cache_observer_(NULL), | 90 save_cache_observer_(NULL), |
| 93 shutdown_(false), | 91 shutdown_(false), |
| 94 restored_(false), | 92 restored_(false), |
| 95 needs_to_be_cached_(false) { | 93 needs_to_be_cached_(false) { |
| 96 InitializeSchemeWhitelist(&scheme_whitelist_); | 94 InitializeSchemeWhitelist(&scheme_whitelist_); |
| 97 // TODO(mrossetti): Register for language change notifications. | 95 // TODO(mrossetti): Register for language change notifications. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return false; | 133 return false; |
| 136 *file_path = history_dir_.Append(FILE_PATH_LITERAL("History Provider Cache")); | 134 *file_path = history_dir_.Append(FILE_PATH_LITERAL("History Provider Cache")); |
| 137 return true; | 135 return true; |
| 138 } | 136 } |
| 139 | 137 |
| 140 // Querying -------------------------------------------------------------------- | 138 // Querying -------------------------------------------------------------------- |
| 141 | 139 |
| 142 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( | 140 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( |
| 143 const base::string16& term_string, | 141 const base::string16& term_string, |
| 144 size_t cursor_position, | 142 size_t cursor_position, |
| 145 size_t max_matches) { | 143 size_t max_matches, |
| 146 return private_data_->HistoryItemsForTerms( | 144 const ScoredHistoryMatch::Builder& builder) { |
| 147 term_string, | 145 return private_data_->HistoryItemsForTerms(term_string, cursor_position, |
| 148 cursor_position, | 146 max_matches, languages_, builder); |
| 149 max_matches, | |
| 150 languages_, | |
| 151 history_client_); | |
| 152 } | 147 } |
| 153 | 148 |
| 154 // Updating -------------------------------------------------------------------- | 149 // Updating -------------------------------------------------------------------- |
| 155 | 150 |
| 156 void InMemoryURLIndex::DeleteURL(const GURL& url) { | 151 void InMemoryURLIndex::DeleteURL(const GURL& url) { |
| 157 private_data_->DeleteURL(url); | 152 private_data_->DeleteURL(url); |
| 158 } | 153 } |
| 159 | 154 |
| 160 void InMemoryURLIndex::OnURLVisited(HistoryService* history_service, | 155 void InMemoryURLIndex::OnURLVisited(HistoryService* history_service, |
| 161 ui::PageTransition transition, | 156 ui::PageTransition transition, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 base::Bind(DeleteCacheFile, path)); | 319 base::Bind(DeleteCacheFile, path)); |
| 325 } | 320 } |
| 326 } | 321 } |
| 327 | 322 |
| 328 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 323 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
| 329 if (save_cache_observer_) | 324 if (save_cache_observer_) |
| 330 save_cache_observer_->OnCacheSaveFinished(succeeded); | 325 save_cache_observer_->OnCacheSaveFinished(succeeded); |
| 331 } | 326 } |
| 332 | 327 |
| 333 } // namespace history | 328 } // namespace history |
| OLD | NEW |