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

Unified Diff: chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h

Issue 3130039: Limit the time spent on a single iteration of PhishingDOMFeatureExtractor. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: tiny comment fix Created 10 years, 4 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/renderer/safe_browsing/phishing_dom_feature_extractor.h
diff --git a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h
index bc9d5996aa2ea7d8632510af4536aa3f846c4cb8..ef0e42e969272f40a33748827b959ee6cd9040fa 100644
--- a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h
+++ b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h
@@ -26,6 +26,7 @@ class WebFrame;
}
namespace safe_browsing {
+class FeatureExtractorClock;
class FeatureMap;
class PhishingDOMFeatureExtractor {
@@ -36,8 +37,11 @@ class PhishingDOMFeatureExtractor {
// Creates a PhishingDOMFeatureExtractor for the specified RenderView.
// The PhishingDOMFeatureExtrator should be destroyed prior to destroying
- // the RenderView.
- explicit PhishingDOMFeatureExtractor(RenderView* render_view);
+ // the RenderView. |clock| is used for timing feature extractor operations,
+ // and may be mocked for testing. PhishingDOMFeatureExtractor takes
+ // ownership of the clock.
+ PhishingDOMFeatureExtractor(RenderView* render_view,
+ FeatureExtractorClock* clock);
~PhishingDOMFeatureExtractor();
// Begins extracting features into the given FeatureMap for the page
@@ -57,6 +61,19 @@ class PhishingDOMFeatureExtractor {
struct FrameData;
struct PageFeatureState;
+ // The maximum amount of time that we will spend on a single extraction
+ // iteration before pausing to let other MessageLoop tasks run.
+ static const int kMaxTimePerChunkMs;
+
+ // The number of elements that we will process before checking to see whether
+ // kMaxTimePerChunkMs has elapsed. Since checking the current time can be
+ // slow, we don't do this on every element processed.
+ static const int kClockCheckGranularity;
+
+ // The maximum total amount of time that the feature extractor will run
+ // before giving up on the current page.
+ static const int kMaxTotalTimeMs;
+
// Does the actual work of ExtractFeatures. ExtractFeaturesWithTimeout runs
// until a predefined maximum amount of time has elapsed, then posts a task
// to the current MessageLoop to continue extraction. When extraction
@@ -101,6 +118,9 @@ class PhishingDOMFeatureExtractor {
// Non-owned pointer to the view that we will extract features from.
RenderView* render_view_;
+ // Owned pointer to our clock.
+ scoped_ptr<FeatureExtractorClock> clock_;
+
// The output parameters from the most recent call to ExtractFeatures().
FeatureMap* features_; // The caller keeps ownership of this.
scoped_ptr<DoneCallback> done_callback_;

Powered by Google App Engine
This is Rietveld 408576698