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

Unified Diff: chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc

Issue 8573018: Convert to base::Callback in safe_browsing client-side-detection code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Don't call Run() on null callbacks. Created 9 years, 1 month 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/renderer/safe_browsing/phishing_term_feature_extractor.cc
diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
index 47161b9ae400d109be685330e3a6df6e770a8fae..082f9e1023be2774b4c60211a26997802ad5363f 100644
--- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
+++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
@@ -115,7 +115,7 @@ PhishingTermFeatureExtractor::~PhishingTermFeatureExtractor() {
void PhishingTermFeatureExtractor::ExtractFeatures(
const string16* page_text,
FeatureMap* features,
- DoneCallback* done_callback) {
+ const DoneCallback& done_callback) {
// The RenderView should have called CancelPendingExtraction() before
// starting a new extraction, so DCHECK this.
CheckNoPendingExtraction();
@@ -125,7 +125,7 @@ void PhishingTermFeatureExtractor::ExtractFeatures(
page_text_ = page_text;
features_ = features;
- done_callback_.reset(done_callback);
+ done_callback_ = done_callback;
state_.reset(new ExtractionState(*page_text_, clock_->Now()));
MessageLoop::current()->PostTask(
@@ -277,9 +277,9 @@ void PhishingTermFeatureExtractor::HandleWord(
}
void PhishingTermFeatureExtractor::CheckNoPendingExtraction() {
- DCHECK(!done_callback_.get());
+ DCHECK(done_callback_.is_null());
DCHECK(!state_.get());
- if (done_callback_.get() || state_.get()) {
+ if (!done_callback_.is_null() || state_.get()) {
LOG(ERROR) << "Extraction in progress, missing call to "
<< "CancelPendingExtraction";
}
@@ -294,15 +294,15 @@ void PhishingTermFeatureExtractor::RunCallback(bool success) {
UMA_HISTOGRAM_TIMES("SBClientPhishing.TermFeatureTotalTime",
clock_->Now() - state_->start_time);
- DCHECK(done_callback_.get());
- done_callback_->Run(success);
+ DCHECK(!done_callback_.is_null());
+ done_callback_.Run(success);
Clear();
}
void PhishingTermFeatureExtractor::Clear() {
page_text_ = NULL;
features_ = NULL;
- done_callback_.reset(NULL);
+ done_callback_.Reset();
state_.reset(NULL);
negative_word_cache_.Clear();
}

Powered by Google App Engine
This is Rietveld 408576698