| 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 23 matching lines...) Expand all Loading... |
| 117 return false; | 121 return false; |
| 118 *file_path = history_dir_.Append(FILE_PATH_LITERAL("History Provider Cache")); | 122 *file_path = history_dir_.Append(FILE_PATH_LITERAL("History Provider Cache")); |
| 119 return true; | 123 return true; |
| 120 } | 124 } |
| 121 | 125 |
| 122 // Querying -------------------------------------------------------------------- | 126 // Querying -------------------------------------------------------------------- |
| 123 | 127 |
| 124 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( | 128 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( |
| 125 const base::string16& term_string, | 129 const base::string16& term_string, |
| 126 size_t cursor_position, | 130 size_t cursor_position, |
| 127 size_t max_matches, | 131 size_t max_matches) { |
| 128 const ScoredHistoryMatch::Builder& builder) { | 132 return private_data_->HistoryItemsForTerms( |
| 129 return private_data_->HistoryItemsForTerms(term_string, cursor_position, | 133 term_string, cursor_position, max_matches, languages_, bookmark_model_); |
| 130 max_matches, languages_, builder); | |
| 131 } | 134 } |
| 132 | 135 |
| 133 // Updating -------------------------------------------------------------------- | 136 // Updating -------------------------------------------------------------------- |
| 134 | 137 |
| 135 void InMemoryURLIndex::DeleteURL(const GURL& url) { | 138 void InMemoryURLIndex::DeleteURL(const GURL& url) { |
| 136 private_data_->DeleteURL(url); | 139 private_data_->DeleteURL(url); |
| 137 } | 140 } |
| 138 | 141 |
| 139 void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service, | 142 void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service, |
| 140 ui::PageTransition transition, | 143 ui::PageTransition transition, |
| (...skipping 183 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 |