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

Side by Side Diff: ios/net/cookies/cookie_creation_time_manager.h

Issue 994823004: [iOS] Upstream //ios/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef IOS_NET_COOKIES_COOKIE_CREATION_TIME_MANAGER_H_
6 #define IOS_NET_COOKIES_COOKIE_CREATION_TIME_MANAGER_H_
7
8 #include <set>
9
10 #include "base/containers/hash_tables.h"
11 #include "base/threading/thread_checker.h"
12 #include "base/time/time.h"
13
14 @class NSHTTPCookie;
15
16 namespace net {
17
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();
40
41 private:
42 base::hash_map<std::string, base::Time> creation_times_;
43 std::set<base::Time> unique_times_;
44 base::ThreadChecker thread_checker_;
45 };
46
47 } // namespace net
48
49 #endif // IOS_NET_COOKIES_COOKIE_CREATION_TIME_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698