Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4645)

Unified Diff: chrome/browser/webdata/autofill_entry.cc

Issue 9585020: Cull autofill entries older than 60 days. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and added culling when the sync is off. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0235334fe7ebc32796ac6bff7faa1b776bc8685a 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,6 +72,31 @@ bool AutofillEntry::operator<(const AutofillEntry& entry) const {
return key_ < entry.key();
}
+bool AutofillEntry::HasTimestampsOlder(base::Time time) const {
+ for (size_t i = 0; i < timestamps_.size(); ++i) {
+ if (timestamps_[i] < time)
+ return true;
+ }
+ return false;
+}
+
+bool AutofillEntry::CullExpiredTimeStamps(base::Time expire_before) {
+ std::vector<base::Time> new_timestamps;
+ new_timestamps.reserve(timestamps_.size());
+
+ for (size_t i = 0; i < timestamps_.size(); ++i) {
+ if (timestamps_[i] >= expire_before)
+ new_timestamps.push_back(timestamps_[i]);
+ }
+
+ if (timestamps_.size() == new_timestamps.size())
+ return false;
+
+ timestamps_.swap(new_timestamps);
+ timestamps_culled_ = true;
+ return true;
+}
+
// Culls the list of timestamps to the most recent |kMaxAutofillTimeStamps|.
// 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

Powered by Google App Engine
This is Rietveld 408576698