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..21642b8c1a7ea2edb9d0e56b553637205601123e 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 |
@@ -15,6 +15,7 @@ import java.io.InputStream; |
import java.net.HttpURLConnection; |
import java.net.MalformedURLException; |
import java.net.URL; |
+import java.util.Arrays; |
/** |
* Background service that fetches the variations seed before the actual first run of Chrome. |
@@ -48,7 +49,7 @@ public class VariationsSeedService extends IntentService { |
connection.setConnectTimeout(REQUEST_TIMEOUT); |
connection.setDoInput(true); |
// TODO(agulenko): add gzip compression support. |
- // connection.setRequestProperty("A-IM", "gzip"); |
+ connection.setRequestProperty("A-IM", "gzip"); |
connection.connect(); |
int responseCode = connection.getResponseCode(); |
if (responseCode != HttpURLConnection.HTTP_OK) { |
@@ -60,8 +61,10 @@ public class VariationsSeedService extends IntentService { |
byte[] rawSeed = getRawSeed(connection); |
String signature = connection.getHeaderField("X-Seed-Signature"); |
String country = connection.getHeaderField("X-Country"); |
+ String date = connection.getHeaderField("Date"); |
+ boolean isGzipCompressed = parseIMHeader(connection.getHeaderField("IM")); |
VariationsSeedBridge.setVariationsFirstRunSeed( |
- getApplicationContext(), rawSeed, signature, country); |
+ getApplicationContext(), rawSeed, signature, country, date, isGzipCompressed); |
return true; |
} catch (IOException e) { |
Log.w(TAG, "IOException fetching first run seed: ", e); |
@@ -73,6 +76,20 @@ public class VariationsSeedService extends IntentService { |
} |
} |
+ private boolean parseIMHeader(String header) { |
+ String[] values = header.split(","); |
+ |
+ for (int i = 0; i < values.length; ++i) values[i] = values[i].trim(); |
+ |
+ final int gzipIM = Arrays.asList(values).indexOf("gzip"); |
+ int imCount = (gzipIM != -1 ? 1 : 0); |
+ if (imCount != values.length) { |
Alexei Svitkine (slow)
2015/11/12 22:25:29
Hmm, so thinking about this more - if there's anyt
Alexander Agulenko
2015/11/12 22:37:55
Done.
|
+ Log.w(TAG, "Unrecognized instance manipulations in " + header |
+ + "; only gzip is supported"); |
+ } |
+ return (gzipIM != -1); |
+ } |
+ |
private byte[] getRawSeed(HttpURLConnection connection) throws IOException { |
InputStream inputStream = null; |
try { |