Commit ff1ede73 authored by Pâris MEULEMAN's avatar Pâris MEULEMAN Committed by Commit Bot

Remove unused method GetAccessTokenWithTimeout

This method was only used by disabled tests. The need for this function was removed
by modifying those tests https://crrev.com/c/1609900.

Bug: 960281
Change-Id: If44a9681251080c9212faf395872a561382cf04c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609825
Auto-Submit: Pâris Meuleman <pmeuleman@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659408}
parent fbb899d5
...@@ -23,11 +23,8 @@ import java.util.Arrays; ...@@ -23,11 +23,8 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* Java instance for the native OAuth2TokenService. * Java instance for the native OAuth2TokenService.
...@@ -256,49 +253,6 @@ public final class OAuth2TokenService ...@@ -256,49 +253,6 @@ public final class OAuth2TokenService
}); });
} }
/**
* Call this method to retrieve an OAuth2 access token for the given account and scope. This
* method times out after the specified timeout, and will return null if that happens.
*
* Given that this is a blocking method call, this should never be called from the UI thread.
*
* @param account the account to get the access token for.
* @param scope The scope to get an auth token for (without Android-style 'oauth2:' prefix).
* @param timeout the timeout.
* @param unit the unit for |timeout|.
*/
@VisibleForTesting
public static String getAccessTokenWithTimeout(
Account account, String scope, long timeout, TimeUnit unit) {
assert !ThreadUtils.runningOnUiThread();
final AtomicReference<String> result = new AtomicReference<>();
final Semaphore semaphore = new Semaphore(0);
getAccessToken(account, scope, new GetAccessTokenCallback() {
@Override
public void onGetTokenSuccess(String token) {
result.set(token);
semaphore.release();
}
@Override
public void onGetTokenFailure(boolean isTransientError) {
result.set(null);
semaphore.release();
}
});
try {
if (semaphore.tryAcquire(timeout, unit)) {
return result.get();
} else {
Log.d(TAG, "Failed to retrieve auth token within timeout (%s %s)", timeout, unit);
return null;
}
} catch (InterruptedException e) {
Log.w(TAG, "Got interrupted while waiting for auth token");
return null;
}
}
/** /**
* Called by native to check whether the account has an OAuth2 refresh token. * Called by native to check whether the account has an OAuth2 refresh token.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment