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

Unified Diff: chrome/browser/safe_browsing/browser_feature_extractor.cc

Issue 330703005: Revert of Change HistoryService::QueryURL to use CancelableTaskTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/safe_browsing/browser_feature_extractor.cc
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc
index 2ef679b14c575d0cfbf2cf43b8937e5a3d8ac894..8d0bd73577bf5b4cf6d8b1f6e26d56e607fae5fa 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc
@@ -323,31 +323,30 @@
callback.Run(false, request);
return;
}
- // HistoryService::QueryURL migrated from CancelableRequestComsumer to
- // CancelableRequestTracker and there is no Handle to associate to the
- // request. Instead manage the request object lifetime by using a scoped_ptr
- // and using base::Passed(). So if the asynchronous call is canceled, the
- // request is deleted, otherwise the callback becomes the owner.
- scoped_ptr<ClientPhishingRequest> owned_request(request);
- history->QueryURL(GURL(request->url()),
- true /* wants_visits */,
- base::Bind(&BrowserFeatureExtractor::QueryUrlHistoryDone,
- base::Unretained(this),
- base::Passed(&owned_request),
- callback),
- &cancelable_task_tracker_);
+ CancelableRequestProvider::Handle handle = history->QueryURL(
+ GURL(request->url()),
+ true /* wants_visits */,
+ &request_consumer_,
+ base::Bind(&BrowserFeatureExtractor::QueryUrlHistoryDone,
+ base::Unretained(this)));
+
+ StorePendingQuery(handle, request, callback);
}
void BrowserFeatureExtractor::QueryUrlHistoryDone(
- scoped_ptr<ClientPhishingRequest> owned_request,
- const DoneCallback& callback,
+ CancelableRequestProvider::Handle handle,
bool success,
- const history::URLRow& row,
- const history::VisitVector& visits) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(owned_request);
+ const history::URLRow* row,
+ history::VisitVector* visits) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ ClientPhishingRequest* request;
+ DoneCallback callback;
+ if (!GetPendingQuery(handle, &request, &callback)) {
+ DLOG(FATAL) << "No pending history query found";
+ return;
+ }
+ DCHECK(request);
DCHECK(!callback.is_null());
- ClientPhishingRequest* request = owned_request.release();
if (!success) {
// URL is not found in the history. In practice this should not
// happen (unless there is a real error) because we just visited
@@ -356,16 +355,15 @@
return;
}
AddFeature(features::kUrlHistoryVisitCount,
- static_cast<double>(row.visit_count()),
+ static_cast<double>(row->visit_count()),
request);
base::Time threshold = base::Time::Now() - base::TimeDelta::FromDays(1);
int num_visits_24h_ago = 0;
int num_visits_typed = 0;
int num_visits_link = 0;
- for (history::VisitVector::const_iterator it = visits.begin();
- it != visits.end();
- ++it) {
+ for (history::VisitVector::const_iterator it = visits->begin();
+ it != visits->end(); ++it) {
if (!content::PageTransitionIsMainFrame(it->transition)) {
continue;
}

Powered by Google App Engine
This is Rietveld 408576698