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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/api/bookmarks/bookmark_service.h" | 9 #include "chrome/browser/api/bookmarks/bookmark_service.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } else if (profile_) { | 251 } else if (profile_) { |
252 // When unable to restore from the cache file delete the cache file, if | 252 // When unable to restore from the cache file delete the cache file, if |
253 // it exists, and then rebuild from the history database if it's available, | 253 // it exists, and then rebuild from the history database if it's available, |
254 // otherwise wait until the history database loaded and then rebuild. | 254 // otherwise wait until the history database loaded and then rebuild. |
255 FilePath path; | 255 FilePath path; |
256 if (!GetCacheFilePath(&path) || shutdown_) | 256 if (!GetCacheFilePath(&path) || shutdown_) |
257 return; | 257 return; |
258 content::BrowserThread::PostBlockingPoolTask( | 258 content::BrowserThread::PostBlockingPoolTask( |
259 FROM_HERE, base::Bind(DeleteCacheFile, path)); | 259 FROM_HERE, base::Bind(DeleteCacheFile, path)); |
260 HistoryService* service = | 260 HistoryService* service = |
261 HistoryServiceFactory::GetForProfileWithoutCreating(profile_); | 261 HistoryServiceFactory::GetForProfileWithoutCreating(profile_).get(); |
262 if (service && service->backend_loaded()) { | 262 if (service && service->backend_loaded()) { |
263 ScheduleRebuildFromHistory(); | 263 ScheduleRebuildFromHistory(); |
264 } else { | 264 } else { |
265 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_LOADED, | 265 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_LOADED, |
266 content::Source<Profile>(profile_)); | 266 content::Source<Profile>(profile_)); |
267 } | 267 } |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 // Restoring from the History DB ----------------------------------------------- | 271 // Restoring from the History DB ----------------------------------------------- |
272 | 272 |
273 void InMemoryURLIndex::ScheduleRebuildFromHistory() { | 273 void InMemoryURLIndex::ScheduleRebuildFromHistory() { |
274 HistoryService* service = | 274 HistoryService* service = |
275 HistoryServiceFactory::GetForProfile(profile_, | 275 HistoryServiceFactory::GetForProfile(profile_, |
276 Profile::EXPLICIT_ACCESS); | 276 Profile::EXPLICIT_ACCESS).get(); |
277 service->ScheduleDBTask( | 277 service->ScheduleDBTask( |
278 new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask( | 278 new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask( |
279 this, languages_, scheme_whitelist_), | 279 this, languages_, scheme_whitelist_), |
280 &cache_reader_consumer_); | 280 &cache_reader_consumer_); |
281 } | 281 } |
282 | 282 |
283 void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB( | 283 void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB( |
284 bool succeeded, | 284 bool succeeded, |
285 scoped_refptr<URLIndexPrivateData> private_data) { | 285 scoped_refptr<URLIndexPrivateData> private_data) { |
286 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 286 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 base::Bind(DeleteCacheFile, path)); | 328 base::Bind(DeleteCacheFile, path)); |
329 } | 329 } |
330 } | 330 } |
331 | 331 |
332 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 332 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
333 if (save_cache_observer_) | 333 if (save_cache_observer_) |
334 save_cache_observer_->OnCacheSaveFinished(succeeded); | 334 save_cache_observer_->OnCacheSaveFinished(succeeded); |
335 } | 335 } |
336 | 336 |
337 } // namespace history | 337 } // namespace history |
OLD | NEW |