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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void InMemoryURLIndex::OnHistoryServiceLoaded( | 201 void InMemoryURLIndex::OnHistoryServiceLoaded( |
202 history::HistoryService* history_service) { | 202 history::HistoryService* history_service) { |
203 if (listen_to_history_service_loaded_) | 203 if (listen_to_history_service_loaded_) |
204 ScheduleRebuildFromHistory(); | 204 ScheduleRebuildFromHistory(); |
205 listen_to_history_service_loaded_ = false; | 205 listen_to_history_service_loaded_ = false; |
206 } | 206 } |
207 | 207 |
208 // Restoring from Cache -------------------------------------------------------- | 208 // Restoring from Cache -------------------------------------------------------- |
209 | 209 |
210 void InMemoryURLIndex::PostRestoreFromCacheFileTask() { | 210 void InMemoryURLIndex::PostRestoreFromCacheFileTask() { |
211 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 211 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
212 TRACE_EVENT0("browser", "InMemoryURLIndex::PostRestoreFromCacheFileTask"); | 212 TRACE_EVENT0("browser", "InMemoryURLIndex::PostRestoreFromCacheFileTask"); |
213 | 213 |
214 base::FilePath path; | 214 base::FilePath path; |
215 if (!GetCacheFilePath(&path) || shutdown_) { | 215 if (!GetCacheFilePath(&path) || shutdown_) { |
216 restored_ = true; | 216 restored_ = true; |
217 if (restore_cache_observer_) | 217 if (restore_cache_observer_) |
218 restore_cache_observer_->OnCacheRestoreFinished(false); | 218 restore_cache_observer_->OnCacheRestoreFinished(false); |
219 return; | 219 return; |
220 } | 220 } |
221 | 221 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 history_service_->ScheduleDBTask( | 279 history_service_->ScheduleDBTask( |
280 scoped_ptr<history::HistoryDBTask>( | 280 scoped_ptr<history::HistoryDBTask>( |
281 new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask( | 281 new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask( |
282 this, languages_, scheme_whitelist_)), | 282 this, languages_, scheme_whitelist_)), |
283 &cache_reader_tracker_); | 283 &cache_reader_tracker_); |
284 } | 284 } |
285 | 285 |
286 void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB( | 286 void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB( |
287 bool succeeded, | 287 bool succeeded, |
288 scoped_refptr<URLIndexPrivateData> private_data) { | 288 scoped_refptr<URLIndexPrivateData> private_data) { |
289 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 289 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
290 if (succeeded) { | 290 if (succeeded) { |
291 private_data_tracker_.TryCancelAll(); | 291 private_data_tracker_.TryCancelAll(); |
292 private_data_ = private_data; | 292 private_data_ = private_data; |
293 PostSaveToCacheFileTask(); // Cache the newly rebuilt index. | 293 PostSaveToCacheFileTask(); // Cache the newly rebuilt index. |
294 } else { | 294 } else { |
295 private_data_->Clear(); // Dump the old private data. | 295 private_data_->Clear(); // Dump the old private data. |
296 // There is no need to do anything with the cache file as it was deleted | 296 // There is no need to do anything with the cache file as it was deleted |
297 // when the rebuild from the history operation was kicked off. | 297 // when the rebuild from the history operation was kicked off. |
298 } | 298 } |
299 restored_ = true; | 299 restored_ = true; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } else { | 331 } else { |
332 // If there is no data in our index then delete any existing cache file. | 332 // If there is no data in our index then delete any existing cache file. |
333 task_runner_->PostTask(FROM_HERE, base::Bind(DeleteCacheFile, path)); | 333 task_runner_->PostTask(FROM_HERE, base::Bind(DeleteCacheFile, path)); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 337 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
338 if (save_cache_observer_) | 338 if (save_cache_observer_) |
339 save_cache_observer_->OnCacheSaveFinished(succeeded); | 339 save_cache_observer_->OnCacheSaveFinished(succeeded); |
340 } | 340 } |
OLD | NEW |