| OLD | NEW |
| 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/scorer.h" | 5 #include "chrome/renderer/safe_browsing/scorer.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 void RecordScorerCreationStatus(ScorerCreationStatus status) { | 29 void RecordScorerCreationStatus(ScorerCreationStatus status) { |
| 30 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.ScorerCreationStatus", | 30 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.ScorerCreationStatus", |
| 31 status, | 31 status, |
| 32 SCORER_STATUS_MAX); | 32 SCORER_STATUS_MAX); |
| 33 } | 33 } |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 namespace safe_browsing { | 36 namespace safe_browsing { |
| 37 | 37 |
| 38 const int Scorer::kMaxPhishingModelSizeBytes = 70 * 1024; | 38 const int Scorer::kMaxPhishingModelSizeBytes = 90 * 1024; |
| 39 | 39 |
| 40 // Helper function which converts log odds to a probability in the range | 40 // Helper function which converts log odds to a probability in the range |
| 41 // [0.0,1.0]. | 41 // [0.0,1.0]. |
| 42 static double LogOdds2Prob(double log_odds) { | 42 static double LogOdds2Prob(double log_odds) { |
| 43 // 709 = floor(1023*ln(2)). 2**1023 is the largest finite double. | 43 // 709 = floor(1023*ln(2)). 2**1023 is the largest finite double. |
| 44 // Small log odds aren't a problem. as the odds will be 0. It's only | 44 // Small log odds aren't a problem. as the odds will be 0. It's only |
| 45 // when we get +infinity for the odds, that odds/(odds+1) would be NaN. | 45 // when we get +infinity for the odds, that odds/(odds+1) would be NaN. |
| 46 if (log_odds >= 709) { | 46 if (log_odds >= 709) { |
| 47 return 1.0; | 47 return 1.0; |
| 48 } | 48 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // If the feature of the rule does not exist in the given feature map the | 188 // If the feature of the rule does not exist in the given feature map the |
| 189 // feature weight is considered to be zero. If the feature weight is zero | 189 // feature weight is considered to be zero. If the feature weight is zero |
| 190 // we leave early since we know that the rule score will be zero. | 190 // we leave early since we know that the rule score will be zero. |
| 191 return 0.0; | 191 return 0.0; |
| 192 } | 192 } |
| 193 rule_score *= it->second; | 193 rule_score *= it->second; |
| 194 } | 194 } |
| 195 return rule_score * rule.weight(); | 195 return rule_score * rule.weight(); |
| 196 } | 196 } |
| 197 } // namespace safe_browsing | 197 } // namespace safe_browsing |
| OLD | NEW |