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..68d439fe0dd372b175d6422b854a58556d42755d |
| --- /dev/null |
| +++ b/net/cookies/cookie_constants.cc |
| @@ -0,0 +1,48 @@ |
| +// 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 { |
| +std::string kPriorityLow("Low"); |
|
erikwright (departed)
2013/04/15 19:00:37
I believe these need to be const char[].
erikwright (departed)
2013/04/15 19:00:37
I don't see any reason to output these with capita
huangs
2013/04/15 21:29:40
Done.
huangs
2013/04/15 21:29:40
Done.
|
| +std::string kPriorityMedium("Medium"); |
| +std::string kPriorityHigh("High"); |
| +} // namespace |
| + |
| +NET_EXPORT const std::string PriorityToString(CookiePriority priority) { |
| + std::string ret; |
| + if (priority == PRIORITY_HIGH) |
| + ret = kPriorityHigh; |
|
erikwright (departed)
2013/04/15 19:00:37
just return from here.
huangs
2013/04/15 21:29:40
Done (although this leads to longer code).
erikwright (departed)
2013/04/16 14:16:15
Well, you did also add 3 lines of whitespace ;)
T
|
| + else if (priority == PRIORITY_MEDIUM) |
| + ret = kPriorityMedium; |
| + else if (priority == PRIORITY_LOW) |
| + ret = kPriorityLow; |
| + else |
| + NOTREACHED(); // Returns empty string. |
| + return ret; |
| +} |
| + |
| +NET_EXPORT CookiePriority StringToPriority(const std::string& priority_str) { |
| + std::string priority_comp(priority_str); |
| + StringToLowerASCII(&priority_comp); |
| + // Capitalize first letter to match case with constants. |
| + if (!priority_comp.empty()) |
| + *(priority_comp.begin()) = base::ToUpperASCII(*(priority_comp.begin())); |
| + |
| + CookiePriority ret = PRIORITY_DEFAULT; |
| + if (priority_comp == kPriorityHigh) |
| + ret = PRIORITY_HIGH; |
|
erikwright (departed)
2013/04/15 19:00:37
just return the value directly here.
huangs
2013/04/15 21:29:40
Done.
|
| + else if (priority_comp == kPriorityMedium) |
| + ret = PRIORITY_MEDIUM; |
| + else if (priority_comp == kPriorityLow) |
| + ret = PRIORITY_LOW; |
| + return ret; |
| +} |
| + |
| +} // namespace net |