Chromium Code Reviews| Index: net/cookies/cookie_monster_unittest.cc |
| diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc |
| index 5452f191992357caabc0a29361078011fc8bf2b9..6f3c0b616fb5703cd2e937dde5a3ce0cbd1382fe 100644 |
| --- a/net/cookies/cookie_monster_unittest.cc |
| +++ b/net/cookies/cookie_monster_unittest.cc |
| @@ -436,20 +436,18 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> { |
| std::vector<int> id_list[3]; // Indexed by CookiePriority. |
| // Parse |coded_priority_str| and add cookies. |
| - std::vector<std::string> priority_tok_list; |
| - base::SplitString(coded_priority_str, ' ', &priority_tok_list); |
| - for (std::vector<std::string>::iterator it = priority_tok_list.begin(); |
| - it != priority_tok_list.end(); ++it) { |
| - size_t len = it->length(); |
| - DCHECK_NE(len, 0U); |
| + for (const std::string& token : |
| + base::SplitString(coded_priority_str, " ", base::TRIM_WHITESPACE, |
| + base::SPLIT_WANT_ALL)) { |
|
Ryan Sleevi
2015/07/06 08:52:01
nit: While you're here, this (and 467) are safe to
brettw
2015/07/06 16:52:34
I have no idea what you're asking me to clean up h
Ryan Sleevi
2015/07/06 16:58:12
Sorry, meant
const base::StringPiece& token : bas
|
| + DCHECK(!token.empty()); |
| // Take last character as priority. |
| - CookiePriority priority = CharToPriority((*it)[len - 1]); |
| + CookiePriority priority = CharToPriority(token[token.length() - 1]); |
| std::string priority_str = CookiePriorityToString(priority); |
| // The rest of the string (possibly empty) specifies repetition. |
| int rep = 1; |
| - if (!it->empty()) { |
| + if (!token.empty()) { |
| bool result = base::StringToInt( |
| - base::StringPiece(it->begin(), it->end() - 1), &rep); |
| + base::StringPiece(token.begin(), token.end() - 1), &rep); |
| DCHECK(result); |
| } |
| for (; rep > 0; --rep, ++next_cookie_id) { |
| @@ -466,14 +464,12 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> { |
| // Parse the list of cookies |
| std::string cookie_str = this->GetCookies(cm, url_google_); |
| - std::vector<std::string> cookie_tok_list; |
| - base::SplitString(cookie_str, ';', &cookie_tok_list); |
| - for (std::vector<std::string>::iterator it = cookie_tok_list.begin(); |
| - it != cookie_tok_list.end(); ++it) { |
| + for (const std::string& token : base::SplitString( |
| + cookie_str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| // Assuming *it is "a#=b", so extract and parse "#" portion. |
| int id = -1; |
| bool result = base::StringToInt( |
| - base::StringPiece(it->begin() + 1, it->end() - 2), &id); |
| + base::StringPiece(token.begin() + 1, token.end() - 2), &id); |
| DCHECK(result); |
| DCHECK_GE(id, 0); |
| DCHECK_LT(id, num_cookies); |