From c4afb05f67511e980cd13c021abf26e04b902977 Mon Sep 17 00:00:00 2001 From: pkasting Date: Thu, 6 Aug 2015 18:29:50 -0700 Subject: Revert of Update SplitString calls to new form (patchset #5 id:80001 of https://codereview.chromium.org/1272823003/ ) Reason for revert: Caused Blink layout test failures in media/encrypted-media/encrypted-media-requestmediakeysystemaccess.html : http://test-results.appspot.com/dashboards/flakiness_dashboard.html#showExpectations=true&tests=media%2Fencrypted-media%2Fencrypted-media-requestmediakeysystemaccess.html Original issue's description: > 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. > > Committed: https://crrev.com/0aa7c64253cca8b636d52d1d01d94f96ab9c13fa > Cr-Commit-Position: refs/heads/master@{#342238} TBR=sky@chromium.org,dalecurtis@chromium.org,brettw@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1278973003 Cr-Commit-Position: refs/heads/master@{#342257} --- google_apis/drive/test_util.cc | 9 +++++---- google_apis/gaia/fake_gaia.cc | 20 ++++++++++++-------- google_apis/gaia/gaia_auth_fetcher.cc | 4 ++-- google_apis/gaia/gaia_auth_util.cc | 5 +++-- 4 files changed, 22 insertions(+), 16 deletions(-) (limited to 'google_apis') diff --git a/google_apis/drive/test_util.cc b/google_apis/drive/test_util.cc index e77aedf..ae96409 100644 --- a/google_apis/drive/test_util.cc +++ b/google_apis/drive/test_util.cc @@ -133,16 +133,17 @@ bool ParseContentRangeHeader(const std::string& value, if (!RemovePrefix(value, "bytes ", &remaining)) return false; - std::vector parts = base::SplitStringPiece( - remaining, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector parts; + base::SplitString(remaining, '/', &parts); if (parts.size() != 2U) return false; + const std::string range = parts[0]; if (!base::StringToInt64(parts[1], length)) return false; - parts = base::SplitStringPiece(parts[0], "-", base::TRIM_WHITESPACE, - base::SPLIT_WANT_ALL); + parts.clear(); + base::SplitString(range, '-', &parts); if (parts.size() != 2U) return false; diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc index d24158c..6749393 100644 --- a/google_apis/gaia/fake_gaia.cc +++ b/google_apis/gaia/fake_gaia.cc @@ -71,13 +71,17 @@ typedef std::map CookieMap; // Parses cookie name-value map our of |request|. CookieMap GetRequestCookies(const HttpRequest& request) { CookieMap result; - auto iter = request.headers.find("Cookie"); + std::map::const_iterator iter = + request.headers.find("Cookie"); if (iter != request.headers.end()) { - for (const std::string& cookie_line : - base::SplitString(iter->second, " ", base::TRIM_WHITESPACE, - base::SPLIT_WANT_ALL)) { - std::vector name_value = base::SplitString( - cookie_line, "=", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector cookie_nv_pairs; + base::SplitString(iter->second, ' ', &cookie_nv_pairs); + for(std::vector::const_iterator cookie_line = + cookie_nv_pairs.begin(); + cookie_line != cookie_nv_pairs.end(); + ++cookie_line) { + std::vector name_value; + base::SplitString(*cookie_line, '=', &name_value); if (name_value.size() != 2) continue; @@ -437,8 +441,8 @@ const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo( if (auth_token.empty() || client_id.empty()) return NULL; - std::vector scope_list = base::SplitString( - scope_string, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector scope_list; + base::SplitString(scope_string, ' ', &scope_list); 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 086414f..04ebd6e 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 parts = base::SplitString( - cookie, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector parts; + base::SplitString(cookie, ';', &parts); // 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 cc5e17c..5464da6 100644 --- a/google_apis/gaia/gaia_auth_util.cc +++ b/google_apis/gaia/gaia_auth_util.cc @@ -21,8 +21,9 @@ const char kGooglemailDomain[] = "googlemail.com"; std::string CanonicalizeEmailImpl(const std::string& email_address, bool change_googlemail_to_gmail) { - std::vector parts = base::SplitString( - email_address, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector parts; + char at = '@'; + base::SplitString(email_address, at, &parts); if (parts.size() != 2U) { NOTREACHED() << "expecting exactly one @, but got " << (parts.empty() ? 0 : parts.size() - 1) -- cgit v1.1