Bug 1518843 - Move CallbackResult out of GeckoSession. r=snorp
authorAgi Sferro <agi@mozilla.com>
Tue, 16 Apr 2019 18:33:02 +0000
changeset 469764 4a6e7c0051cb
parent 469763 48f975c56cc6
child 469765 7c149c2cd4a9
push id35882
push usercbrindusan@mozilla.com
push dateWed, 17 Apr 2019 15:54:01 +0000
treeherdermozilla-central@37185c0ae520 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1518843
milestone68.0a1
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
Bug 1518843 - Move CallbackResult out of GeckoSession. r=snorp Depends On D22620 Differential Revision: https://phabricator.services.mozilla.com/D23093
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/CallbackResult.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/RuntimeTelemetry.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionFinder.java
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/CallbackResult.java
@@ -0,0 +1,17 @@
+/* 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 org.mozilla.gecko.util.EventCallback;
+
+/* package */ abstract class CallbackResult<T> extends GeckoResult<T>
+        implements EventCallback {
+    @Override
+    public void sendError(final Object response) {
+        completeExceptionally(response != null ?
+                new Exception(response.toString()) :
+                new UnknownError());
+    }
+}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
@@ -284,17 +284,17 @@ public final class GeckoRuntime implemen
      * @param webExtension {@link WebExtension} to register
      *
      * @return A {@link GeckoResult} that will complete when the WebExtension
      * has been installed.
      */
     @UiThread
     public @NonNull GeckoResult<Void> registerWebExtension(
             final @NonNull WebExtension webExtension) {
-        final GeckoSession.CallbackResult<Void> result = new GeckoSession.CallbackResult<Void>() {
+        final CallbackResult<Void> result = new CallbackResult<Void>() {
             @Override
             public void sendSuccess(final Object response) {
                 complete(null);
             }
         };
 
         final GeckoBundle bundle = new GeckoBundle(1);
         bundle.putString("locationUri", webExtension.location.toString());
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -261,26 +261,16 @@ public class GeckoSession implements Par
     /* package */ final Compositor mCompositor = new Compositor();
 
     @WrapForJNI(stubName = "GetCompositor", calledFrom = "ui")
     private Object getCompositorFromNative() {
         // Only used by native code.
         return mCompositorReady ? mCompositor : null;
     }
 
-    /* package */ static abstract class CallbackResult<T> extends GeckoResult<T>
-                                                          implements EventCallback {
-        @Override
-        public void sendError(final Object response) {
-            completeExceptionally(response != null ?
-                    new Exception(response.toString()) :
-                    new UnknownError());
-        }
-    }
-
     private final GeckoSessionHandler<HistoryDelegate> mHistoryHandler =
         new GeckoSessionHandler<HistoryDelegate>(
             "GeckoViewHistory", this,
             new String[]{
                 "GeckoView:OnVisited",
                 "GeckoView:GetVisited",
             }
         ) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/RuntimeTelemetry.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/RuntimeTelemetry.java
@@ -37,25 +37,24 @@ public final class RuntimeTelemetry {
      * @param clear Whether the retrieved snapshots should be cleared.
      * @return A {@link GeckoResult} with the GeckoBundle snapshot results.
      */
     @AnyThread
     public @NonNull GeckoResult<JSONObject> getSnapshots(final boolean clear) {
         final GeckoBundle msg = new GeckoBundle(1);
         msg.putBoolean("clear", clear);
 
-        final GeckoSession.CallbackResult<JSONObject> result =
-            new GeckoSession.CallbackResult<JSONObject>() {
-                @Override
-                public void sendSuccess(final Object value) {
-                    try {
-                        complete(((GeckoBundle) value).toJSONObject());
-                    } catch (JSONException ex) {
-                        completeExceptionally(ex);
-                    }
+        final CallbackResult<JSONObject> result = new CallbackResult<JSONObject>() {
+            @Override
+            public void sendSuccess(final Object value) {
+                try {
+                    complete(((GeckoBundle) value).toJSONObject());
+                } catch (JSONException ex) {
+                    completeExceptionally(ex);
                 }
-            };
+            }
+        };
 
         mEventDispatcher.dispatch("GeckoView:TelemetrySnapshots", msg, result);
 
         return result;
     }
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionFinder.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionFinder.java
@@ -80,18 +80,17 @@ public final class SessionFinder {
      */
     @NonNull
     public GeckoResult<FinderResult> find(@Nullable final String searchString,
                                           @FinderFindFlags final int flags) {
         final GeckoBundle bundle = new GeckoBundle(sFlagNames.size() + 1);
         bundle.putString("searchString", searchString);
         addFlagsToBundle(flags, bundle);
 
-        final GeckoSession.CallbackResult<FinderResult> result =
-                new GeckoSession.CallbackResult<FinderResult>() {
+        final CallbackResult<FinderResult> result = new CallbackResult<FinderResult>() {
             @Override
             public void sendSuccess(final Object response) {
                 complete(new FinderResult((GeckoBundle) response));
             }
         };
         mDispatcher.dispatch("GeckoView:FindInPage", bundle, result);
         return result;
     }