Index: net/cookies/parsed_cookie.h |
diff --git a/net/cookies/parsed_cookie.h b/net/cookies/parsed_cookie.h |
index 6f8e4ef72012a1b05bc5b41e4377f1ce5a977dd3..086d91ad77c81d7fbcaa4235306d39cb327b16ab 100644 |
--- a/net/cookies/parsed_cookie.h |
+++ b/net/cookies/parsed_cookie.h |
@@ -55,8 +55,23 @@ class NET_EXPORT ParsedCookie { |
// "BLAH=hah; path=/; domain=.google.com" |
size_t NumberOfAttributes() const { return pairs_.size() - 1; } |
- // For debugging only! |
- std::string DebugString() const; |
+ // These functions set the respective properties of the cookie. If the |
+ // parameters are empty, the respective properties are cleared. |
+ // The functions return false in case an error occurred. |
+ bool SetName(const std::string& name); |
+ bool SetValue(const std::string& value); |
+ bool SetPath(const std::string& path); |
+ bool SetDomain(const std::string& domain); |
+ bool SetMACKey(const std::string& mac_key); |
+ bool SetMACAlgorithm(const std::string& mac_algorithm); |
+ bool SetExpires(const std::string& expires); |
+ bool SetMaxAge(const std::string& maxage); |
+ bool SetIsSecure(bool is_secure); |
+ bool SetIsHttpOnly(bool is_http_only); |
+ |
+ // Returns the cookie description as it appears in a HTML response header. |
+ // ToCookieLine() is the new DebugString(); |
erikwright (departed)
2012/07/12 15:50:57
Remove the "new DebugString()" note.
battre
2012/07/12 18:03:10
Done.
|
+ std::string ToCookieLine() const; |
// Returns an iterator pointing to the first terminator character found in |
// the given string. |
@@ -87,15 +102,23 @@ class NET_EXPORT ParsedCookie { |
static std::string ParseValueString(const std::string& value); |
private: |
- static const char kTerminator[]; |
- static const int kTerminatorLen; |
- static const char kWhitespace[]; |
- static const char kValueSeparator[]; |
- static const char kTokenSeparator[]; |
- |
void ParseTokenValuePairs(const std::string& cookie_line); |
void SetupAttributes(); |
+ // Sets a key/value pair for a cookie. |index| has to point to one of the |
+ // |*_index_| fields in ParsedCookie and is updated to the position where |
+ // the key/value pair is set in |pairs_|. Accordingly, |key| has to correspond |
+ // to the token matching |index|. If |value| contains invalid characters, the |
+ // cookie parameter is not changed and the function returns false. |
+ bool SetAttributePair(size_t* index, |
+ const std::string& key, |
+ const std::string& value); |
+ |
+ // Removes the key/value pair from a cookie that is identified by |index|. |
+ // |index| refers to a position in |pairs_|. |
+ // Returns false in case an error occurred. |
+ bool ClearAttributePair(size_t index); |
+ |
PairList pairs_; |
bool is_valid_; |
// These will default to 0, but that should never be valid since the |