Bug 1457472 - [1.1] Simplify telemetry snapshot API to reflect new implementation constraints. r=snorp,jchen

This commit is contained in:
Eugen Sawin 2018-05-15 15:13:24 +02:00
Родитель 94bd85ef62
Коммит 9c403f8953
1 изменённых файлов: 8 добавлений и 74 удалений

Просмотреть файл

@ -6,15 +6,7 @@
package org.mozilla.geckoview;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.json.JSONException;
import org.json.JSONObject;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import org.mozilla.gecko.EventDispatcher;
@ -31,48 +23,6 @@ public final class RuntimeTelemetry {
private final GeckoRuntime mRuntime;
private final EventDispatcher mEventDispatcher;
@Retention(RetentionPolicy.SOURCE)
@IntDef({ DATASET_BASE, DATASET_EXTENDED })
public @interface DatasetType {}
// Match with nsITelemetry.
/**
* The base dataset suitable for release builds.
*/
public static final int DATASET_BASE = 0;
/**
* The extended dataset suitable for pre-release builds.
*/
public static final int DATASET_EXTENDED = 1;
@IntDef(flag = true,
value = { SNAPSHOT_HISTOGRAMS, SNAPSHOT_KEYED_HISTOGRAMS,
SNAPSHOT_SCALARS, SNAPSHOT_KEYED_SCALARS,
SNAPSHOT_ALL })
public @interface SnapshotType {}
// Match with GeckoViewTelemetryController.
/**
* Adds a "histogram" object entry to the snapshot response.
*/
public static final int SNAPSHOT_HISTOGRAMS = 1 << 0;
/**
* Adds a "keyedHistogram" object entry to the snapshot response.
*/
public static final int SNAPSHOT_KEYED_HISTOGRAMS = 1 << 1;
/**
* Adds a "scalars" object entry to the snapshot response.
*/
public static final int SNAPSHOT_SCALARS = 1 << 2;
/**
* Adds a "keyedScalars" object entry to the snapshot response.
*/
public static final int SNAPSHOT_KEYED_SCALARS = 1 << 3;
/**
* Adds all snapshot types to the response.
*/
public static final int SNAPSHOT_ALL = (1 << 4) - 1;
/* package */ RuntimeTelemetry(final @NonNull GeckoRuntime runtime) {
mRuntime = runtime;
mEventDispatcher = EventDispatcher.getInstance();
@ -80,37 +30,21 @@ public final class RuntimeTelemetry {
/**
* Retrieve all telemetry snapshots.
* The response bundle will contain following snapshots:
* <ul>
* <li>histograms</li>
* <li>keyedHistograms</li>
* <li>scalars</li>
* <li>keyedScalars</li>
* </ul>
*
* @param dataset The dataset type to retreive.
* One of {@link #DATASET_BASE DATASET_*} flags.
* @param clear Whether the retrieved snapshots should be cleared.
* @param response Used to return the async response.
*/
public void getSnapshots(
final @DatasetType int dataset,
final boolean clear,
final @NonNull GeckoResponse<GeckoBundle> response) {
getSnapshots(SNAPSHOT_ALL, dataset, clear, response);
}
/**
* Retrieve the requested telemetry snapshots.
*
* @param types The requested snapshot types.
* One or more of {@link #SNAPSHOT_HISTOGRAMS SNAPSHOT_*} flags.
* @param dataset The dataset type to retreive.
* One of {@link #DATASET_BASE DATASET_*} flags.
* @param clear Whether the retrieved snapshots should be cleared.
* @param response Used to return the async response.
*/
public void getSnapshots(
final @SnapshotType int types,
final @DatasetType int dataset,
final boolean clear,
final @NonNull GeckoResponse<GeckoBundle> response) {
final GeckoBundle msg = new GeckoBundle(3);
msg.putInt("types", types);
msg.putInt("dataset", dataset);
final GeckoBundle msg = new GeckoBundle(1);
msg.putBoolean("clear", clear);
mEventDispatcher.dispatch("GeckoView:TelemetrySnapshots", msg,