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

Unified Diff: components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedService.java

Issue 1437833004: Implemented clearing Java prefs after pulling variations first run seed from Java to C++ side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor code review fixes Created 5 years, 1 month 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: components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedService.java
diff --git a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedService.java b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedService.java
index c752d884b1fb67c05c0648f2f4bd1d2de2d90f26..daf433d20a828665c5cfc9610b39d451ad29065f 100644
--- a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedService.java
+++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedService.java
@@ -27,16 +27,29 @@ public class VariationsSeedService extends IntentService {
private static final int READ_TIMEOUT = 10000; // time in ms
private static final int REQUEST_TIMEOUT = 15000; // time in ms
+ // Static variable that indicates a status of the variations seed fetch. If one request is in
+ // progress, we do not start another fetch.
+ private static boolean sFetchInProgress = false;
+
public VariationsSeedService() {
super(TAG);
}
@Override
public void onHandleIntent(Intent intent) {
+ // Check if any variations seed fetch is in progress, or the seed has been already fetched,
+ // or seed has been successfully stored on the C++ side.
+ if (sFetchInProgress || VariationsSeedBridge.hasJavaPref(getApplicationContext())
+ || VariationsSeedBridge.hasNativePref(getApplicationContext())) {
+ return;
+ }
+ sFetchInProgress = true;
try {
downloadContent(new URL(VARIATIONS_SERVER_URL));
} catch (MalformedURLException e) {
Log.w(TAG, "Variations server URL is malformed.", e);
+ } finally {
+ sFetchInProgress = false;
}
}

Powered by Google App Engine
This is Rietveld 408576698