author | Bogdan Tara <btara@mozilla.com> |
Tue, 24 Apr 2018 01:27:50 +0300 | |
changeset 468702 | cac46e410f9911d8748d8366c7ec939c71cebbee |
parent 468701 | 781457239e63258ea069ccdd16ebaadb6c5fa33b |
child 468703 | 45c6f888c2acabcc8076ce8220e0993f2aee88df |
push id | 9165 |
push user | asasaki@mozilla.com |
push date | Thu, 26 Apr 2018 21:04:54 +0000 |
treeherder | mozilla-beta@064c3804de2e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | backout |
bugs | 1437551 |
milestone | 61.0a1 |
backs out | 781457239e63258ea069ccdd16ebaadb6c5fa33b 2f30bed5423644f54c7d8ef3115427f3f6e52382 6badc13e1d210c59ee161e7dc52b9e5a34811cce 5582b64d4a8b25276cfe1f4e035e37fbd7701f6b |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java +++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java @@ -52,17 +52,16 @@ import org.mozilla.gecko.text.TextSelect import org.mozilla.gecko.util.ActivityUtils; import org.mozilla.gecko.util.ColorUtil; import org.mozilla.gecko.util.GeckoBundle; import org.mozilla.gecko.util.IntentUtils; import org.mozilla.gecko.util.PackageUtil; import org.mozilla.gecko.webapps.WebApps; import org.mozilla.gecko.widget.ActionModePresenter; import org.mozilla.gecko.widget.GeckoPopupMenu; -import org.mozilla.geckoview.GeckoResponse; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.geckoview.GeckoView; import java.util.List; public class CustomTabsActivity extends AppCompatActivity @@ -600,17 +599,17 @@ public class CustomTabsActivity extends public void onCanGoForward(GeckoSession session, boolean canGoForward) { mCanGoForward = canGoForward; updateMenuItemForward(); } @Override public void onLoadRequest(final GeckoSession session, final String urlStr, final int target, - final GeckoResponse<Boolean> response) { + final GeckoSession.Response<Boolean> response) { if (target != GeckoSession.NavigationDelegate.TARGET_WINDOW_NEW) { response.respond(false); return; } final Uri uri = Uri.parse(urlStr); if (uri == null) { // We can't handle this, so deny it. @@ -641,17 +640,17 @@ public class CustomTabsActivity extends } } response.respond(true); } @Override public void onNewSession(final GeckoSession session, final String uri, - final GeckoResponse<GeckoSession> response) { + final GeckoSession.Response<GeckoSession> response) { // We should never get here because we abort loads that need a new session in onLoadRequest() throw new IllegalStateException("Unexpected new session"); } /* GeckoSession.ProgressDelegate */ @Override public void onPageStart(GeckoSession session, String url) { mCurrentUrl = url;
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java +++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java @@ -32,17 +32,16 @@ import org.mozilla.gecko.preferences.Gec import org.mozilla.gecko.R; import org.mozilla.gecko.customtabs.CustomTabsActivity; import org.mozilla.gecko.permissions.Permissions; import org.mozilla.gecko.prompts.PromptService; import org.mozilla.gecko.text.TextSelection; import org.mozilla.gecko.util.ActivityUtils; import org.mozilla.gecko.util.ColorUtil; import org.mozilla.gecko.widget.ActionModePresenter; -import org.mozilla.geckoview.GeckoResponse; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.geckoview.GeckoView; public class WebAppActivity extends AppCompatActivity implements ActionModePresenter, GeckoSession.ContentDelegate, @@ -369,17 +368,17 @@ public class WebAppActivity extends AppC @Override // GeckoSession.ContentDelegate public void onFullScreen(GeckoSession session, boolean fullScreen) { updateFullScreenContent(fullScreen); } @Override public void onLoadRequest(final GeckoSession session, final String urlStr, final int target, - final GeckoResponse<Boolean> response) { + final GeckoSession.Response<Boolean> response) { final Uri uri = Uri.parse(urlStr); if (uri == null) { // We can't really handle this, so deny it? Log.w(LOGTAG, "Failed to parse URL for navigation: " + urlStr); response.respond(true); return; } @@ -421,17 +420,17 @@ public class WebAppActivity extends AppC Log.w(LOGTAG, "No activity handler found for: " + urlStr); } } response.respond(true); } @Override public void onNewSession(final GeckoSession session, final String uri, - final GeckoResponse<GeckoSession> response) { + final GeckoSession.Response<GeckoSession> response) { // We should never get here because we abort loads that need a new session in onLoadRequest() throw new IllegalStateException("Unexpected new session"); } private void updateFullScreen() { boolean fullScreen = mIsFullScreenContent || mIsFullScreenMode; if (ActivityUtils.isFullScreen(this) == fullScreen) { return;
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java @@ -1,16 +1,15 @@ /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.mozilla.geckoview.test; -import org.mozilla.geckoview.GeckoResponse; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.geckoview.GeckoView; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoRuntimeSettings; import android.app.Activity; import android.content.Intent; @@ -39,23 +38,23 @@ public class TestRunnerActivity extends @Override public void onCanGoForward(GeckoSession session, boolean canGoForward) { } @Override public void onLoadRequest(GeckoSession session, String uri, int target, - GeckoResponse<Boolean> response) { + GeckoSession.Response<Boolean> response) { // Allow Gecko to load all URIs response.respond(false); } @Override - public void onNewSession(GeckoSession session, String uri, GeckoResponse<GeckoSession> response) { + public void onNewSession(GeckoSession session, String uri, GeckoSession.Response<GeckoSession> response) { response.respond(createSession(session.getSettings())); } }; private GeckoSession.ContentDelegate mContentDelegate = new GeckoSession.ContentDelegate() { @Override public void onTitleChange(GeckoSession session, String title) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/BasicSelectionActionDelegate.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/BasicSelectionActionDelegate.java @@ -59,17 +59,17 @@ public class BasicSelectionActionDelegat protected final RectF mTempRect = new RectF(); private boolean mExternalActionsEnabled; protected ActionMode mActionMode; protected GeckoSession mSession; protected Selection mSelection; protected List<String> mActions; - protected GeckoResponse<String> mResponse; + protected GeckoSession.Response<String> mResponse; protected boolean mRepopulatedMenu; @TargetApi(Build.VERSION_CODES.M) private class Callback2Wrapper extends ActionMode.Callback2 { @Override public boolean onCreateActionMode(final ActionMode actionMode, final Menu menu) { return BasicSelectionActionDelegate.this.onCreateActionMode(actionMode, menu); } @@ -345,17 +345,17 @@ public class BasicSelectionActionDelegat mTempMatrix.mapRect(mTempRect, mSelection.clientRect); mTempRect.roundOut(outRect); } @TargetApi(Build.VERSION_CODES.M) @Override public void onShowActionRequest(final GeckoSession session, final Selection selection, final String[] actions, - final GeckoResponse<String> response) { + final GeckoSession.Response<String> response) { mSession = session; mSelection = selection; mActions = Arrays.asList(actions); mResponse = response; if (mActionMode != null) { if (actions.length > 0) { mActionMode.invalidate();
deleted file mode 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * vim: ts=4 sw=4 expandtab: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.geckoview; - -/** - * This is used to receive async responses from delegate methods. - */ -public interface GeckoResponse<T> { - /** - * Called when async processing has finished. - * - * @param value The value contained in the response. - */ - void respond(T value); -}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java @@ -15,30 +15,29 @@ import android.util.Log; import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoThread; import org.mozilla.gecko.PrefsHelper; import org.mozilla.gecko.util.BundleEventListener; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.GeckoBundle; -import org.mozilla.gecko.util.ThreadUtils; public final class GeckoRuntime implements Parcelable { private static final String LOGTAG = "GeckoRuntime"; private static final boolean DEBUG = false; private static GeckoRuntime sDefaultRuntime; /** * Get the default runtime for the given context. * This will create and initialize the runtime with the default settings. * * Note: Only use this for session-less apps. - * For regular apps, use create() instead. + * For regular apps, use create() and createSession() instead. * * @return The (static) default runtime for the context. */ public static synchronized @NonNull GeckoRuntime getDefault( final @NonNull Context context) { Log.d(LOGTAG, "getDefault"); if (sDefaultRuntime == null) { sDefaultRuntime = new GeckoRuntime(); @@ -46,17 +45,16 @@ public final class GeckoRuntime implemen sDefaultRuntime.init(new GeckoRuntimeSettings()); } return sDefaultRuntime; } private GeckoRuntimeSettings mSettings; private Delegate mDelegate; - private RuntimeTelemetry mTelemetry; /** * Attach the runtime to the given context. * * @param context The new context to attach to. */ public void attachTo(final @NonNull Context context) { if (DEBUG) { @@ -191,31 +189,16 @@ public final class GeckoRuntime implemen public GeckoRuntimeSettings getSettings() { return mSettings; } /* package */ void setPref(final String name, final Object value) { PrefsHelper.setPref(name, value, /* flush */ false); } - /** - * Return the telemetry object for this runtime. - * - * @return The telemetry object. - */ - public RuntimeTelemetry getTelemetry() { - ThreadUtils.assertOnUiThread(); - - if (mTelemetry == null) { - mTelemetry = new RuntimeTelemetry(this); - } - return mTelemetry; - - } - @Override // Parcelable public int describeContents() { return 0; } @Override // Parcelable public void writeToParcel(Parcel out, int flags) { out.writeParcelable(mSettings, flags);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -176,26 +176,26 @@ public class GeckoSession extends LayerS delegate.onCanGoBack(GeckoSession.this, message.getBoolean("canGoBack")); delegate.onCanGoForward(GeckoSession.this, message.getBoolean("canGoForward")); } else if ("GeckoView:OnLoadRequest".equals(event)) { final String uri = message.getString("uri"); final int where = convertGeckoTarget(message.getInt("where")); delegate.onLoadRequest(GeckoSession.this, uri, where, - new GeckoResponse<Boolean>() { + new Response<Boolean>() { @Override public void respond(Boolean handled) { callback.sendSuccess(handled); } }); } else if ("GeckoView:OnNewSession".equals(event)) { final String uri = message.getString("uri"); delegate.onNewSession(GeckoSession.this, uri, - new GeckoResponse<GeckoSession>() { + new Response<GeckoSession>() { @Override public void respond(GeckoSession session) { if (session == null) { callback.sendSuccess(null); return; } if (session.isOpen()) { @@ -358,17 +358,17 @@ public class GeckoSession extends LayerS final GeckoBundle message, final EventCallback callback) { if ("GeckoView:ShowSelectionAction".equals(event)) { final SelectionActionDelegate.Selection selection = new SelectionActionDelegate.Selection(message); final String[] actions = message.getStringArray("actions"); final int seqNo = message.getInt("seqNo"); - final GeckoResponse<String> response = new GeckoResponse<String>() { + final Response<String> response = new Response<String>() { @Override public void respond(final String action) { final GeckoBundle response = new GeckoBundle(2); response.putString("id", action); response.putInt("seqNo", seqNo); callback.sendSuccess(response); } }; @@ -1119,17 +1119,17 @@ public class GeckoSession extends LayerS * Save the current browsing session state of this GeckoSession. This session state * includes the history, scroll position, zoom, and any form data that has been entered, * but does not include information pertaining to the GeckoSession itself (for example, * this does not include settings on the GeckoSession). * * @param response This is a response which will be called with the state once it has been * saved. Can be null if we fail to save the state for any reason. */ - public void saveState(final GeckoResponse<SessionState> response) { + public void saveState(final Response<SessionState> response) { mEventDispatcher.dispatch("GeckoView:SaveState", null, new EventCallback() { @Override public void sendSuccess(final Object result) { response.respond(new SessionState((String) result)); } @Override public void sendError(final Object result) { @@ -2000,17 +2000,17 @@ public class GeckoSession extends LayerS * @param selection Current selection attributes. * @param actions Array of built-in actions available; possible values * come from the {@link #ACTION_CUT ACTION_*} constants. * @param response Callback object for performing built-in actions. For example, * {@code response.respond(actions[0])} performs the first action. May be used * multiple times to perform multiple actions at once. */ void onShowActionRequest(GeckoSession session, Selection selection, - @Action String[] actions, GeckoResponse<String> response); + @Action String[] actions, Response<String> response); @IntDef({HIDE_REASON_NO_SELECTION, HIDE_REASON_INVISIBLE_SELECTION, HIDE_REASON_ACTIVE_SELECTION, HIDE_REASON_ACTIVE_SCROLL}) @interface HideReason {} /** @@ -2043,16 +2043,26 @@ public class GeckoSession extends LayerS * * @param session The GeckoSession that initiated the callback. * @param reason The reason that actions are no longer available, as one of the * {@link #HIDE_REASON_NO_SELECTION HIDE_REASON_*} constants. */ void onHideAction(GeckoSession session, @HideReason int reason); } + /** + * This is used to send responses in delegate methods that have asynchronous responses. + */ + public interface Response<T> { + /** + * @param val The value contained in the response + */ + void respond(T val); + } + public interface NavigationDelegate { /** * A view has started loading content from the network. * @param session The GeckoSession that initiated the callback. * @param url The resource being loaded. */ void onLocationChange(GeckoSession session, String url); @@ -2088,29 +2098,29 @@ public class GeckoSession extends LayerS * @param target The target where the window has requested to open. One of * TARGET_WINDOW_*. * @param response A response which will state whether or not the load * was handled. If unhandled, Gecko will continue the * load as normal. */ void onLoadRequest(GeckoSession session, String uri, @TargetWindow int target, - GeckoResponse<Boolean> response); + Response<Boolean> response); /** * A request has been made to open a new session. The URI is provided only for * informational purposes. Do not call GeckoSession.loadUri() here. Additionally, the * returned GeckoSession must be a newly-created one. * * @param session The GeckoSession that initiated the callback. * @param uri The URI to be loaded. * * @param response A Response which will hold the returned GeckoSession */ - void onNewSession(GeckoSession session, String uri, GeckoResponse<GeckoSession> response); + void onNewSession(GeckoSession session, String uri, Response<GeckoSession> response); } /** * GeckoSession applications implement this interface to handle prompts triggered by * content in the GeckoSession, such as alerts, authentication dialogs, and select list * pickers. **/ public interface PromptDelegate {
deleted file mode 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/RuntimeTelemetry.java +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * vim: ts=4 sw=4 expandtab: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -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; -import org.mozilla.gecko.util.GeckoBundle; -import org.mozilla.gecko.util.EventCallback; - -/** - * The telemetry API gives access to telemetry data of the Gecko runtime. - */ -public final class RuntimeTelemetry { - private final static String LOGTAG = "GeckoViewTelemetry"; - private final static boolean DEBUG = false; - - 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(); - } - - /** - * Retrieve all telemetry snapshots. - * - * @param dataset The dataset type to retreive. - * One of {@link #RuntimeTelemetry.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 #RuntimeTelemetry.SNAPSHOT_HISTOGRAMS SNAPSHOT_*} flags. - * @param dataset The dataset type to retreive. - * One of {@link #RuntimeTelemetry.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); - msg.putBoolean("clear", clear); - - mEventDispatcher.dispatch("GeckoView:TelemetrySnapshots", msg, - new EventCallback() { - @Override - public void sendSuccess(final Object result) { - response.respond((GeckoBundle) result); - } - - @Override - public void sendError(final Object error) { - Log.e(LOGTAG, "getSnapshots failed: " + error); - response.respond(null); - } - }); - } -}
--- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java +++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java @@ -12,19 +12,19 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.SystemClock; import android.util.Log; import android.view.WindowManager; import java.util.Locale; -import org.mozilla.geckoview.GeckoResponse; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.GeckoSessionSettings; +import org.mozilla.geckoview.GeckoSession.Response; import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate; import org.mozilla.geckoview.GeckoView; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoRuntimeSettings; public class GeckoViewActivity extends Activity { private static final String LOGTAG = "GeckoViewActivity"; private static final String DEFAULT_URL = "https://mozilla.org"; @@ -359,23 +359,23 @@ public class GeckoViewActivity extends A } @Override public void onCanGoForward(GeckoSession session, boolean value) { } @Override public void onLoadRequest(final GeckoSession session, final String uri, - final int target, GeckoResponse<Boolean> response) { + final int target, Response<Boolean> response) { Log.d(LOGTAG, "onLoadRequest=" + uri + " where=" + target); response.respond(false); } @Override - public void onNewSession(final GeckoSession session, final String uri, GeckoResponse<GeckoSession> response) { + public void onNewSession(final GeckoSession session, final String uri, Response<GeckoSession> response) { response.respond(null); } } private class MyTrackingProtection implements GeckoSession.TrackingProtectionDelegate { private int mBlockedAds = 0; private int mBlockedAnalytics = 0; private int mBlockedSocial = 0;
--- a/toolkit/components/telemetry/geckoview/GeckoViewTelemetryController.jsm +++ b/toolkit/components/telemetry/geckoview/GeckoViewTelemetryController.jsm @@ -3,111 +3,32 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm"); XPCOMUtils.defineLazyModuleGetters(this, { - EventDispatcher: "resource://gre/modules/Messaging.jsm", Services: "resource://gre/modules/Services.jsm", TelemetryUtils: "resource://gre/modules/TelemetryUtils.jsm", }); GeckoViewUtils.initLogging("GeckoView.TelemetryController", this); var EXPORTED_SYMBOLS = ["GeckoViewTelemetryController"]; /* global debug warn */ -/** - * Telemetry snapshot API adaptors used to retrieve one or more snapshots - * for GeckoView:TelemetrySnapshots requests. - * Match with RuntimeTelemetry.SNAPSHOT_* and nsITelemetry.idl. - */ -const TelemetrySnapshots = [ - { - type: "histograms", - flag: (1 << 0), - get: (dataset, clear) => Services.telemetry.snapshotHistograms( - dataset, false, clear) - }, - { - type: "keyedHistograms", - flag: (1 << 1), - get: (dataset, clear) => Services.telemetry.snapshotKeyedHistograms( - dataset, false, clear) - }, - { - type: "scalars", - flag: (1 << 2), - get: (dataset, clear) => Services.telemetry.snapshotScalars( - dataset, clear) - }, - { - type: "keyedScalars", - flag: (1 << 3), - get: (dataset, clear) => Services.telemetry.snapshotKeyedScalars( - dataset, clear) - }, -]; - -const GeckoViewTelemetryController = { +let GeckoViewTelemetryController = { /** * Setup the Telemetry recording flags. This must be called * in all the processes that need to collect Telemetry. */ setup() { debug `setup`; TelemetryUtils.setTelemetryRecordingFlags(); debug `setup - canRecordPrereleaseData ${Services.telemetry.canRecordPrereleaseData }, canRecordReleaseData ${Services.telemetry.canRecordReleaseData}`; - - if (GeckoViewUtils.IS_PARENT_PROCESS) { - try { - EventDispatcher.instance.registerListener(this, [ - "GeckoView:TelemetrySnapshots", - ]); - } catch (e) { - warn `Failed registering GeckoView:TelemetrySnapshots listener: ${e}`; - } - } - }, - - /** - * Handle GeckoView:TelemetrySnapshots requests. - * Match with RuntimeTelemetry.getSnapshots. - * - * @param aEvent Name of the event to dispatch. - * @param aData Optional object containing data for the event. - * @param aCallback Optional callback implementing nsIAndroidEventCallback. - */ - onEvent(aEvent, aData, aCallback) { - debug `onEvent: aEvent=${aEvent}, aData=${aData}`; - - if (aEvent !== "GeckoView:TelemetrySnapshots") { - warn `Received unexpected event ${aEvent}`; - return; - } - - const { clear, types, dataset } = aData; - let snapshots = {}; - - // Iterate over all snapshot types, retreive and assemble results. - for (const tel of TelemetrySnapshots) { - if ((tel.flag & types) == 0) { - // This snapshot type has not been requested. - continue; - } - const snapshot = tel.get(dataset, clear); - if (!snapshot) { - aCallback.onError(`Failed retrieving ${tel.type} snapshot!`); - return; - } - snapshots[tel.type] = snapshot; - } - - aCallback.onSuccess(snapshots); }, };