diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-26 20:41:14 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-26 20:41:14 +0000 |
commit | 1cf5550dcad4d01e349380fbbec068839716421c (patch) | |
tree | f294a9a502912f49356197bb60c1ed44a45febee /google_apis | |
parent | 40fdd014c3a6847c472ce5da8e43ffeb99441b04 (diff) | |
download | chromium_src-1cf5550dcad4d01e349380fbbec068839716421c.zip chromium_src-1cf5550dcad4d01e349380fbbec068839716421c.tar.gz chromium_src-1cf5550dcad4d01e349380fbbec068839716421c.tar.bz2 |
Fix GaiaOAuthClient to handle the case when it's destroyed from callbacks.
Previously GaiaOAuthClient was accessing its members after calling the
delegate, so it was crashing if the delegate destroys GaiaOAuthClient object.
Second problem this change solves is that it was not possible to call
GetUserInfo() from OnRefreshTokenResponse().
Review URL: https://chromiumcodereview.appspot.com/11271038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/gaia_oauth_client.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/google_apis/gaia/gaia_oauth_client.cc b/google_apis/gaia/gaia_oauth_client.cc index 41e8f96..46fbac1 100644 --- a/google_apis/gaia/gaia_oauth_client.cc +++ b/google_apis/gaia/gaia_oauth_client.cc @@ -163,15 +163,16 @@ void GaiaOAuthClient::Core::OnURLFetchComplete( // URLFetcher::Core::RetryOrCompleteUrlFetch resets it to NULL... request_->SetRequestContext(request_context_getter_); request_->Start(); - } else { - request_.reset(); } } void GaiaOAuthClient::Core::HandleResponse( const net::URLFetcher* source, bool* should_retry_request) { - *should_retry_request = false; + // Keep the URLFetcher object in case we need to reuse it. + scoped_ptr<net::URLFetcher> old_request = request_.Pass(); + DCHECK_EQ(source, old_request.get()); + // RC_BAD_REQUEST means the arguments are invalid. No point retrying. We are // done here. if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) { @@ -199,6 +200,7 @@ void GaiaOAuthClient::Core::HandleResponse( // Retry limit reached. Give up. delegate_->OnNetworkError(source->GetResponseCode()); } else { + request_ = old_request.Pass(); *should_retry_request = true; } return; |