Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2271)

Unified Diff: chrome/browser/history/in_memory_url_index.cc

Issue 352913002: Port HistoryService::ScheduleDBTask to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix lifetime of base::CancelableTaskTracker for HistoryModelWorker Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/in_memory_url_index.cc
diff --git a/chrome/browser/history/in_memory_url_index.cc b/chrome/browser/history/in_memory_url_index.cc
index 13c0e9857c4f7d56ff5f8cfee29de7b85e74bd20..7d22dd9f0b2e85e41ec4f8d750922c26d4827746 100644
--- a/chrome/browser/history/in_memory_url_index.cc
+++ b/chrome/browser/history/in_memory_url_index.cc
@@ -138,12 +138,12 @@ void InMemoryURLIndex::Init() {
void InMemoryURLIndex::ShutDown() {
registrar_.RemoveAll();
- cache_reader_consumer_.CancelAllRequests();
+ cache_reader_tracker_.TryCancelAll();
shutdown_ = true;
base::FilePath path;
if (!GetCacheFilePath(&path))
return;
- private_data_->CancelPendingUpdates();
+ private_data_tracker_.TryCancelAll();
URLIndexPrivateData::WritePrivateDataToCacheFileTask(private_data_, path);
needs_to_be_cached_ = false;
}
@@ -210,8 +210,11 @@ void InMemoryURLIndex::OnURLVisited(const URLVisitedDetails* details) {
HistoryService* service =
HistoryServiceFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
- needs_to_be_cached_ |= private_data_->UpdateURL(
- service, details->row, languages_, scheme_whitelist_);
+ needs_to_be_cached_ |= private_data_->UpdateURL(service,
+ details->row,
+ languages_,
+ scheme_whitelist_,
+ &private_data_tracker_);
}
void InMemoryURLIndex::OnURLsModified(const URLsModifiedDetails* details) {
@@ -219,9 +222,11 @@ void InMemoryURLIndex::OnURLsModified(const URLsModifiedDetails* details) {
HistoryServiceFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
for (URLRows::const_iterator row = details->changed_urls.begin();
- row != details->changed_urls.end(); ++row)
- needs_to_be_cached_ |=
- private_data_->UpdateURL(service, *row, languages_, scheme_whitelist_);
+ row != details->changed_urls.end();
+ ++row) {
+ needs_to_be_cached_ |= private_data_->UpdateURL(
+ service, *row, languages_, scheme_whitelist_, &private_data_tracker_);
+ }
}
void InMemoryURLIndex::OnURLsDeleted(const URLsDeletedDetails* details) {
@@ -259,6 +264,7 @@ void InMemoryURLIndex::PostRestoreFromCacheFileTask() {
void InMemoryURLIndex::OnCacheLoadDone(
scoped_refptr<URLIndexPrivateData> private_data) {
if (private_data.get() && !private_data->Empty()) {
+ private_data_tracker_.TryCancelAll();
private_data_ = private_data;
restored_ = true;
if (restore_cache_observer_)
@@ -292,7 +298,7 @@ void InMemoryURLIndex::ScheduleRebuildFromHistory() {
service->ScheduleDBTask(
new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask(
this, languages_, scheme_whitelist_),
- &cache_reader_consumer_);
+ &cache_reader_tracker_);
}
void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB(
@@ -300,6 +306,7 @@ void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB(
scoped_refptr<URLIndexPrivateData> private_data) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (succeeded) {
+ private_data_tracker_.TryCancelAll();
private_data_ = private_data;
PostSaveToCacheFileTask(); // Cache the newly rebuilt index.
} else {
@@ -313,6 +320,7 @@ void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB(
}
void InMemoryURLIndex::RebuildFromHistory(HistoryDatabase* history_db) {
+ private_data_tracker_.TryCancelAll();
private_data_ = URLIndexPrivateData::RebuildFromHistory(history_db,
languages_,
scheme_whitelist_);
« no previous file with comments | « chrome/browser/history/in_memory_url_index.h ('k') | chrome/browser/history/in_memory_url_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698