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 "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 class NET_EXPORT ParsedCookie { | 16 class NET_EXPORT ParsedCookie { |
17 public: | 17 public: |
18 typedef std::pair<std::string, std::string> TokenValuePair; | 18 typedef std::pair<std::string, std::string> TokenValuePair; |
19 typedef std::vector<TokenValuePair> PairList; | 19 typedef std::vector<TokenValuePair> PairList; |
20 | 20 |
21 // The maximum length of a cookie string we will try to parse | 21 // The maximum length of a cookie string we will try to parse |
22 static const size_t kMaxCookieSize = 4096; | 22 static const size_t kMaxCookieSize = 4096; |
23 // The maximum number of Token/Value pairs. Shouldn't have more than 8. | 23 // The maximum number of Token/Value pairs. Shouldn't have more than 8. |
24 static const int kMaxPairs = 16; | 24 static const int kMaxPairs = 16; |
25 | 25 |
26 // Construct from a cookie string like "BLAH=1; path=/; domain=.google.com" | 26 // Construct from a cookie string like "BLAH=1; path=/; domain=.google.com" |
27 ParsedCookie(const std::string& cookie_line); | 27 explicit ParsedCookie(const std::string& cookie_line); |
28 ~ParsedCookie(); | 28 ~ParsedCookie(); |
29 | 29 |
30 // You should not call any other methods except for SetName/SetValue on the | 30 // You should not call any other methods except for SetName/SetValue on the |
31 // class if !IsValid. | 31 // class if !IsValid. |
32 bool IsValid() const; | 32 bool IsValid() const; |
33 | 33 |
34 const std::string& Name() const { return pairs_[0].first; } | 34 const std::string& Name() const { return pairs_[0].first; } |
35 const std::string& Token() const { return Name(); } | 35 const std::string& Token() const { return Name(); } |
36 const std::string& Value() const { return pairs_[0].second; } | 36 const std::string& Value() const { return pairs_[0].second; } |
37 | 37 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 size_t maxage_index_; | 144 size_t maxage_index_; |
145 size_t secure_index_; | 145 size_t secure_index_; |
146 size_t httponly_index_; | 146 size_t httponly_index_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); | 148 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); |
149 }; | 149 }; |
150 | 150 |
151 } // namespace net | 151 } // namespace net |
152 | 152 |
153 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 153 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |