Add ICU message format support
[chromium-blink-merge.git] / ios / net / cookies / cookie_creation_time_manager.h
blob42b9a429b6d826efc74b878ea99d94f55f4cf6f9
1 // Copyright 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 IOS_NET_COOKIES_COOKIE_CREATION_TIME_MANAGER_H_
6 #define IOS_NET_COOKIES_COOKIE_CREATION_TIME_MANAGER_H_
8 #include <set>
10 #include "base/containers/hash_tables.h"
11 #include "base/threading/thread_checker.h"
12 #include "base/time/time.h"
14 @class NSHTTPCookie;
16 namespace net {
18 // The CookieCreationTimeManager allows to get and set the creation time of a
19 // NSHTTPCookie.
20 // Creation time data is stored either in the cookie properties (when the cookie
21 // is created by the system) or in |creation_times_| (when the cookie is created
22 // by CookieStoreIOS). When both are available, |creation_times_| is used,
23 // because the cookie property only has a one second precision.
24 class CookieCreationTimeManager {
25 public:
26 CookieCreationTimeManager();
27 ~CookieCreationTimeManager();
28 // Sets the creation time for |cookie|.
29 // |creation_time| must be unique (not used by another cookie).
30 void SetCreationTime(NSHTTPCookie* cookie, const base::Time& creation_time);
31 // Creates a unique creation time (to be used in SetCreationTime()) that is
32 // as close as possible to |creation_time|.
33 base::Time MakeUniqueCreationTime(const base::Time& creation_time);
34 // Gets the creation time for |cookie|.
35 base::Time GetCreationTime(NSHTTPCookie* cookie);
36 // Deletes the creation time for |cookie|.
37 void DeleteCreationTime(NSHTTPCookie* cookie);
38 // Clears all the creation times.
39 void Clear();
41 private:
42 base::hash_map<std::string, base::Time> creation_times_;
43 std::set<base::Time> unique_times_;
44 base::ThreadChecker thread_checker_;
47 } // namespace net
49 #endif // IOS_NET_COOKIES_COOKIE_CREATION_TIME_MANAGER_H_