| Index: chrome/browser/webdata/autofill_entry.cc
|
| diff --git a/chrome/browser/webdata/autofill_entry.cc b/chrome/browser/webdata/autofill_entry.cc
|
| index fe874a58cd8c4da8be15155a99f5e15ed43ace29..76d28048f3310b173dd58a751f92412339eb76ad 100644
|
| --- a/chrome/browser/webdata/autofill_entry.cc
|
| +++ b/chrome/browser/webdata/autofill_entry.cc
|
| @@ -2,13 +2,21 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/webdata/autofill_entry.h"
|
| +
|
| #include <algorithm>
|
| #include <set>
|
|
|
| #include "base/logging.h"
|
| -#include "chrome/browser/webdata/autofill_entry.h"
|
| #include "base/utf_string_conversions.h"
|
|
|
| +namespace {
|
| +
|
| +// The period after which Autofill entries should expire in days.
|
| +const int64 kExpirationPeriodInDays = 60;
|
| +
|
| +} // namespace
|
| +
|
| AutofillKey::AutofillKey() {}
|
|
|
| AutofillKey::AutofillKey(const string16& name, const string16& value)
|
| @@ -72,7 +80,19 @@ bool AutofillEntry::operator<(const AutofillEntry& entry) const {
|
| return key_ < entry.key();
|
| }
|
|
|
| -// Culls the list of timestamps to the most recent |kMaxAutofillTimeStamps|.
|
| +bool AutofillEntry::IsExpired() const {
|
| + base::Time time = ExpirationTime();
|
| + // TODO(georgey): add DCHECK(!timestamps_.empty()) after conversion of the db
|
| + // is complete.
|
| + return (timestamps_.empty() || timestamps_.back() < time);
|
| +}
|
| +
|
| +// static
|
| +base::Time AutofillEntry::ExpirationTime() {
|
| + return base::Time::Now() - base::TimeDelta::FromDays(kExpirationPeriodInDays);
|
| +}
|
| +
|
| +// Culls the list of timestamps to the first and last used.
|
| // If sync is enabled, at every browser restart, sync will do a match up of all
|
| // autofill items on the server with all items on the web db. When webdb loads
|
| // all the items in memory(for sync to process. The method is
|
| @@ -83,26 +103,23 @@ bool AutofillEntry::operator<(const AutofillEntry& entry) const {
|
| // restart. But sync when uploading to the server will only upload this culled
|
| // list. Meaning until restart there will be mis-match in timestamps but
|
| // it should correct itself at startup.
|
| -// Also if sync is not enabled this culling would never take place.
|
| bool AutofillEntry::CullTimeStamps(const std::vector<base::Time>& source,
|
| - std::vector<base::Time>* result) {
|
| + std::vector<base::Time>* result) {
|
| DCHECK(result);
|
| DCHECK(&source != result);
|
|
|
| // First copy the source to result.
|
| result->clear();
|
| - result->insert(result->begin(), source.begin(), source.end());
|
|
|
| - if (source.size() <= kMaxAutofillTimeStamps)
|
| + if (source.size() <= 2) {
|
| + result->insert(result->begin(), source.begin(), source.end());
|
| return false;
|
| + }
|
|
|
| - VLOG(1) << "Culling timestamps. Current count is : " << source.size();
|
| -
|
| - // Regular sort does ascending order. So we pass in a comparator function.
|
| - partial_sort(result->begin(), result->begin() + kMaxAutofillTimeStamps,
|
| - result->end(), std::greater<base::Time>());
|
| + result->push_back(source.front());
|
| + result->push_back(source.back());
|
|
|
| - result->erase(result->begin() + kMaxAutofillTimeStamps, result->end());
|
| + DVLOG(1) << "Culling timestamps. Current count is : " << source.size();
|
|
|
| return true;
|
| }
|
|
|