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

Side by Side Diff: chrome/browser/safe_browsing/browser_feature_extractor.h

Issue 314293005: Change HistoryService::QueryURL to use CancelableTaskTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and add comment for scoped_ptr usage 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 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 // BrowserFeatureExtractor computes various browser features for client-side 5 // BrowserFeatureExtractor computes various browser features for client-side
6 // phishing detection. For now it does a bunch of lookups in the history 6 // phishing detection. For now it does a bunch of lookups in the history
7 // service to see whether a particular URL has been visited before by the 7 // service to see whether a particular URL has been visited before by the
8 // user. 8 // user.
9 9
10 #ifndef CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ 10 #ifndef CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_
11 #define CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ 11 #define CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_
12 12
13 #include <map> 13 #include <map>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/basictypes.h" 19 #include "base/basictypes.h"
20 #include "base/callback.h" 20 #include "base/callback.h"
21 #include "base/containers/hash_tables.h" 21 #include "base/containers/hash_tables.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "base/sequenced_task_runner_helpers.h" 23 #include "base/sequenced_task_runner_helpers.h"
24 #include "base/task/cancelable_task_tracker.h"
24 #include "base/time/time.h" 25 #include "base/time/time.h"
25 #include "chrome/browser/common/cancelable_request.h" 26 #include "chrome/browser/common/cancelable_request.h"
26 #include "chrome/browser/history/history_types.h" 27 #include "chrome/browser/history/history_types.h"
27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 28 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
28 #include "chrome/browser/safe_browsing/ui_manager.h" 29 #include "chrome/browser/safe_browsing/ui_manager.h"
29 #include "url/gurl.h" 30 #include "url/gurl.h"
30 #include "webkit/common/resource_type.h" 31 #include "webkit/common/resource_type.h"
31 32
32 33
33 class HistoryService; 34 class HistoryService;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Synchronous browser feature extraction. 138 // Synchronous browser feature extraction.
138 void ExtractBrowseInfoFeatures(const BrowseInfo& info, 139 void ExtractBrowseInfoFeatures(const BrowseInfo& info,
139 ClientPhishingRequest* request); 140 ClientPhishingRequest* request);
140 141
141 // Actually starts feature extraction (does the real work). 142 // Actually starts feature extraction (does the real work).
142 void StartExtractFeatures(ClientPhishingRequest* request, 143 void StartExtractFeatures(ClientPhishingRequest* request,
143 const DoneCallback& callback); 144 const DoneCallback& callback);
144 145
145 // HistoryService callback which is called when we're done querying URL visits 146 // HistoryService callback which is called when we're done querying URL visits
146 // in the history. 147 // in the history.
147 void QueryUrlHistoryDone(CancelableRequestProvider::Handle handle, 148 void QueryUrlHistoryDone(scoped_ptr<ClientPhishingRequest> request,
149 const DoneCallback& callback,
148 bool success, 150 bool success,
149 const history::URLRow* row, 151 const history::URLRow& row,
150 history::VisitVector* visits); 152 const history::VisitVector& visits);
151 153
152 // HistoryService callback which is called when we're done querying HTTP host 154 // HistoryService callback which is called when we're done querying HTTP host
153 // visits in the history. 155 // visits in the history.
154 void QueryHttpHostVisitsDone(CancelableRequestProvider::Handle handle, 156 void QueryHttpHostVisitsDone(CancelableRequestProvider::Handle handle,
155 bool success, 157 bool success,
156 int num_visits, 158 int num_visits,
157 base::Time first_visit); 159 base::Time first_visit);
158 160
159 // HistoryService callback which is called when we're done querying HTTPS host 161 // HistoryService callback which is called when we're done querying HTTPS host
160 // visits in the history. 162 // visits in the history.
(...skipping 30 matching lines...) Expand all
191 193
192 // Helper function which is called when we're done filtering out benign IPs 194 // Helper function which is called when we're done filtering out benign IPs
193 // on the IO thread. This function is called on the UI thread. 195 // on the IO thread. This function is called on the UI thread.
194 void FinishExtractMalwareFeatures(scoped_ptr<IPUrlMap> bad_ips, 196 void FinishExtractMalwareFeatures(scoped_ptr<IPUrlMap> bad_ips,
195 MalwareDoneCallback callback, 197 MalwareDoneCallback callback,
196 scoped_ptr<ClientMalwareRequest> request); 198 scoped_ptr<ClientMalwareRequest> request);
197 199
198 content::WebContents* tab_; 200 content::WebContents* tab_;
199 ClientSideDetectionHost* host_; 201 ClientSideDetectionHost* host_;
200 CancelableRequestConsumer request_consumer_; 202 CancelableRequestConsumer request_consumer_;
203 base::CancelableTaskTracker cancelable_task_tracker_;
201 base::WeakPtrFactory<BrowserFeatureExtractor> weak_factory_; 204 base::WeakPtrFactory<BrowserFeatureExtractor> weak_factory_;
202 205
203 // Set of pending extractions (i.e. extractions for which ExtractFeatures was 206 // Set of pending extractions (i.e. extractions for which ExtractFeatures was
204 // called but not StartExtractFeatures). 207 // called but not StartExtractFeatures).
205 std::map<ClientPhishingRequest*, DoneCallback> pending_extractions_; 208 std::map<ClientPhishingRequest*, DoneCallback> pending_extractions_;
206 209
207 // Set of pending queries (i.e., where history->Query...() was called but 210 // Set of pending queries (i.e., where history->Query...() was called but
208 // the history callback hasn't been invoked yet). 211 // the history callback hasn't been invoked yet).
209 PendingQueriesMap pending_queries_; 212 PendingQueriesMap pending_queries_;
210 213
211 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); 214 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor);
212 }; 215 };
213 216
214 } // namespace safe_browsing 217 } // namespace safe_browsing
215 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ 218 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698