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

Unified Diff: chrome/browser/history/android/android_history_provider_service.cc

Issue 368283003: Change AndroidHistoryProviderService to use CancelableTaskTracker (5/6) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cancelable_task_tracker.5
Patch Set: Fix unit tests Created 6 years, 5 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/android/android_history_provider_service.cc
diff --git a/chrome/browser/history/android/android_history_provider_service.cc b/chrome/browser/history/android/android_history_provider_service.cc
index e008b54679b2ac36f1715af5c49b2f18fbbcdc04..5c1d0d88aa5761a68e5217730120989a3ce89dfd 100644
--- a/chrome/browser/history/android/android_history_provider_service.cc
+++ b/chrome/browser/history/android/android_history_provider_service.cc
@@ -47,25 +47,31 @@ AndroidHistoryProviderService::QueryHistoryAndBookmarks(
}
}
-AndroidHistoryProviderService::Handle
+base::CancelableTaskTracker::TaskId
AndroidHistoryProviderService::UpdateHistoryAndBookmarks(
const history::HistoryAndBookmarkRow& row,
const std::string& selection,
const std::vector<base::string16>& selection_args,
- CancelableRequestConsumerBase* consumer,
- const UpdateCallback& callback) {
- UpdateRequest* request = new UpdateRequest(callback);
- AddRequest(request, consumer);
+ const UpdateCallback& callback,
+ base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
if (hs) {
- hs->Schedule(HistoryService::PRIORITY_NORMAL,
- &HistoryBackend::UpdateHistoryAndBookmarks, NULL, request, row,
- selection, selection_args);
+ DCHECK(hs->thread_) << "History service being called after cleanup";
+ DCHECK(hs->thread_checker_.CalledOnValidThread());
+ return tracker->PostTaskAndReplyWithResult(
+ hs->thread_->message_loop_proxy().get(),
+ FROM_HERE,
+ base::Bind(&HistoryBackend::UpdateHistoryAndBookmarks,
+ hs->history_backend_.get(),
+ row,
+ selection,
+ selection_args),
+ callback);
} else {
- request->ForwardResultAsync(request->handle(), false, 0);
+ callback.Run(0);
+ return base::CancelableTaskTracker::kBadTaskId;
}
- return request->handle();
}
AndroidHistoryProviderService::Handle
@@ -192,25 +198,31 @@ AndroidHistoryProviderService::InsertSearchTerm(
}
}
-AndroidHistoryProviderService::Handle
+base::CancelableTaskTracker::TaskId
AndroidHistoryProviderService::UpdateSearchTerms(
const history::SearchRow& row,
const std::string& selection,
const std::vector<base::string16>& selection_args,
- CancelableRequestConsumerBase* consumer,
- const UpdateCallback& callback) {
- UpdateRequest* request = new UpdateRequest(callback);
- AddRequest(request, consumer);
+ const UpdateCallback& callback,
+ base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
if (hs) {
- hs->Schedule(HistoryService::PRIORITY_NORMAL,
- &HistoryBackend::UpdateSearchTerms, NULL, request, row, selection,
- selection_args);
+ DCHECK(hs->thread_) << "History service being called after cleanup";
+ DCHECK(hs->thread_checker_.CalledOnValidThread());
+ return tracker->PostTaskAndReplyWithResult(
+ hs->thread_->message_loop_proxy().get(),
+ FROM_HERE,
+ base::Bind(&HistoryBackend::UpdateSearchTerms,
+ hs->history_backend_.get(),
+ row,
+ selection,
+ selection_args),
+ callback);
} else {
- request->ForwardResultAsync(request->handle(), false, 0);
+ callback.Run(0);
+ return base::CancelableTaskTracker::kBadTaskId;
}
- return request->handle();
}
AndroidHistoryProviderService::Handle

Powered by Google App Engine
This is Rietveld 408576698