Chromium Code Reviews| Index: net/cookies/cookie_constants.cc |
| diff --git a/net/cookies/cookie_constants.cc b/net/cookies/cookie_constants.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35f823368f85ce4dcf7f265c0ed39c81b08e05bc |
| --- /dev/null |
| +++ b/net/cookies/cookie_constants.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "net/cookies/cookie_constants.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/string_util.h" |
| + |
| +namespace net { |
| + |
| +namespace { |
| + |
| +// These are lower-case to facilitate compare. |
|
erikwright (departed)
2013/04/16 14:16:15
I don't think this comment is necessary. The file
huangs
2013/04/16 16:04:42
Done. Added cookie_constants_unittest.cc.
|
| +const char kPriorityLow[] = "low"; |
| +const char kPriorityMedium[] = "medium"; |
| +const char kPriorityHigh[] = "high"; |
| + |
| +} // namespace |
| + |
| +NET_EXPORT const std::string CookiePriorityToString(CookiePriority priority) { |
| + if (priority == PRIORITY_HIGH) |
| + return kPriorityHigh; |
| + |
| + if (priority == PRIORITY_MEDIUM) |
| + return kPriorityMedium; |
| + |
| + if (priority == PRIORITY_LOW) |
| + return kPriorityLow; |
| + |
| + NOTREACHED(); |
| + return std::string(); |
| +} |
| + |
| +NET_EXPORT CookiePriority StringToCookiePriority(const std::string& priority) { |
| + std::string priority_comp(priority); |
| + StringToLowerASCII(&priority_comp); |
| + |
| + if (priority_comp == kPriorityHigh) |
| + return PRIORITY_HIGH; |
| + |
| + if (priority_comp == kPriorityMedium) |
| + return PRIORITY_MEDIUM; |
| + |
| + if (priority_comp == kPriorityLow) |
| + return PRIORITY_LOW; |
| + |
| + return PRIORITY_DEFAULT; |
| +} |
| + |
| +} // namespace net |