diff options
author | brettw <brettw@chromium.org> | 2015-08-06 17:11:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 00:12:13 +0000 |
commit | 0aa7c64253cca8b636d52d1d01d94f96ab9c13fa (patch) | |
tree | 29b825a84dffc4d7310c69b22da0cfd7b1228277 /google_apis | |
parent | 924597ba8b5def174aebdc96368545f51df1bee2 (diff) | |
download | chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.zip chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.tar.gz chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.tar.bz2 |
Update SplitString calls to new form
Uses the new form for most (but not quite all) of the remaining users of the old form.
Changes media mime util codec list parsing to expect no result from the string "," rather than two empty strings. The old SplitString call had a special case where if the input was empty, it would return empty, but if it had one split character, it would return two empty strings as results.
The new one lets you choose but the options are either (1) empty string -> one empty string and "," -> two empty strings, or (2) map both to no results for when you don't want empty results. I'm pretty sure media codec parsing actually wants the latter behavior, so I updated the call to discard empty results and MimeUtilTest.ParseCodecString is updated.
Review URL: https://codereview.chromium.org/1272823003
Cr-Commit-Position: refs/heads/master@{#342238}
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/drive/test_util.cc | 9 | ||||
-rw-r--r-- | google_apis/gaia/fake_gaia.cc | 20 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher.cc | 4 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_util.cc | 5 |
4 files changed, 16 insertions, 22 deletions
diff --git a/google_apis/drive/test_util.cc b/google_apis/drive/test_util.cc index ae96409..e77aedf 100644 --- a/google_apis/drive/test_util.cc +++ b/google_apis/drive/test_util.cc @@ -133,17 +133,16 @@ bool ParseContentRangeHeader(const std::string& value, if (!RemovePrefix(value, "bytes ", &remaining)) return false; - std::vector<std::string> parts; - base::SplitString(remaining, '/', &parts); + std::vector<base::StringPiece> parts = base::SplitStringPiece( + remaining, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (parts.size() != 2U) return false; - const std::string range = parts[0]; if (!base::StringToInt64(parts[1], length)) return false; - parts.clear(); - base::SplitString(range, '-', &parts); + parts = base::SplitStringPiece(parts[0], "-", base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL); if (parts.size() != 2U) return false; diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc index 6749393..d24158c 100644 --- a/google_apis/gaia/fake_gaia.cc +++ b/google_apis/gaia/fake_gaia.cc @@ -71,17 +71,13 @@ typedef std::map<std::string, std::string> CookieMap; // Parses cookie name-value map our of |request|. CookieMap GetRequestCookies(const HttpRequest& request) { CookieMap result; - std::map<std::string, std::string>::const_iterator iter = - request.headers.find("Cookie"); + auto iter = request.headers.find("Cookie"); if (iter != request.headers.end()) { - std::vector<std::string> cookie_nv_pairs; - base::SplitString(iter->second, ' ', &cookie_nv_pairs); - for(std::vector<std::string>::const_iterator cookie_line = - cookie_nv_pairs.begin(); - cookie_line != cookie_nv_pairs.end(); - ++cookie_line) { - std::vector<std::string> name_value; - base::SplitString(*cookie_line, '=', &name_value); + for (const std::string& cookie_line : + base::SplitString(iter->second, " ", base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL)) { + std::vector<std::string> name_value = base::SplitString( + cookie_line, "=", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (name_value.size() != 2) continue; @@ -441,8 +437,8 @@ const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo( if (auth_token.empty() || client_id.empty()) return NULL; - std::vector<std::string> scope_list; - base::SplitString(scope_string, ' ', &scope_list); + std::vector<std::string> scope_list = base::SplitString( + scope_string, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); ScopeSet scopes(scope_list.begin(), scope_list.end()); for (AccessTokenInfoMap::const_iterator entry( diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc index 04ebd6e..086414f 100644 --- a/google_apis/gaia/gaia_auth_fetcher.cc +++ b/google_apis/gaia/gaia_auth_fetcher.cc @@ -508,8 +508,8 @@ bool GaiaAuthFetcher::ParseClientLoginToOAuth2Response( // static bool GaiaAuthFetcher::ParseClientLoginToOAuth2Cookie(const std::string& cookie, std::string* auth_code) { - std::vector<std::string> parts; - base::SplitString(cookie, ';', &parts); + std::vector<std::string> parts = base::SplitString( + cookie, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); // Per documentation, the cookie should have Secure and HttpOnly. if (!CookiePartsContains(parts, kClientLoginToOAuth2CookiePartSecure) || !CookiePartsContains(parts, kClientLoginToOAuth2CookiePartHttpOnly)) { diff --git a/google_apis/gaia/gaia_auth_util.cc b/google_apis/gaia/gaia_auth_util.cc index 5464da6..cc5e17c 100644 --- a/google_apis/gaia/gaia_auth_util.cc +++ b/google_apis/gaia/gaia_auth_util.cc @@ -21,9 +21,8 @@ const char kGooglemailDomain[] = "googlemail.com"; std::string CanonicalizeEmailImpl(const std::string& email_address, bool change_googlemail_to_gmail) { - std::vector<std::string> parts; - char at = '@'; - base::SplitString(email_address, at, &parts); + std::vector<std::string> parts = base::SplitString( + email_address, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (parts.size() != 2U) { NOTREACHED() << "expecting exactly one @, but got " << (parts.empty() ? 0 : parts.size() - 1) |