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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier.cc

Issue 1167163002: chrome: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing message_loop.h includes. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/safe_browsing/phishing_classifier.h" 5 #include "chrome/renderer/safe_browsing/phishing_classifier.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/thread_task_runner_handle.h"
16 #include "chrome/common/safe_browsing/csd.pb.h" 18 #include "chrome/common/safe_browsing/csd.pb.h"
17 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
18 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" 20 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h"
19 #include "chrome/renderer/safe_browsing/features.h" 21 #include "chrome/renderer/safe_browsing/features.h"
20 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" 22 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h"
21 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" 23 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h"
22 #include "chrome/renderer/safe_browsing/phishing_url_feature_extractor.h" 24 #include "chrome/renderer/safe_browsing/phishing_url_feature_extractor.h"
23 #include "chrome/renderer/safe_browsing/scorer.h" 25 #include "chrome/renderer/safe_browsing/scorer.h"
24 #include "content/public/renderer/render_view.h" 26 #include "content/public/renderer/render_view.h"
25 #include "crypto/sha2.h" 27 #include "crypto/sha2.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // classification so that we can start in a known state. 93 // classification so that we can start in a known state.
92 CancelPendingClassification(); 94 CancelPendingClassification();
93 95
94 page_text_ = page_text; 96 page_text_ = page_text;
95 done_callback_ = done_callback; 97 done_callback_ = done_callback;
96 98
97 // For consistency, we always want to invoke the DoneCallback 99 // For consistency, we always want to invoke the DoneCallback
98 // asynchronously, rather than directly from this method. To ensure that 100 // asynchronously, rather than directly from this method. To ensure that
99 // this is the case, post a task to begin feature extraction on the next 101 // this is the case, post a task to begin feature extraction on the next
100 // iteration of the message loop. 102 // iteration of the message loop.
101 base::MessageLoop::current()->PostTask( 103 base::ThreadTaskRunnerHandle::Get()->PostTask(
102 FROM_HERE, 104 FROM_HERE, base::Bind(&PhishingClassifier::BeginFeatureExtraction,
103 base::Bind(&PhishingClassifier::BeginFeatureExtraction, 105 weak_factory_.GetWeakPtr()));
104 weak_factory_.GetWeakPtr()));
105 } 106 }
106 107
107 void PhishingClassifier::BeginFeatureExtraction() { 108 void PhishingClassifier::BeginFeatureExtraction() {
108 blink::WebView* web_view = render_view_->GetWebView(); 109 blink::WebView* web_view = render_view_->GetWebView();
109 if (!web_view) { 110 if (!web_view) {
110 RunFailureCallback(); 111 RunFailureCallback();
111 return; 112 return;
112 } 113 }
113 114
114 blink::WebFrame* frame = web_view->mainFrame(); 115 blink::WebFrame* frame = web_view->mainFrame();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 242 }
242 243
243 void PhishingClassifier::Clear() { 244 void PhishingClassifier::Clear() {
244 page_text_ = NULL; 245 page_text_ = NULL;
245 done_callback_.Reset(); 246 done_callback_.Reset();
246 features_.reset(NULL); 247 features_.reset(NULL);
247 shingle_hashes_.reset(NULL); 248 shingle_hashes_.reset(NULL);
248 } 249 }
249 250
250 } // namespace safe_browsing 251 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698