OLD | NEW |
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_PARSED_COOKIE_H_ | 5 #ifndef NET_COOKIES_PARSED_COOKIE_H_ |
6 #define NET_COOKIES_PARSED_COOKIE_H_ | 6 #define NET_COOKIES_PARSED_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 "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
16 class NET_EXPORT ParsedCookie { | 17 class NET_EXPORT ParsedCookie { |
17 public: | 18 public: |
18 typedef std::pair<std::string, std::string> TokenValuePair; | 19 typedef std::pair<std::string, std::string> TokenValuePair; |
19 typedef std::vector<TokenValuePair> PairList; | 20 typedef std::vector<TokenValuePair> PairList; |
20 | 21 |
21 // The maximum length of a cookie string we will try to parse | 22 // The maximum length of a cookie string we will try to parse |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 static void ParseValue(std::string::const_iterator* it, | 80 static void ParseValue(std::string::const_iterator* it, |
80 const std::string::const_iterator& end, | 81 const std::string::const_iterator& end, |
81 std::string::const_iterator* value_start, | 82 std::string::const_iterator* value_start, |
82 std::string::const_iterator* value_end); | 83 std::string::const_iterator* value_end); |
83 | 84 |
84 // Same as the above functions, except the input is assumed to contain the | 85 // Same as the above functions, except the input is assumed to contain the |
85 // desired token/value and nothing else. | 86 // desired token/value and nothing else. |
86 static std::string ParseTokenString(const std::string& token); | 87 static std::string ParseTokenString(const std::string& token); |
87 static std::string ParseValueString(const std::string& value); | 88 static std::string ParseValueString(const std::string& value); |
88 | 89 |
| 90 // Parses the string with the cookie time (very forgivingly). |
| 91 static base::Time ParseCookieTime(const std::string& time_string); |
| 92 |
89 private: | 93 private: |
90 static const char kTerminator[]; | 94 static const char kTerminator[]; |
91 static const int kTerminatorLen; | 95 static const int kTerminatorLen; |
92 static const char kWhitespace[]; | 96 static const char kWhitespace[]; |
93 static const char kValueSeparator[]; | 97 static const char kValueSeparator[]; |
94 static const char kTokenSeparator[]; | 98 static const char kTokenSeparator[]; |
95 | 99 |
96 void ParseTokenValuePairs(const std::string& cookie_line); | 100 void ParseTokenValuePairs(const std::string& cookie_line); |
97 void SetupAttributes(); | 101 void SetupAttributes(); |
98 | 102 |
(...skipping 11 matching lines...) Expand all Loading... |
110 size_t maxage_index_; | 114 size_t maxage_index_; |
111 size_t secure_index_; | 115 size_t secure_index_; |
112 size_t httponly_index_; | 116 size_t httponly_index_; |
113 | 117 |
114 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); | 118 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); |
115 }; | 119 }; |
116 | 120 |
117 } // namespace net | 121 } // namespace net |
118 | 122 |
119 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 123 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |