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

Side by Side Diff: net/cookies/canonical_cookie.h

Issue 14113014: Adding Priority field to cookies. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed enums PRIORITY_* to COOKIE_PRIORITY_*. Created 7 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_COOKIES_CANONICAL_COOKIE_H_ 5 #ifndef NET_COOKIES_CANONICAL_COOKIE_H_
6 #define NET_COOKIES_CANONICAL_COOKIE_H_ 6 #define NET_COOKIES_CANONICAL_COOKIE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 #include "net/cookies/cookie_constants.h"
14 #include "net/cookies/cookie_options.h" 15 #include "net/cookies/cookie_options.h"
15 16
16 class GURL; 17 class GURL;
17 18
18 namespace net { 19 namespace net {
19 20
20 class ParsedCookie; 21 class ParsedCookie;
21 22
22 class NET_EXPORT CanonicalCookie { 23 class NET_EXPORT CanonicalCookie {
23 public: 24 public:
24 // These constructors do no validation or canonicalization of their inputs; 25 // These constructors do no validation or canonicalization of their inputs;
25 // the resulting CanonicalCookies should not be relied on to be canonical 26 // the resulting CanonicalCookies should not be relied on to be canonical
26 // unless the caller has done appropriate validation and canonicalization 27 // unless the caller has done appropriate validation and canonicalization
27 // themselves. 28 // themselves.
28 CanonicalCookie(); 29 CanonicalCookie();
29 CanonicalCookie(const GURL& url, 30 CanonicalCookie(const GURL& url,
30 const std::string& name, 31 const std::string& name,
31 const std::string& value, 32 const std::string& value,
32 const std::string& domain, 33 const std::string& domain,
33 const std::string& path, 34 const std::string& path,
34 const base::Time& creation, 35 const base::Time& creation,
35 const base::Time& expiration, 36 const base::Time& expiration,
36 const base::Time& last_access, 37 const base::Time& last_access,
37 bool secure, 38 bool secure,
38 bool httponly); 39 bool httponly,
40 CookiePriority priority);
39 41
40 // This constructor does canonicalization but not validation. 42 // This constructor does canonicalization but not validation.
41 // The result of this constructor should not be relied on in contexts 43 // The result of this constructor should not be relied on in contexts
42 // in which pre-validation of the ParsedCookie has not been done. 44 // in which pre-validation of the ParsedCookie has not been done.
43 CanonicalCookie(const GURL& url, const ParsedCookie& pc); 45 CanonicalCookie(const GURL& url, const ParsedCookie& pc);
44 46
45 ~CanonicalCookie(); 47 ~CanonicalCookie();
46 48
47 // Supports the default copy constructor. 49 // Supports the default copy constructor.
48 50
49 // Creates a new |CanonicalCookie| from the |cookie_line| and the 51 // Creates a new |CanonicalCookie| from the |cookie_line| and the
50 // |creation_time|. Canonicalizes and validates inputs. May return NULL if 52 // |creation_time|. Canonicalizes and validates inputs. May return NULL if
51 // an attribut value is invalid. 53 // an attribut value is invalid.
52 static CanonicalCookie* Create(const GURL& url, 54 static CanonicalCookie* Create(const GURL& url,
53 const std::string& cookie_line, 55 const std::string& cookie_line,
54 const base::Time& creation_time, 56 const base::Time& creation_time,
55 const CookieOptions& options); 57 const CookieOptions& options);
56 58
57 // Creates a canonical cookie from unparsed attribute values. 59 // Creates a canonical cookie from unparsed attribute values.
58 // Canonicalizes and validates inputs. May return NULL if an attribute 60 // Canonicalizes and validates inputs. May return NULL if an attribute
59 // value is invalid. 61 // value is invalid.
60 static CanonicalCookie* Create(const GURL& url, 62 static CanonicalCookie* Create(const GURL& url,
61 const std::string& name, 63 const std::string& name,
62 const std::string& value, 64 const std::string& value,
63 const std::string& domain, 65 const std::string& domain,
64 const std::string& path, 66 const std::string& path,
65 const base::Time& creation, 67 const base::Time& creation,
66 const base::Time& expiration, 68 const base::Time& expiration,
67 bool secure, 69 bool secure,
68 bool http_only); 70 bool http_only,
71 CookiePriority priority);
69 72
70 const std::string& Source() const { return source_; } 73 const std::string& Source() const { return source_; }
71 const std::string& Name() const { return name_; } 74 const std::string& Name() const { return name_; }
72 const std::string& Value() const { return value_; } 75 const std::string& Value() const { return value_; }
73 const std::string& Domain() const { return domain_; } 76 const std::string& Domain() const { return domain_; }
74 const std::string& Path() const { return path_; } 77 const std::string& Path() const { return path_; }
75 const base::Time& CreationDate() const { return creation_date_; } 78 const base::Time& CreationDate() const { return creation_date_; }
76 const base::Time& LastAccessDate() const { return last_access_date_; } 79 const base::Time& LastAccessDate() const { return last_access_date_; }
77 bool IsPersistent() const { return !expiry_date_.is_null(); } 80 bool IsPersistent() const { return !expiry_date_.is_null(); }
78 const base::Time& ExpiryDate() const { return expiry_date_; } 81 const base::Time& ExpiryDate() const { return expiry_date_; }
79 bool IsSecure() const { return secure_; } 82 bool IsSecure() const { return secure_; }
80 bool IsHttpOnly() const { return httponly_; } 83 bool IsHttpOnly() const { return httponly_; }
84 CookiePriority Priority() const { return priority_; }
81 bool IsDomainCookie() const { 85 bool IsDomainCookie() const {
82 return !domain_.empty() && domain_[0] == '.'; } 86 return !domain_.empty() && domain_[0] == '.'; }
83 bool IsHostCookie() const { return !IsDomainCookie(); } 87 bool IsHostCookie() const { return !IsDomainCookie(); }
84 88
85 bool IsExpired(const base::Time& current) const { 89 bool IsExpired(const base::Time& current) const {
86 return !expiry_date_.is_null() && current >= expiry_date_; 90 return !expiry_date_.is_null() && current >= expiry_date_;
87 } 91 }
88 92
89 // Are the cookies considered equivalent in the eyes of RFC 2965. 93 // Are the cookies considered equivalent in the eyes of RFC 2965.
90 // The RFC says that name must match (case-sensitive), domain must 94 // The RFC says that name must match (case-sensitive), domain must
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 std::string source_; 145 std::string source_;
142 std::string name_; 146 std::string name_;
143 std::string value_; 147 std::string value_;
144 std::string domain_; 148 std::string domain_;
145 std::string path_; 149 std::string path_;
146 base::Time creation_date_; 150 base::Time creation_date_;
147 base::Time expiry_date_; 151 base::Time expiry_date_;
148 base::Time last_access_date_; 152 base::Time last_access_date_;
149 bool secure_; 153 bool secure_;
150 bool httponly_; 154 bool httponly_;
155 CookiePriority priority_;
151 }; 156 };
152 157
153 typedef std::vector<CanonicalCookie> CookieList; 158 typedef std::vector<CanonicalCookie> CookieList;
154 159
155 } // namespace net 160 } // namespace net
156 161
157 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ 162 #endif // NET_COOKIES_CANONICAL_COOKIE_H_
OLDNEW
« no previous file with comments | « content/browser/net/sqlite_persistent_cookie_store_unittest.cc ('k') | net/cookies/canonical_cookie.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698