summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-11 20:18:14 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-11 20:18:14 +0000
commit843fe4276bb2a001d6bdbb74dda7ef44a707cec7 (patch)
treeaf01f65e18a684a2d0849233624f9b8257d8870d /chrome
parentff8e80ecc662d9b2959881276393e9710ca875e2 (diff)
downloadchromium_src-843fe4276bb2a001d6bdbb74dda7ef44a707cec7.zip
chromium_src-843fe4276bb2a001d6bdbb74dda7ef44a707cec7.tar.gz
chromium_src-843fe4276bb2a001d6bdbb74dda7ef44a707cec7.tar.bz2
Invalidate ChromeToMobileService's |access_token_| on expiration.
Use OAuth2AccessTokenConsumer's expiration_time as intended. The majority of failure reports are caused by auth errors. BUG=102709,120941 TEST=Less UMA reports of search and send auth failures. Review URL: https://chromiumcodereview.appspot.com/10919202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chrome_to_mobile_service.cc13
-rw-r--r--chrome/browser/chrome_to_mobile_service.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/chrome/browser/chrome_to_mobile_service.cc b/chrome/browser/chrome_to_mobile_service.cc
index 58435a8..993fd2c 100644
--- a/chrome/browser/chrome_to_mobile_service.cc
+++ b/chrome/browser/chrome_to_mobile_service.cc
@@ -368,6 +368,15 @@ void ChromeToMobileService::OnGetTokenSuccess(
auth_retry_timer_.Stop();
access_token_ = access_token;
+ // Post a delayed task to invalidate the access token at its expiration time.
+ if (!content::BrowserThread::PostDelayedTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ChromeToMobileService::ClearAccessToken,
+ weak_ptr_factory_.GetWeakPtr()),
+ expiration_time - base::Time::Now())) {
+ NOTREACHED();
+ }
+
while (!task_queue_.empty()) {
// Post all tasks that were queued and waiting on a valid access token.
if (!content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
@@ -523,6 +532,10 @@ void ChromeToMobileService::SendJobRequest(base::WeakPtr<Observer> observer,
request->Start();
}
+void ChromeToMobileService::ClearAccessToken() {
+ access_token_.clear();
+}
+
void ChromeToMobileService::RequestAccessToken() {
// Register to observe Gaia login refresh token updates.
TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
diff --git a/chrome/browser/chrome_to_mobile_service.h b/chrome/browser/chrome_to_mobile_service.h
index 15f288c..569b3a1 100644
--- a/chrome/browser/chrome_to_mobile_service.h
+++ b/chrome/browser/chrome_to_mobile_service.h
@@ -202,6 +202,9 @@ class ChromeToMobileService : public ProfileKeyedService,
// Submit a cloud print job request with the requisite data.
void SendJobRequest(base::WeakPtr<Observer> observer, const JobData& data);
+ // Clear the cached cloud print auth access token.
+ void ClearAccessToken();
+
// Send the OAuth2AccessTokenFetcher request.
// Virtual for unit test mocking.
virtual void RequestAccessToken();