1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__
6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__
11 #include "base/gtest_prod_util.h"
12 #include "base/string16.h"
13 #include "base/time.h"
18 AutofillKey(const string16
& name
, const string16
& value
);
19 AutofillKey(const char* name
, const char* value
);
20 AutofillKey(const AutofillKey
& key
);
21 virtual ~AutofillKey();
23 const string16
& name() const { return name_
; }
24 const string16
& value() const { return value_
; }
26 bool operator==(const AutofillKey
& key
) const;
27 bool operator<(const AutofillKey
& key
) const;
36 AutofillEntry(const AutofillKey
& key
,
37 const std::vector
<base::Time
>& timestamps
);
40 const AutofillKey
& key() const { return key_
; }
41 const std::vector
<base::Time
>& timestamps() const { return timestamps_
; }
43 bool operator==(const AutofillEntry
& entry
) const;
44 bool operator<(const AutofillEntry
& entry
) const;
46 bool timestamps_culled() const { return timestamps_culled_
; }
48 // Checks if last of the timestamps are older than ExpirationTime().
49 bool IsExpired() const;
51 // The entries last accessed before this time should expire.
52 static base::Time
ExpirationTime();
55 FRIEND_TEST_ALL_PREFIXES(AutofillEntryTest
, NoCulling
);
56 FRIEND_TEST_ALL_PREFIXES(AutofillEntryTest
, Culling
);
57 FRIEND_TEST_ALL_PREFIXES(AutofillEntryTest
, CullByTime
);
59 // Culls the list of timestamps to 2 - the oldest and most recent. This is a
60 // precursor to getting rid of the timestamps db altogether.
61 // See http://crbug.com/118696.
62 // |source| is expected to be sorted from oldest to newest.
63 static bool CullTimeStamps(const std::vector
<base::Time
>& source
,
64 std::vector
<base::Time
>* result
);
67 std::vector
<base::Time
> timestamps_
;
68 bool timestamps_culled_
;
71 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__