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

Unified Diff: net/cookies/parsed_cookie.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | net/cookies/parsed_cookie_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/parsed_cookie.cc
diff --git a/net/cookies/parsed_cookie.cc b/net/cookies/parsed_cookie.cc
index ecb87129b432f12efd6b97117be91ebdc2d45d76..8d382152b32c7e12e2df45834521c4bb39c56111 100644
--- a/net/cookies/parsed_cookie.cc
+++ b/net/cookies/parsed_cookie.cc
@@ -55,6 +55,7 @@ const char kExpiresTokenName[] = "expires";
const char kMaxAgeTokenName[] = "max-age";
const char kSecureTokenName[] = "secure";
const char kHttpOnlyTokenName[] = "httponly";
+const char kPriorityTokenName[] = "priority";
const char kTerminator[] = "\n\r\0";
const int kTerminatorLen = sizeof(kTerminator) - 1;
@@ -155,7 +156,8 @@ ParsedCookie::ParsedCookie(const std::string& cookie_line)
expires_index_(0),
maxage_index_(0),
secure_index_(0),
- httponly_index_(0) {
+ httponly_index_(0),
+ priority_index_(0) {
if (cookie_line.size() > kMaxCookieSize) {
VLOG(1) << "Not parsing cookie, too large: " << cookie_line.size();
@@ -174,6 +176,11 @@ bool ParsedCookie::IsValid() const {
return !pairs_.empty();
}
+CookiePriority ParsedCookie::Priority() const {
+ return (priority_index_ == 0) ? COOKIE_PRIORITY_DEFAULT :
+ StringToCookiePriority(pairs_[priority_index_].second);
+}
+
bool ParsedCookie::SetName(const std::string& name) {
if (!IsValidToken(name))
return false;
@@ -216,6 +223,10 @@ bool ParsedCookie::SetIsHttpOnly(bool is_http_only) {
return SetBool(&httponly_index_, kHttpOnlyTokenName, is_http_only);
}
+bool ParsedCookie::SetPriority(const std::string& priority) {
+ return SetString(&priority_index_, kPriorityTokenName, priority);
+}
+
std::string ParsedCookie::ToCookieLine() const {
std::string out;
for (PairList::const_iterator it = pairs_.begin();
@@ -400,6 +411,8 @@ void ParsedCookie::SetupAttributes() {
secure_index_ = i;
} else if (pairs_[i].first == kHttpOnlyTokenName) {
httponly_index_ = i;
+ } else if (pairs_[i].first == kPriorityTokenName) {
+ priority_index_ = i;
} else {
/* some attribute we don't know or don't care about. */
}
@@ -452,7 +465,8 @@ void ParsedCookie::ClearAttributePair(size_t index) {
return;
size_t* indexes[] = { &path_index_, &domain_index_, &expires_index_,
- &maxage_index_, &secure_index_, &httponly_index_ };
+ &maxage_index_, &secure_index_, &httponly_index_,
+ &priority_index_ };
for (size_t i = 0; i < arraysize(indexes); ++i) {
if (*indexes[i] == index)
*indexes[i] = 0;
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | net/cookies/parsed_cookie_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698