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

Unified Diff: chrome/renderer/safe_browsing/phishing_dom_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_dom_feature_extractor.cc
diff --git a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc
index 7037754ec0f4bd5a5ad31116fdc2e494d86f3558..d1f59086d998f686439a2e146fcd74bf61408022 100644
--- a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc
+++ b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc
@@ -115,7 +115,7 @@ PhishingDOMFeatureExtractor::~PhishingDOMFeatureExtractor() {
void PhishingDOMFeatureExtractor::ExtractFeatures(
FeatureMap* features,
- DoneCallback* done_callback) {
+ const DoneCallback& done_callback) {
// The RenderView should have called CancelPendingExtraction() before
// starting a new extraction, so DCHECK this.
CheckNoPendingExtraction();
@@ -124,7 +124,7 @@ void PhishingDOMFeatureExtractor::ExtractFeatures(
CancelPendingExtraction();
features_ = features;
- done_callback_.reset(done_callback);
+ done_callback_ = done_callback;
page_feature_state_.reset(new PageFeatureState(clock_->Now()));
WebKit::WebView* web_view = render_view_->GetWebView();
@@ -348,10 +348,10 @@ void PhishingDOMFeatureExtractor::HandleScript(
}
void PhishingDOMFeatureExtractor::CheckNoPendingExtraction() {
- DCHECK(!done_callback_.get());
+ DCHECK(done_callback_.is_null());
DCHECK(!cur_frame_data_.get());
DCHECK(cur_document_.isNull());
- if (done_callback_.get() || cur_frame_data_.get() ||
+ if (!done_callback_.is_null() || cur_frame_data_.get() ||
!cur_document_.isNull()) {
LOG(ERROR) << "Extraction in progress, missing call to "
<< "CancelPendingExtraction";
@@ -367,14 +367,14 @@ void PhishingDOMFeatureExtractor::RunCallback(bool success) {
UMA_HISTOGRAM_TIMES("SBClientPhishing.DOMFeatureTotalTime",
clock_->Now() - page_feature_state_->start_time);
- DCHECK(done_callback_.get());
- done_callback_->Run(success);
+ DCHECK(!done_callback_.is_null());
+ done_callback_.Run(success);
Clear();
}
void PhishingDOMFeatureExtractor::Clear() {
features_ = NULL;
- done_callback_.reset(NULL);
+ done_callback_.Reset();
cur_frame_data_.reset(NULL);
cur_document_.reset();
}

Powered by Google App Engine
This is Rietveld 408576698