| 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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: | 85 InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: |
| 86 ~RebuildPrivateDataFromHistoryDBTask() { | 86 ~RebuildPrivateDataFromHistoryDBTask() { |
| 87 } | 87 } |
| 88 | 88 |
| 89 // InMemoryURLIndex ------------------------------------------------------------ | 89 // InMemoryURLIndex ------------------------------------------------------------ |
| 90 | 90 |
| 91 InMemoryURLIndex::InMemoryURLIndex(Profile* profile, | 91 InMemoryURLIndex::InMemoryURLIndex(Profile* profile, |
| 92 const base::FilePath& history_dir, | 92 const base::FilePath& history_dir, |
| 93 const std::string& languages) | 93 const std::string& languages, |
| 94 HistoryClient* history_client) |
| 94 : profile_(profile), | 95 : profile_(profile), |
| 96 history_client_(history_client), |
| 95 history_dir_(history_dir), | 97 history_dir_(history_dir), |
| 96 languages_(languages), | 98 languages_(languages), |
| 97 private_data_(new URLIndexPrivateData), | 99 private_data_(new URLIndexPrivateData), |
| 98 restore_cache_observer_(NULL), | 100 restore_cache_observer_(NULL), |
| 99 save_cache_observer_(NULL), | 101 save_cache_observer_(NULL), |
| 100 shutdown_(false), | 102 shutdown_(false), |
| 101 restored_(false), | 103 restored_(false), |
| 102 needs_to_be_cached_(false) { | 104 needs_to_be_cached_(false) { |
| 103 InitializeSchemeWhitelist(&scheme_whitelist_); | 105 InitializeSchemeWhitelist(&scheme_whitelist_); |
| 104 if (profile) { | 106 if (profile) { |
| 105 // TODO(mrossetti): Register for language change notifications. | 107 // TODO(mrossetti): Register for language change notifications. |
| 106 content::Source<Profile> source(profile); | 108 content::Source<Profile> source(profile); |
| 107 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, source); | 109 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, source); |
| 108 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 110 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 109 source); | 111 source); |
| 110 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source); | 112 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source); |
| 111 } | 113 } |
| 112 } | 114 } |
| 113 | 115 |
| 114 // Called only by unit tests. | 116 // Called only by unit tests. |
| 115 InMemoryURLIndex::InMemoryURLIndex() | 117 InMemoryURLIndex::InMemoryURLIndex() |
| 116 : profile_(NULL), | 118 : profile_(NULL), |
| 119 history_client_(NULL), |
| 117 private_data_(new URLIndexPrivateData), | 120 private_data_(new URLIndexPrivateData), |
| 118 restore_cache_observer_(NULL), | 121 restore_cache_observer_(NULL), |
| 119 save_cache_observer_(NULL), | 122 save_cache_observer_(NULL), |
| 120 shutdown_(false), | 123 shutdown_(false), |
| 121 restored_(false), | 124 restored_(false), |
| 122 needs_to_be_cached_(false) { | 125 needs_to_be_cached_(false) { |
| 123 InitializeSchemeWhitelist(&scheme_whitelist_); | 126 InitializeSchemeWhitelist(&scheme_whitelist_); |
| 124 } | 127 } |
| 125 | 128 |
| 126 InMemoryURLIndex::~InMemoryURLIndex() { | 129 InMemoryURLIndex::~InMemoryURLIndex() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 163 |
| 161 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( | 164 ScoredHistoryMatches InMemoryURLIndex::HistoryItemsForTerms( |
| 162 const base::string16& term_string, | 165 const base::string16& term_string, |
| 163 size_t cursor_position, | 166 size_t cursor_position, |
| 164 size_t max_matches) { | 167 size_t max_matches) { |
| 165 return private_data_->HistoryItemsForTerms( | 168 return private_data_->HistoryItemsForTerms( |
| 166 term_string, | 169 term_string, |
| 167 cursor_position, | 170 cursor_position, |
| 168 max_matches, | 171 max_matches, |
| 169 languages_, | 172 languages_, |
| 170 BookmarkModelFactory::GetForProfile(profile_)); | 173 history_client_); |
| 171 } | 174 } |
| 172 | 175 |
| 173 // Updating -------------------------------------------------------------------- | 176 // Updating -------------------------------------------------------------------- |
| 174 | 177 |
| 175 void InMemoryURLIndex::DeleteURL(const GURL& url) { | 178 void InMemoryURLIndex::DeleteURL(const GURL& url) { |
| 176 private_data_->DeleteURL(url); | 179 private_data_->DeleteURL(url); |
| 177 } | 180 } |
| 178 | 181 |
| 179 void InMemoryURLIndex::Observe(int notification_type, | 182 void InMemoryURLIndex::Observe(int notification_type, |
| 180 const content::NotificationSource& source, | 183 const content::NotificationSource& source, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 base::Bind(DeleteCacheFile, path)); | 343 base::Bind(DeleteCacheFile, path)); |
| 341 } | 344 } |
| 342 } | 345 } |
| 343 | 346 |
| 344 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 347 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
| 345 if (save_cache_observer_) | 348 if (save_cache_observer_) |
| 346 save_cache_observer_->OnCacheSaveFinished(succeeded); | 349 save_cache_observer_->OnCacheSaveFinished(succeeded); |
| 347 } | 350 } |
| 348 | 351 |
| 349 } // namespace history | 352 } // namespace history |
| OLD | NEW |