| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_data_model.h" | 5 #include "components/autofill/core/browser/autofill_data_model.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "components/autofill/core/browser/autofill_type.h" | 9 #include "components/autofill/core/browser/autofill_type.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 11 | 11 |
| 12 namespace autofill { | 12 namespace autofill { |
| 13 | 13 |
| 14 AutofillDataModel::AutofillDataModel(const std::string& guid, | 14 AutofillDataModel::AutofillDataModel(const std::string& guid, |
| 15 const std::string& origin) | 15 const std::string& origin) |
| 16 : guid_(guid), origin_(origin), use_count_(0) { | 16 : guid_(guid), |
| 17 } | 17 origin_(origin), |
| 18 use_count_(1), |
| 19 use_date_(base::Time::Now()), |
| 20 modification_date_(base::Time::Now()) {} |
| 18 AutofillDataModel::~AutofillDataModel() {} | 21 AutofillDataModel::~AutofillDataModel() {} |
| 19 | 22 |
| 20 bool AutofillDataModel::IsVerified() const { | 23 bool AutofillDataModel::IsVerified() const { |
| 21 return !origin_.empty() && !GURL(origin_).is_valid(); | 24 return !origin_.empty() && !GURL(origin_).is_valid(); |
| 22 } | 25 } |
| 23 | 26 |
| 24 void AutofillDataModel::RecordUse() { | 27 void AutofillDataModel::RecordUse() { |
| 25 ++use_count_; | 28 ++use_count_; |
| 26 use_date_ = base::Time::Now(); | 29 use_date_ = base::Time::Now(); |
| 27 } | 30 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 43 | 46 |
| 44 double AutofillDataModel::GetFrecencyScore(base::Time time) const { | 47 double AutofillDataModel::GetFrecencyScore(base::Time time) const { |
| 45 // The formula calculates a score based on both the frequency and the recency | 48 // The formula calculates a score based on both the frequency and the recency |
| 46 // of the profile and leveraging the properties of the logarithmic function. | 49 // of the profile and leveraging the properties of the logarithmic function. |
| 47 // DaysSinceLastUse() and |use_count_| are offset because their minimum values | 50 // DaysSinceLastUse() and |use_count_| are offset because their minimum values |
| 48 // are respectively 0 and 1 but the formula requires at least a value of 2. | 51 // are respectively 0 and 1 but the formula requires at least a value of 2. |
| 49 return -log((time - use_date_).InDays() + 2) / log(use_count_ + 1); | 52 return -log((time - use_date_).InDays() + 2) / log(use_count_ + 1); |
| 50 } | 53 } |
| 51 | 54 |
| 52 } // namespace autofill | 55 } // namespace autofill |
| OLD | NEW |