| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 161 |
| 159 // Querying -------------------------------------------------------------------- | 162 // Querying -------------------------------------------------------------------- |
| 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 return private_data_->HistoryItemsForTerms( | 167 return private_data_->HistoryItemsForTerms( |
| 165 term_string, | 168 term_string, |
| 166 cursor_position, | 169 cursor_position, |
| 167 languages_, | 170 languages_, |
| 168 BookmarkModelFactory::GetForProfile(profile_)); | 171 history_client_); |
| 169 } | 172 } |
| 170 | 173 |
| 171 // Updating -------------------------------------------------------------------- | 174 // Updating -------------------------------------------------------------------- |
| 172 | 175 |
| 173 void InMemoryURLIndex::DeleteURL(const GURL& url) { | 176 void InMemoryURLIndex::DeleteURL(const GURL& url) { |
| 174 private_data_->DeleteURL(url); | 177 private_data_->DeleteURL(url); |
| 175 } | 178 } |
| 176 | 179 |
| 177 void InMemoryURLIndex::Observe(int notification_type, | 180 void InMemoryURLIndex::Observe(int notification_type, |
| 178 const content::NotificationSource& source, | 181 const content::NotificationSource& source, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 base::Bind(DeleteCacheFile, path)); | 341 base::Bind(DeleteCacheFile, path)); |
| 339 } | 342 } |
| 340 } | 343 } |
| 341 | 344 |
| 342 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 345 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
| 343 if (save_cache_observer_) | 346 if (save_cache_observer_) |
| 344 save_cache_observer_->OnCacheSaveFinished(succeeded); | 347 save_cache_observer_->OnCacheSaveFinished(succeeded); |
| 345 } | 348 } |
| 346 | 349 |
| 347 } // namespace history | 350 } // namespace history |
| OLD | NEW |