| 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/autocomplete/in_memory_url_index.h" | 5 #include "chrome/browser/autocomplete/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/autocomplete/url_index_private_data.h" | 10 #include "chrome/browser/autocomplete/url_index_private_data.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 whitelist->insert(std::string(content::kChromeUIScheme)); | 31 whitelist->insert(std::string(content::kChromeUIScheme)); |
| 32 whitelist->insert(std::string(url::kFileScheme)); | 32 whitelist->insert(std::string(url::kFileScheme)); |
| 33 whitelist->insert(std::string(url::kFtpScheme)); | 33 whitelist->insert(std::string(url::kFtpScheme)); |
| 34 whitelist->insert(std::string(url::kHttpScheme)); | 34 whitelist->insert(std::string(url::kHttpScheme)); |
| 35 whitelist->insert(std::string(url::kHttpsScheme)); | 35 whitelist->insert(std::string(url::kHttpsScheme)); |
| 36 whitelist->insert(std::string(url::kMailToScheme)); | 36 whitelist->insert(std::string(url::kMailToScheme)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Restore/SaveCacheObserver --------------------------------------------------- | 39 // Restore/SaveCacheObserver --------------------------------------------------- |
| 40 | 40 |
| 41 InMemoryURLIndex::RestoreCacheObserver::~RestoreCacheObserver() {} | 41 InMemoryURLIndex::RestoreCacheObserver::~RestoreCacheObserver() { |
| 42 } |
| 42 | 43 |
| 43 InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() {} | 44 InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() { |
| 45 } |
| 44 | 46 |
| 45 // RebuildPrivateDataFromHistoryDBTask ----------------------------------------- | 47 // RebuildPrivateDataFromHistoryDBTask ----------------------------------------- |
| 46 | 48 |
| 47 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: | 49 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: |
| 48 RebuildPrivateDataFromHistoryDBTask( | 50 RebuildPrivateDataFromHistoryDBTask( |
| 49 InMemoryURLIndex* index, | 51 InMemoryURLIndex* index, |
| 50 const std::string& languages, | 52 const std::string& languages, |
| 51 const std::set<std::string>& scheme_whitelist) | 53 const std::set<std::string>& scheme_whitelist) |
| 52 : index_(index), | 54 : index_(index), |
| 53 languages_(languages), | 55 languages_(languages), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 DoneRunOnMainThread() { | 72 DoneRunOnMainThread() { |
| 71 index_->DoneRebuidingPrivateDataFromHistoryDB(succeeded_, data_); | 73 index_->DoneRebuidingPrivateDataFromHistoryDB(succeeded_, data_); |
| 72 } | 74 } |
| 73 | 75 |
| 74 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: | 76 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: |
| 75 ~RebuildPrivateDataFromHistoryDBTask() { | 77 ~RebuildPrivateDataFromHistoryDBTask() { |
| 76 } | 78 } |
| 77 | 79 |
| 78 // InMemoryURLIndex ------------------------------------------------------------ | 80 // InMemoryURLIndex ------------------------------------------------------------ |
| 79 | 81 |
| 80 InMemoryURLIndex::InMemoryURLIndex(history::HistoryService* history_service, | 82 InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model, |
| 83 history::HistoryService* history_service, |
| 81 const base::FilePath& history_dir, | 84 const base::FilePath& history_dir, |
| 82 const std::string& languages) | 85 const std::string& languages) |
| 83 : history_service_(history_service), | 86 : bookmark_model_(bookmark_model), |
| 87 history_service_(history_service), |
| 84 history_dir_(history_dir), | 88 history_dir_(history_dir), |
| 85 languages_(languages), | 89 languages_(languages), |
| 86 private_data_(new URLIndexPrivateData), | 90 private_data_(new URLIndexPrivateData), |
| 87 restore_cache_observer_(NULL), | 91 restore_cache_observer_(NULL), |
| 88 save_cache_observer_(NULL), | 92 save_cache_observer_(NULL), |
| 89 shutdown_(false), | 93 shutdown_(false), |
| 90 restored_(false), | 94 restored_(false), |
| 91 needs_to_be_cached_(false), | 95 needs_to_be_cached_(false), |
| 92 listen_to_history_service_loaded_(false) { | 96 listen_to_history_service_loaded_(false) { |
| 93 InitializeSchemeWhitelist(&scheme_whitelist_); | 97 InitializeSchemeWhitelist(&scheme_whitelist_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return false; | 138 return false; |
| 135 *file_path = history_dir_.Append(FILE_PATH_LITERAL("History Provider Cache")); | 139 *file_path = history_dir_.Append(FILE_PATH_LITERAL("History Provider Cache")); |
| 136 return true; | 140 return true; |
| 137 } | 141 } |
| 138 | 142 |
| 139 // Querying -------------------------------------------------------------------- | 143 // Querying -------------------------------------------------------------------- |
| 140 | 144 |
| 141 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( | 145 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( |
| 142 const base::string16& term_string, | 146 const base::string16& term_string, |
| 143 size_t cursor_position, | 147 size_t cursor_position, |
| 144 size_t max_matches, | 148 size_t max_matches) { |
| 145 const ScoredHistoryMatch::Builder& builder) { | 149 return private_data_->HistoryItemsForTerms( |
| 146 return private_data_->HistoryItemsForTerms(term_string, cursor_position, | 150 term_string, cursor_position, max_matches, languages_, bookmark_model_); |
| 147 max_matches, languages_, builder); | |
| 148 } | 151 } |
| 149 | 152 |
| 150 // Updating -------------------------------------------------------------------- | 153 // Updating -------------------------------------------------------------------- |
| 151 | 154 |
| 152 void InMemoryURLIndex::DeleteURL(const GURL& url) { | 155 void InMemoryURLIndex::DeleteURL(const GURL& url) { |
| 153 private_data_->DeleteURL(url); | 156 private_data_->DeleteURL(url); |
| 154 } | 157 } |
| 155 | 158 |
| 156 void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service, | 159 void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service, |
| 157 ui::PageTransition transition, | 160 ui::PageTransition transition, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 content::BrowserThread::PostBlockingPoolTask( | 327 content::BrowserThread::PostBlockingPoolTask( |
| 325 FROM_HERE, | 328 FROM_HERE, |
| 326 base::Bind(DeleteCacheFile, path)); | 329 base::Bind(DeleteCacheFile, path)); |
| 327 } | 330 } |
| 328 } | 331 } |
| 329 | 332 |
| 330 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 333 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
| 331 if (save_cache_observer_) | 334 if (save_cache_observer_) |
| 332 save_cache_observer_->OnCacheSaveFinished(succeeded); | 335 save_cache_observer_->OnCacheSaveFinished(succeeded); |
| 333 } | 336 } |
| OLD | NEW |