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

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

Issue 1438123002: Removed callbacks to JNI functions + added gzip compressed seed support & pulling response time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging this CL with master 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 d1efb22473b81c502b7a9ef64190b6a3c59cbd33..02fc45d4c5d7191bcf6c50c9d402b52254ea0047 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
@@ -66,8 +66,7 @@ public class VariationsSeedService extends IntentService {
connection.setReadTimeout(READ_TIMEOUT);
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) {
@@ -77,10 +76,12 @@ public class VariationsSeedService extends IntentService {
// Convert the InputStream into a byte array.
byte[] rawSeed = getRawSeed(connection);
- String signature = connection.getHeaderField("X-Seed-Signature");
- String country = connection.getHeaderField("X-Country");
+ String signature = getHeaderFieldOrEmpty(connection, "X-Seed-Signature");
+ String country = getHeaderFieldOrEmpty(connection, "X-Country");
+ String date = getHeaderFieldOrEmpty(connection, "Date");
+ boolean isGzipCompressed = getHeaderFieldOrEmpty(connection, "IM").equals("gzip");
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);
@@ -92,6 +93,14 @@ public class VariationsSeedService extends IntentService {
}
}
+ private String getHeaderFieldOrEmpty(HttpURLConnection connection, String name) {
+ String headerField = connection.getHeaderField(name);
+ if (headerField == null) {
+ return "";
+ }
+ return headerField.trim();
+ }
+
private byte[] getRawSeed(HttpURLConnection connection) throws IOException {
InputStream inputStream = null;
try {

Powered by Google App Engine
This is Rietveld 408576698