Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/Chromoting.java

Issue 607453004: Android Chromoting: Don't fetch auth token if there's a fetch pending. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/Chromoting.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
index f21efccb8eeda585a3eafaf16852bed1517fe911..be378904553fec2c44085415258644ed5443d4a1 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -96,6 +96,13 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
*/
boolean mTriedNewAuthToken;
+ /**
+ * Flag to track whether a call to AccountManager.getAuthToken() is currently pending.
+ * This avoids infinitely-nested calls in case onStart() gets triggered a second time
+ * while a token is being fetched.
+ */
+ private boolean mWaitingForAuthToken = false;
+
/** Shows a warning explaining that a Google account is required, then closes the activity. */
private void showNoAccountsDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -292,16 +299,27 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
}
private void refreshHostList() {
+ if (mWaitingForAuthToken) {
+ return;
+ }
+
mTriedNewAuthToken = false;
setHostListProgressVisible(true);
// The refresh button simply makes use of the currently-chosen account.
+ requestAuthToken();
+ }
+
+ private void requestAuthToken() {
AccountManager.get(this).getAuthToken(mAccount, TOKEN_SCOPE, null, this, this, null);
+ mWaitingForAuthToken = true;
}
@Override
public void run(AccountManagerFuture<Bundle> future) {
Log.i("auth", "User finished with auth dialogs");
+ mWaitingForAuthToken = false;
+
Bundle result = null;
String explanation = null;
try {
@@ -316,6 +334,7 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
}
if (result == null) {
+ setHostListProgressVisible(false);
if (explanation != null) {
Toast.makeText(this, explanation, Toast.LENGTH_LONG).show();
}
@@ -387,7 +406,7 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe
Log.w("auth", "Requesting renewal of rejected auth token");
authenticator.invalidateAuthToken(mAccount.type, mToken);
mToken = null;
- authenticator.getAuthToken(mAccount, TOKEN_SCOPE, null, this, this, null);
+ requestAuthToken();
Jamie 2014/09/26 21:31:17 Does this not also need to be guarded against reen
Lambros 2014/09/26 22:36:34 No, because we've got the token at this point, so
// We're not in an error state *yet*.
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698