summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 20:47:27 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 20:47:27 +0000
commit6c0507960c2634185ed3df13f75e31ecdaceda34 (patch)
tree92fc79cf981d9be22871f49ea9efa99c101325cf /google_apis
parent2b7dea8f59e2517df1cd8bfba3dd90ce260dafc3 (diff)
downloadchromium_src-6c0507960c2634185ed3df13f75e31ecdaceda34.zip
chromium_src-6c0507960c2634185ed3df13f75e31ecdaceda34.tar.gz
chromium_src-6c0507960c2634185ed3df13f75e31ecdaceda34.tar.bz2
Fix "unreachable code" warnings (MSVC warning 4702) in google_apis/.
BUG=346399 TEST=none R=mtomasz@chromium.org, rogerta@chromium.org Review URL: https://codereview.chromium.org/203033002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/drive/drive_api_parser.cc1
-rw-r--r--google_apis/gaia/gaia_auth_fetcher.cc122
-rw-r--r--google_apis/gaia/gaia_auth_fetcher_unittest.cc40
3 files changed, 32 insertions, 131 deletions
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc
index 384db45..1eefb8b 100644
--- a/google_apis/drive/drive_api_parser.cc
+++ b/google_apis/drive/drive_api_parser.cc
@@ -706,7 +706,6 @@ scoped_ptr<ImageMediaMetadata> ImageMediaMetadata::CreateFrom(
}
bool ImageMediaMetadata::Parse(const base::Value& value) {
- return true;
base::JSONValueConverter<ImageMediaMetadata> converter;
if (!converter.Convert(value, this)) {
LOG(ERROR) << "Unable to parse: Invalid ImageMediaMetadata.";
diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc
index 01e9567..4e21fd7 100644
--- a/google_apis/gaia/gaia_auth_fetcher.cc
+++ b/google_apis/gaia/gaia_auth_fetcher.cc
@@ -114,21 +114,15 @@ const char GaiaAuthFetcher::kOAuthLoginFormat[] = "service=%s&source=%s";
// static
const char GaiaAuthFetcher::kAccountDeletedError[] = "AccountDeleted";
-const char GaiaAuthFetcher::kAccountDeletedErrorCode[] = "adel";
// static
const char GaiaAuthFetcher::kAccountDisabledError[] = "AccountDisabled";
-const char GaiaAuthFetcher::kAccountDisabledErrorCode[] = "adis";
// static
const char GaiaAuthFetcher::kBadAuthenticationError[] = "BadAuthentication";
-const char GaiaAuthFetcher::kBadAuthenticationErrorCode[] = "badauth";
// static
const char GaiaAuthFetcher::kCaptchaError[] = "CaptchaRequired";
-const char GaiaAuthFetcher::kCaptchaErrorCode[] = "cr";
// static
const char GaiaAuthFetcher::kServiceUnavailableError[] =
"ServiceUnavailable";
-const char GaiaAuthFetcher::kServiceUnavailableErrorCode[] =
- "ire";
// static
const char GaiaAuthFetcher::kErrorParam[] = "Error";
// static
@@ -693,102 +687,42 @@ GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError(
if (!status.is_success()) {
if (status.status() == net::URLRequestStatus::CANCELED) {
return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED);
- } else {
- DLOG(WARNING) << "Could not reach Google Accounts servers: errno "
- << status.error();
- return GoogleServiceAuthError::FromConnectionError(status.error());
- }
- } else {
- if (IsSecondFactorSuccess(data)) {
- return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR);
- }
-
- std::string error;
- std::string url;
- std::string captcha_url;
- std::string captcha_token;
- ParseClientLoginFailure(data, &error, &url, &captcha_url, &captcha_token);
- DLOG(WARNING) << "ClientLogin failed with " << error;
-
- if (error == kCaptchaError) {
- GURL image_url(
- GaiaUrls::GetInstance()->captcha_base_url().Resolve(captcha_url));
- GURL unlock_url(url);
- return GoogleServiceAuthError::FromClientLoginCaptchaChallenge(
- captcha_token, image_url, unlock_url);
- }
- if (error == kAccountDeletedError)
- return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED);
- if (error == kAccountDisabledError)
- return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED);
- if (error == kBadAuthenticationError) {
- return GoogleServiceAuthError(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- }
- if (error == kServiceUnavailableError) {
- return GoogleServiceAuthError(
- GoogleServiceAuthError::SERVICE_UNAVAILABLE);
}
+ DLOG(WARNING) << "Could not reach Google Accounts servers: errno "
+ << status.error();
+ return GoogleServiceAuthError::FromConnectionError(status.error());
+ }
- DLOG(WARNING) << "Incomprehensible response from Google Accounts servers.";
+ if (IsSecondFactorSuccess(data))
+ return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR);
+
+ std::string error;
+ std::string url;
+ std::string captcha_url;
+ std::string captcha_token;
+ ParseClientLoginFailure(data, &error, &url, &captcha_url, &captcha_token);
+ DLOG(WARNING) << "ClientLogin failed with " << error;
+
+ if (error == kCaptchaError) {
+ return GoogleServiceAuthError::FromClientLoginCaptchaChallenge(
+ captcha_token,
+ GURL(GaiaUrls::GetInstance()->captcha_base_url().Resolve(captcha_url)),
+ GURL(url));
+ }
+ if (error == kAccountDeletedError)
+ return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED);
+ if (error == kAccountDisabledError)
+ return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED);
+ if (error == kBadAuthenticationError) {
return GoogleServiceAuthError(
- GoogleServiceAuthError::SERVICE_UNAVAILABLE);
+ GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
}
-
- NOTREACHED();
- return GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE);
-}
-
-// static
-GoogleServiceAuthError GaiaAuthFetcher::GenerateOAuthLoginError(
- const std::string& data,
- const net::URLRequestStatus& status) {
- if (!status.is_success()) {
- if (status.status() == net::URLRequestStatus::CANCELED) {
- return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED);
- } else {
- DLOG(WARNING) << "Could not reach Google Accounts servers: errno "
- << status.error();
- return GoogleServiceAuthError::FromConnectionError(status.error());
- }
- } else {
- if (IsSecondFactorSuccess(data)) {
- return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR);
- }
-
- std::string error;
- std::string url;
- std::string captcha_url;
- std::string captcha_token;
- ParseClientLoginFailure(data, &error, &url, &captcha_url, &captcha_token);
- LOG(WARNING) << "OAuthLogin failed with " << error;
-
- if (error == kCaptchaErrorCode) {
- GURL image_url(
- GaiaUrls::GetInstance()->captcha_base_url().Resolve(captcha_url));
- GURL unlock_url(url);
- return GoogleServiceAuthError::FromClientLoginCaptchaChallenge(
- captcha_token, image_url, unlock_url);
- }
- if (error == kAccountDeletedErrorCode)
- return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED);
- if (error == kAccountDisabledErrorCode)
- return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED);
- if (error == kBadAuthenticationErrorCode) {
- return GoogleServiceAuthError(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- }
- if (error == kServiceUnavailableErrorCode) {
- return GoogleServiceAuthError(
- GoogleServiceAuthError::SERVICE_UNAVAILABLE);
- }
-
- DLOG(WARNING) << "Incomprehensible response from Google Accounts servers.";
+ if (error == kServiceUnavailableError) {
return GoogleServiceAuthError(
GoogleServiceAuthError::SERVICE_UNAVAILABLE);
}
- NOTREACHED();
+ DLOG(WARNING) << "Incomprehensible response from Google Accounts servers.";
return GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE);
}
diff --git a/google_apis/gaia/gaia_auth_fetcher_unittest.cc b/google_apis/gaia/gaia_auth_fetcher_unittest.cc
index 5bced8c..9d2f60a 100644
--- a/google_apis/gaia/gaia_auth_fetcher_unittest.cc
+++ b/google_apis/gaia/gaia_auth_fetcher_unittest.cc
@@ -406,7 +406,7 @@ TEST_F(GaiaAuthFetcherTest, AccountDisabledError) {
EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED);
}
-TEST_F(GaiaAuthFetcherTest,BadAuthenticationError) {
+TEST_F(GaiaAuthFetcherTest, BadAuthenticationError) {
net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
std::string data = "Error=BadAuthentication\n";
GoogleServiceAuthError error =
@@ -414,7 +414,7 @@ TEST_F(GaiaAuthFetcherTest,BadAuthenticationError) {
EXPECT_EQ(error.state(), GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
}
-TEST_F(GaiaAuthFetcherTest,IncomprehensibleError) {
+TEST_F(GaiaAuthFetcherTest, IncomprehensibleError) {
net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
std::string data = "Error=Gobbledygook\n";
GoogleServiceAuthError error =
@@ -422,43 +422,11 @@ TEST_F(GaiaAuthFetcherTest,IncomprehensibleError) {
EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
}
-TEST_F(GaiaAuthFetcherTest,ServiceUnavailableError) {
+TEST_F(GaiaAuthFetcherTest, ServiceUnavailableError) {
net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
std::string data = "Error=ServiceUnavailable\n";
GoogleServiceAuthError error =
- GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
- EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
-}
-
-TEST_F(GaiaAuthFetcherTest, OAuthAccountDeletedError) {
- net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
- std::string data = "Error=adel\n";
- GoogleServiceAuthError error =
- GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
- EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DELETED);
-}
-
-TEST_F(GaiaAuthFetcherTest, OAuthAccountDisabledError) {
- net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
- std::string data = "Error=adis\n";
- GoogleServiceAuthError error =
- GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
- EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED);
-}
-
-TEST_F(GaiaAuthFetcherTest, OAuthBadAuthenticationError) {
- net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
- std::string data = "Error=badauth\n";
- GoogleServiceAuthError error =
- GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
- EXPECT_EQ(error.state(), GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
-}
-
-TEST_F(GaiaAuthFetcherTest, OAuthServiceUnavailableError) {
- net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
- std::string data = "Error=ire\n";
- GoogleServiceAuthError error =
- GaiaAuthFetcher::GenerateOAuthLoginError(data, status);
+ GaiaAuthFetcher::GenerateAuthError(data, status);
EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
}