Commit 4667f21d authored by petewil's avatar petewil Committed by Commit bot

Switch to currentTimeMillis, persist task

Since we are persisting our GCM Network Manager task across reboots,
we need to switch to a type of time that will work reliably across
reboots.

We consisered SystemClock.elapsedRealtime, but we think that bad UMA
samples will be more likely from reboots than the user adjusting
wall clock time.

BUG=612325

Review-Url: https://codereview.chromium.org/2037213002
Cr-Commit-Position: refs/heads/master@{#397877}
parent 071378ae
......@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.offlinepages;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import com.google.android.gms.gcm.GcmNetworkManager;
import com.google.android.gms.gcm.OneoffTask;
......@@ -35,7 +34,7 @@ public class BackgroundScheduler {
// Triggering conditions will include network state and charging requirements, maybe
// also battery percentage.
Bundle taskExtras = new Bundle();
taskExtras.putLong(DATE_TAG, SystemClock.elapsedRealtime());
taskExtras.putLong(DATE_TAG, System.currentTimeMillis());
Task task = new OneoffTask.Builder()
.setService(ChromeBackgroundService.class)
......@@ -45,6 +44,7 @@ public class BackgroundScheduler {
.setRequiredNetwork(Task.NETWORK_STATE_CONNECTED)
.setRequiresCharging(false)
.setExtras(taskExtras)
.setPersisted(true)
.build();
gcmNetworkManager.schedule(task);
......
......@@ -9,7 +9,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Environment;
import android.os.SystemClock;
import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram;
......@@ -206,7 +205,7 @@ public class OfflinePageUtils {
* Records UMA data when the Offline Pages Background Load service awakens.
* @param context android context
*/
public static void recordWakeupUMA(Context context, long millisSinceBootTask) {
public static void recordWakeupUMA(Context context, long taskScheduledTimeMillis) {
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
// Note this is a sticky intent, so we aren't really registering a receiver, just getting
// the sticky intent. That means that we don't need to unregister the filter later.
......@@ -228,8 +227,8 @@ public class OfflinePageUtils {
connectionType, ConnectionType.CONNECTION_LAST + 1);
// Collect UMA on the time since the request started.
long milliSinceBootNow = SystemClock.elapsedRealtime();
long delayInMilliseconds = milliSinceBootNow - millisSinceBootTask;
long nowMillis = System.currentTimeMillis();
long delayInMilliseconds = nowMillis - taskScheduledTimeMillis;
if (delayInMilliseconds <= 0) {
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment