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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/profiles/ProfileDownloader.java

Issue 1256283002: GAIA ID migration for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: full version Created 5 years, 4 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
Index: chrome/android/java/src/org/chromium/chrome/browser/profiles/ProfileDownloader.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/profiles/ProfileDownloader.java b/chrome/android/java/src/org/chromium/chrome/browser/profiles/ProfileDownloader.java
index 286e99f1520d62476e501e30cefa230bfad330f6..5b67c393b01b1951dd50c4b81060e9d71ce95b41 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/profiles/ProfileDownloader.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/profiles/ProfileDownloader.java
@@ -4,11 +4,15 @@
package org.chromium.chrome.browser.profiles;
+import android.content.Context;
import android.graphics.Bitmap;
import org.chromium.base.ObserverList;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
+import org.chromium.chrome.browser.signin.AccountTrackerService;
+
+import java.util.ArrayList;
/**
* Android wrapper of the ProfileDownloader which provides access from the Java layer.
@@ -50,14 +54,74 @@ public class ProfileDownloader {
}
/**
+ * Private class to pend profile download requests when system accounts have not been seeded into
+ * AccountTrackerService. It listens onSystemAccountsSeedingComplete to finish pending requests.
+ */
+ private static class PendingProfileDownloads
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:21 Do we need this class or can ProfileDownloader its
gogerald1 2015/08/18 01:14:26 We could, but it would be a little readable to mak
+ implements AccountTrackerService.SystemAccountsSeedingObserver {
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:21 Nit: I think the java naming pattern would be: OnS
gogerald1 2015/08/18 01:14:26 Done.
+ private static PendingProfileDownloads sPendingProfileDownloads;
+
+ private ArrayList<Context> mContexts;
+ private ArrayList<Profile> mProfiles;
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:21 Why do we need arrays for context and profile? Th
gogerald1 2015/08/18 01:14:25 Done.
+ private ArrayList<String> mAccountIds;
+ private ArrayList<Integer> mImageSidePixels;
+
+ private PendingProfileDownloads() {
+ mContexts = new ArrayList<Context>();
+ mProfiles = new ArrayList<Profile>();
+ mAccountIds = new ArrayList<String>();
+ mImageSidePixels = new ArrayList<Integer>();
+ }
+
+ public static PendingProfileDownloads get(Context context) {
+ if (sPendingProfileDownloads == null) {
+ sPendingProfileDownloads = new PendingProfileDownloads();
+ AccountTrackerService.get(context).observeSystemAccountsSeeding(
+ sPendingProfileDownloads);
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:21 Nit: I think the java naming pattern would be: add
gogerald1 2015/08/18 01:14:25 Done.
+ }
+ return sPendingProfileDownloads;
+ }
+
+ public void pendProfileDownload(
+ Context context, Profile profile, String accountId, int imageSidePixels) {
+ mContexts.add(context);
+ mProfiles.add(profile);
+ mAccountIds.add(accountId);
+ mImageSidePixels.add(imageSidePixels);
+ if (AccountTrackerService.get(context).isSystemAccountsSeeded()) {
+ onSystemAccountsSeedingComplete();
+ }
+ }
+
+ public synchronized void onSystemAccountsSeedingComplete() {
+ int numberOfPendingRequests = mAccountIds.size();
+ while (numberOfPendingRequests > 0) {
+ // Pending requests here must be pre-signin request since SigninManager will wait
+ // system accounts been seeded into AccountTrackerService before finishing sign in.
+ startFetchingAccountInfoFor(mContexts.get(0), mProfiles.get(0), mAccountIds.get(0),
+ mImageSidePixels.get(0).intValue(), true);
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:21 Maybe call nativeStartFetchingAccountInfoFor() dir
gogerald1 2015/08/18 01:14:26 Done.
+ mContexts.remove(0);
+ mProfiles.remove(0);
+ mAccountIds.remove(0);
+ mImageSidePixels.remove(0);
+ }
+ }
+ }
+
+ /**
* Starts fetching the account information for a given account.
Roger Tawa OOO till Jul 10th 2015/08/14 15:01:21 Nit: add comment for new arg.
gogerald1 2015/08/18 01:14:26 Done.
* @param profile Profile associated with the request
* @param accountId Account name to fetch the information for
* @param imageSidePixels Request image side (in pixels)
*/
- public static void startFetchingAccountInfoFor(
- Profile profile, String accountId, int imageSidePixels, boolean isPreSignin) {
+ public static void startFetchingAccountInfoFor(Context context, Profile profile,
+ String accountId, int imageSidePixels, boolean isPreSignin) {
ThreadUtils.assertOnUiThread();
+ if (!AccountTrackerService.get(context).isSystemAccountsSeeded()) {
+ PendingProfileDownloads.get(context).pendProfileDownload(
+ context, profile, accountId, imageSidePixels);
+ return;
+ }
nativeStartFetchingAccountInfoFor(profile, accountId, imageSidePixels, isPreSignin);
}

Powered by Google App Engine
This is Rietveld 408576698