| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // PhishingDOMFeatureExtractor handles computing DOM-based features for the | 5 // PhishingDOMFeatureExtractor handles computing DOM-based features for the |
| 6 // client-side phishing detection model. These include the presence of various | 6 // client-side phishing detection model. These include the presence of various |
| 7 // types of elements, ratios of external and secure links, and tokens for | 7 // types of elements, ratios of external and secure links, and tokens for |
| 8 // external domains linked to. | 8 // external domains linked to. |
| 9 | 9 |
| 10 #ifndef CHROME_RENDERER_SAFE_BROWSING_PHISHING_DOM_FEATURE_EXTRACTOR_H_ | 10 #ifndef CHROME_RENDERER_SAFE_BROWSING_PHISHING_DOM_FEATURE_EXTRACTOR_H_ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // ownership of the clock. | 42 // ownership of the clock. |
| 43 PhishingDOMFeatureExtractor(RenderView* render_view, | 43 PhishingDOMFeatureExtractor(RenderView* render_view, |
| 44 FeatureExtractorClock* clock); | 44 FeatureExtractorClock* clock); |
| 45 ~PhishingDOMFeatureExtractor(); | 45 ~PhishingDOMFeatureExtractor(); |
| 46 | 46 |
| 47 // Begins extracting features into the given FeatureMap for the page | 47 // Begins extracting features into the given FeatureMap for the page |
| 48 // currently loaded in this object's RenderView. To avoid blocking the | 48 // currently loaded in this object's RenderView. To avoid blocking the |
| 49 // render thread for too long, the feature extractor may run in several | 49 // render thread for too long, the feature extractor may run in several |
| 50 // chunks of work, posting a task to the current MessageLoop to continue | 50 // chunks of work, posting a task to the current MessageLoop to continue |
| 51 // processing. Once feature extraction is complete, |done_callback| | 51 // processing. Once feature extraction is complete, |done_callback| |
| 52 // is run. PhishingDOMFeatureExtractor takes ownership of the callback. | 52 // is run on the current thread. PhishingDOMFeatureExtractor takes |
| 53 // ownership of the callback. |
| 53 void ExtractFeatures(FeatureMap* features, DoneCallback* done_callback); | 54 void ExtractFeatures(FeatureMap* features, DoneCallback* done_callback); |
| 54 | 55 |
| 55 // Cancels any pending feature extraction. The DoneCallback will not be run. | 56 // Cancels any pending feature extraction. The DoneCallback will not be run. |
| 56 // Must be called if there is a feature extraction in progress when the page | 57 // Must be called if there is a feature extraction in progress when the page |
| 57 // is unloaded or the PhishingDOMFeatureExtractor is destroyed. | 58 // is unloaded or the PhishingDOMFeatureExtractor is destroyed. |
| 58 void CancelPendingExtraction(); | 59 void CancelPendingExtraction(); |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 struct FrameData; | 62 struct FrameData; |
| 62 struct PageFeatureState; | 63 struct PageFeatureState; |
| 63 | 64 |
| 64 // The maximum amount of time that we will spend on a single extraction | 65 // The maximum amount of wall time that we will spend on a single extraction |
| 65 // iteration before pausing to let other MessageLoop tasks run. | 66 // iteration before pausing to let other MessageLoop tasks run. |
| 66 static const int kMaxTimePerChunkMs; | 67 static const int kMaxTimePerChunkMs; |
| 67 | 68 |
| 68 // The number of elements that we will process before checking to see whether | 69 // The number of elements that we will process before checking to see whether |
| 69 // kMaxTimePerChunkMs has elapsed. Since checking the current time can be | 70 // kMaxTimePerChunkMs has elapsed. Since checking the current time can be |
| 70 // slow, we don't do this on every element processed. | 71 // slow, we don't do this on every element processed. |
| 71 static const int kClockCheckGranularity; | 72 static const int kClockCheckGranularity; |
| 72 | 73 |
| 73 // The maximum total amount of time that the feature extractor will run | 74 // The maximum total amount of time that the feature extractor will run |
| 74 // before giving up on the current page. | 75 // before giving up on the current page. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Used to create ExtractFeaturesWithTimeout tasks. | 140 // Used to create ExtractFeaturesWithTimeout tasks. |
| 140 // These tasks are revoked if extraction is cancelled. | 141 // These tasks are revoked if extraction is cancelled. |
| 141 ScopedRunnableMethodFactory<PhishingDOMFeatureExtractor> method_factory_; | 142 ScopedRunnableMethodFactory<PhishingDOMFeatureExtractor> method_factory_; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(PhishingDOMFeatureExtractor); | 144 DISALLOW_COPY_AND_ASSIGN(PhishingDOMFeatureExtractor); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 } // namespace safe_browsing | 147 } // namespace safe_browsing |
| 147 | 148 |
| 148 #endif // CHROME_RENDERER_SAFE_BROWSING_PHISHING_DOM_FEATURE_EXTRACTOR_H_ | 149 #endif // CHROME_RENDERER_SAFE_BROWSING_PHISHING_DOM_FEATURE_EXTRACTOR_H_ |
| OLD | NEW |