Chromium Code Reviews| 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..e6ef6de2110a32e47df7a1d955e886810f3378f4 100644 |
| --- a/chrome/browser/webdata/autofill_entry.cc |
| +++ b/chrome/browser/webdata/autofill_entry.cc |
| @@ -1,12 +1,12 @@ |
| // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // 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" |
| AutofillKey::AutofillKey() {} |
| @@ -72,7 +72,14 @@ bool AutofillEntry::operator<(const AutofillEntry& entry) const { |
| return key_ < entry.key(); |
| } |
| -// Culls the list of timestamps to the most recent |kMaxAutofillTimeStamps|. |
| +bool AutofillEntry::LastAccessOlder(base::Time time) const { |
| + if (timestamps_.empty() || timestamps_.back() < time) |
|
Ilya Sherman
2012/03/15 21:00:41
nit: Can we DCHECK(!timestamps_.empty()), or is th
GeorgeY
2012/03/17 00:36:16
Done.
|
| + return true; |
| + return false; |
|
Ilya Sherman
2012/03/15 21:00:41
nit: This implementation can be collapsed to "retu
GeorgeY
2012/03/17 00:36:16
Done.
|
| +} |
| + |
| + |
| +// 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 |
| @@ -85,24 +92,21 @@ bool AutofillEntry::operator<(const AutofillEntry& entry) const { |
| // 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; |
| + } |
| + result->push_back(source.front()); |
| + result->push_back(source.back()); |
|
Ilya Sherman
2012/03/15 21:00:41
Just to make sure, are the timestamps guaranteed t
GeorgeY
2012/03/17 00:36:16
Done.
|
| VLOG(1) << "Culling timestamps. Current count is : " << source.size(); |
|
Ilya Sherman
2012/03/15 21:00:41
nit: DVLOG?
GeorgeY
2012/03/17 00:36:16
Done.
|
| - // 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->erase(result->begin() + kMaxAutofillTimeStamps, result->end()); |
| - |
| return true; |
| } |