зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1270213 - Update TelemetryUploadService to use doc ID. r=sebastian
This is not yet expected to compile. MozReview-Commit-ID: FQF6z5ni6jC --HG-- extra : rebase_source : bd7ccc97e44a17f66122242d28e030762c645ee9
This commit is contained in:
Родитель
efe06ac7a9
Коммит
e0f8ab936b
|
@ -32,6 +32,7 @@ import java.security.GeneralSecurityException;
|
|||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
@ -90,11 +91,11 @@ public class TelemetryUploadService extends IntentService {
|
|||
}
|
||||
|
||||
final String serverSchemeHostPort = getServerSchemeHostPort(context);
|
||||
final HashSet<Integer> successfulUploadIDs = new HashSet<>(pingsToUpload.size()); // used for side effects.
|
||||
final HashSet<String> successfulUploadIDs = new HashSet<>(pingsToUpload.size()); // used for side effects.
|
||||
final PingResultDelegate delegate = new PingResultDelegate(successfulUploadIDs);
|
||||
for (final TelemetryPing ping : pingsToUpload) {
|
||||
// TODO: It'd be great to re-use the same HTTP connection for each upload request.
|
||||
delegate.setPingID(ping.getUniqueID());
|
||||
delegate.setDocID(ping.getDocID());
|
||||
final String url = serverSchemeHostPort + "/" + ping.getURLPath();
|
||||
uploadPayload(url, ping.getPayload(), delegate);
|
||||
|
||||
|
@ -230,13 +231,13 @@ public class TelemetryUploadService extends IntentService {
|
|||
private static final int SOCKET_TIMEOUT_MILLIS = (int) TimeUnit.SECONDS.toMillis(30);
|
||||
private static final int CONNECTION_TIMEOUT_MILLIS = (int) TimeUnit.SECONDS.toMillis(30);
|
||||
|
||||
/** The store ID of the ping currently being uploaded. Use {@link #getPingID()} to access it. */
|
||||
private int pingID = -1;
|
||||
private final HashSet<Integer> successfulUploadIDs;
|
||||
/** The store ID of the ping currently being uploaded. Use {@link #getDocID()} to access it. */
|
||||
private String docID = null;
|
||||
private final Set<String> successfulUploadIDs;
|
||||
|
||||
private boolean hadConnectionError = false;
|
||||
|
||||
public PingResultDelegate(final HashSet<Integer> successfulUploadIDs) {
|
||||
public PingResultDelegate(final Set<String> successfulUploadIDs) {
|
||||
super();
|
||||
this.successfulUploadIDs = successfulUploadIDs;
|
||||
}
|
||||
|
@ -251,15 +252,15 @@ public class TelemetryUploadService extends IntentService {
|
|||
return CONNECTION_TIMEOUT_MILLIS;
|
||||
}
|
||||
|
||||
private int getPingID() {
|
||||
if (pingID < 0) {
|
||||
private String getDocID() {
|
||||
if (docID == null) {
|
||||
throw new IllegalStateException("Expected ping ID to have been updated before retrieval");
|
||||
}
|
||||
return pingID;
|
||||
return docID;
|
||||
}
|
||||
|
||||
public void setPingID(final int id) {
|
||||
pingID = id;
|
||||
public void setDocID(final String id) {
|
||||
docID = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -273,7 +274,7 @@ public class TelemetryUploadService extends IntentService {
|
|||
switch (status) {
|
||||
case 200:
|
||||
case 201:
|
||||
successfulUploadIDs.add(getPingID());
|
||||
successfulUploadIDs.add(getDocID());
|
||||
break;
|
||||
default:
|
||||
Log.w(LOGTAG, "Telemetry upload failure. HTTP status: " + status);
|
||||
|
|
Загрузка…
Ссылка в новой задаче