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

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

Issue 2804043002: Enable variations restrict param for Java-side fetches. (Closed)
Patch Set: Addressed comments. Created 3 years, 8 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: components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
diff --git a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
index 7f117590184ddb894530066a1f8b4447baa7c040..3c696771fbabb131a0d52a26dea20a6910d176e1 100644
--- a/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
+++ b/components/variations/android/java/src/org/chromium/components/variations/firstrun/VariationsSeedFetcher.java
@@ -77,15 +77,21 @@ public class VariationsSeedFetcher {
}
@VisibleForTesting
- protected HttpURLConnection getServerConnection() throws MalformedURLException, IOException {
- URL url = new URL(VARIATIONS_SERVER_URL);
+ protected HttpURLConnection getServerConnection(String restrictMode)
+ throws MalformedURLException, IOException {
+ String urlString = VARIATIONS_SERVER_URL;
+ if (restrictMode != null && !restrictMode.isEmpty()) {
+ urlString += "&restrict=" + restrictMode;
+ }
+ URL url = new URL(urlString);
return (HttpURLConnection) url.openConnection();
}
/**
* Fetch the first run variations seed.
+ * @param restrictMode The restrict mode parameter to pass to the server via a URL param.
*/
- public void fetchSeed() {
+ public void fetchSeed(String restrictMode) {
assert !ThreadUtils.runningOnUiThread();
// Prevent multiple simultaneous fetches
synchronized (sLock) {
@@ -100,7 +106,7 @@ public class VariationsSeedFetcher {
|| VariationsSeedBridge.hasNativePref(context)) {
return;
}
- downloadContent(context);
+ downloadContent(context, restrictMode);
prefs.edit().putBoolean(VARIATIONS_INITIALIZED_PREF, true).apply();
}
}
@@ -124,11 +130,11 @@ public class VariationsSeedFetcher {
histogram.record(timeDeltaMillis);
}
- private void downloadContent(Context context) {
+ private void downloadContent(Context context, String restrictMode) {
HttpURLConnection connection = null;
try {
long startTimeMillis = SystemClock.elapsedRealtime();
- connection = getServerConnection();
+ connection = getServerConnection(restrictMode);
connection.setReadTimeout(READ_TIMEOUT);
connection.setConnectTimeout(REQUEST_TIMEOUT);
connection.setDoInput(true);

Powered by Google App Engine
This is Rietveld 408576698