Commit 90dc8b8b authored by bttk's avatar bttk Committed by Commit Bot

Remove GcmUma.onNativeLaunched

RecordHistogram can now be used without native.

Bug: 1069507
Change-Id: If4a6dd84b510f021f6e690df7e6e8d112e031caf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148042Reviewed-by: default avatarGang Wu <gangwu@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: bttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759377}
parent 0558f757
...@@ -9,10 +9,6 @@ import android.content.Context; ...@@ -9,10 +9,6 @@ import android.content.Context;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.task.PostTask;
import org.chromium.content_public.browser.BrowserStartupController;
import org.chromium.content_public.browser.BrowserStartupController.StartupCallback;
import org.chromium.content_public.browser.UiThreadTaskTraits;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -42,62 +38,28 @@ public class GcmUma { ...@@ -42,62 +38,28 @@ public class GcmUma {
} }
public static void recordDataMessageReceived(Context context, final boolean hasCollapseKey) { public static void recordDataMessageReceived(Context context, final boolean hasCollapseKey) {
onNativeLaunched(context, new Runnable() {
@Override public void run() {
// There is no equivalent of the GCM Store on Android in which we can fail to find a // There is no equivalent of the GCM Store on Android in which we can fail to find a
// registered app. It's not clear whether Google Play Services doesn't check for // registered app. It's not clear whether Google Play Services doesn't check for
// registrations, or only gives us messages that have one, but in either case we // registrations, or only gives us messages that have one, but in either case we
// should log true here. // should log true here.
RecordHistogram.recordBooleanHistogram( RecordHistogram.recordBooleanHistogram("GCM.DataMessageReceivedHasRegisteredApp", true);
"GCM.DataMessageReceivedHasRegisteredApp", true); RecordHistogram.recordCountHistogram("GCM.DataMessageReceived", 1);
RecordHistogram.recordCountHistogram(
"GCM.DataMessageReceived", 1);
RecordHistogram.recordBooleanHistogram( RecordHistogram.recordBooleanHistogram(
"GCM.DataMessageReceivedHasCollapseKey", hasCollapseKey); "GCM.DataMessageReceivedHasCollapseKey", hasCollapseKey);
} }
});
}
public static void recordGcmUpstreamHistogram(Context context, final int value) { public static void recordGcmUpstreamHistogram(Context context, final int value) {
onNativeLaunched(context, new Runnable() {
@Override public void run() {
RecordHistogram.recordEnumeratedHistogram( RecordHistogram.recordEnumeratedHistogram(
"Invalidations.GCMUpstreamRequest", value, UMA_UPSTREAM_COUNT); "Invalidations.GCMUpstreamRequest", value, UMA_UPSTREAM_COUNT);
} }
});
}
public static void recordDeletedMessages(Context context) { public static void recordDeletedMessages(Context context) {
onNativeLaunched(context, new Runnable() {
@Override public void run() {
RecordHistogram.recordCount1000Histogram( RecordHistogram.recordCount1000Histogram(
"GCM.DeletedMessagesReceived", 0 /* unknown deleted count */); "GCM.DeletedMessagesReceived", 0 /* unknown deleted count */);
} }
});
}
public static void recordWebPushReceivedDeviceState(@WebPushDeviceState int state) { public static void recordWebPushReceivedDeviceState(@WebPushDeviceState int state) {
RecordHistogram.recordEnumeratedHistogram( RecordHistogram.recordEnumeratedHistogram(
"GCM.WebPushReceived.DeviceState", state, WebPushDeviceState.NUM_ENTRIES); "GCM.WebPushReceived.DeviceState", state, WebPushDeviceState.NUM_ENTRIES);
} }
private static void onNativeLaunched(final Context context, final Runnable task) {
PostTask.postTask(UiThreadTaskTraits.DEFAULT, new Runnable() {
@Override
public void run() {
BrowserStartupController.getInstance().addStartupCompletedObserver(
new StartupCallback() {
@Override
public void onSuccess() {
task.run();
}
@Override
public void onFailure() {
// Startup failed.
}
});
}
});
}
} }
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