Bug 1443659 - Rename GeckoSession.openWindow and closeWindow r=esawin,droeh
☠☠ backed out by dd3beebf0ce3 ☠ ☠
authorJames Willcox <snorp@snorp.net>
Thu, 01 Mar 2018 09:15:12 -0500
changeset 462130 c8275e1f531edac26f613b99499714708af3b01e
parent 462129 bbb5759485fe49ea30d27d0d002f00fcdb3680ee
child 462131 e1eeee3bb2ff141785f4eafb51d513b2338825d3
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, droeh
bugs1443659
milestone60.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 1443659 - Rename GeckoSession.openWindow and closeWindow r=esawin,droeh MozReview-Commit-ID: 1zhNRw2OJ7y
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationListenerTest.kt
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1070,17 +1070,17 @@ public abstract class GeckoApp extends G
         mRootLayout = (RelativeLayout) findViewById(R.id.root_layout);
         mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
         mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
         mLayerView = (GeckoView) findViewById(R.id.layer_view);
 
         final GeckoSession session = new GeckoSession();
         // If the view already has a session, we need to ensure it is closed.
         if (mLayerView.getSession() != null) {
-            mLayerView.getSession().closeWindow();
+            mLayerView.getSession().close();
         }
         mLayerView.setSession(session);
         mLayerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
 
         session.getSettings().setString(GeckoSessionSettings.CHROME_URI,
                                         "chrome://browser/content/browser.xul");
         session.setContentDelegate(this);
 
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -2,41 +2,38 @@
  * 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.gecko.customtabs;
 
 import android.app.PendingIntent;
 import android.content.ActivityNotFoundException;
-import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ResolveInfo;
 import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.provider.Browser;
 import android.support.annotation.ColorInt;
 import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
 import android.support.design.widget.Snackbar;
 import android.support.v4.util.SparseArrayCompat;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.view.ActionMode;
 import android.support.v7.widget.Toolbar;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
-import android.widget.ListView;
 import android.widget.ProgressBar;
 
 import org.mozilla.gecko.ActivityHandlerHelper;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.Clipboard;
 import org.mozilla.gecko.DoorHangerPopup;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.FormAssistPopup;
@@ -46,26 +43,23 @@ import org.mozilla.gecko.preferences.Gec
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SnackbarBuilder;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.GeckoMenuInflater;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.permissions.Permissions;
-import org.mozilla.gecko.prompts.Prompt;
-import org.mozilla.gecko.prompts.PromptListItem;
 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.util.GeckoBundle;
 import org.mozilla.gecko.util.IntentUtils;
 import org.mozilla.gecko.util.PackageUtil;
-import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.webapps.WebApps;
 import org.mozilla.gecko.widget.ActionModePresenter;
 import org.mozilla.gecko.widget.GeckoPopupMenu;
 import org.mozilla.geckoview.GeckoSession;
 import org.mozilla.geckoview.GeckoSessionSettings;
 import org.mozilla.geckoview.GeckoView;
 
 import java.util.List;
@@ -174,17 +168,17 @@ public class CustomTabsActivity extends 
     @Override
     public void onPause() {
         mGeckoSession.setActive(false);
         super.onPause();
     }
 
     @Override
     public void onDestroy() {
-        mGeckoSession.closeWindow();
+        mGeckoSession.close();
         mTextSelection.destroy();
         mFormAssistPopup.destroy();
         mDoorHangerPopup.destroy();
         mPromptService.destroy();
 
         super.onDestroy();
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ -1,38 +1,29 @@
 /* -*- 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.gecko.webapps;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
 import android.annotation.TargetApi;
 import android.app.ActivityManager;
 import android.content.ActivityNotFoundException;
 import android.content.Intent;
-import android.content.pm.ActivityInfo;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.customtabs.CustomTabsIntent;
-import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.view.ActionMode;
-import android.support.v7.widget.Toolbar;
 import android.util.Log;
-import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
-import android.widget.TextView;
 import android.widget.Toast;
 
 import org.mozilla.gecko.ActivityHandlerHelper;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.DoorHangerPopup;
 import org.mozilla.gecko.FormAssistPopup;
 import org.mozilla.gecko.GeckoAccessibility;
@@ -209,17 +200,17 @@ public class WebAppActivity extends AppC
     @Override
     public void onPause() {
         mGeckoSession.setActive(false);
         super.onPause();
     }
 
     @Override
     public void onDestroy() {
-        mGeckoSession.closeWindow();
+        mGeckoSession.close();
         mTextSelection.destroy();
         mFormAssistPopup.destroy();
         mDoorHangerPopup.destroy();
         mPromptService.destroy();
         super.onDestroy();
     }
 
     @Override
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationListenerTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationListenerTest.kt
@@ -250,17 +250,17 @@ class NavigationDelegateTest {
     fun onNewSession_doesNotAllowOpened() {
         sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH)
         sessionRule.waitForPageStop()
 
         sessionRule.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
             @AssertCalled(count = 1)
             override fun onNewSession(session: GeckoSession, uri: String, response: GeckoSession.Response<GeckoSession>) {
                 var session = GeckoSession(session.settings)
-                session.openWindow(null)
+                session.open(null)
                 response.respond(session)
             }
         })
 
         sessionRule.synthesizeTap(5, 5)
         sessionRule.waitUntilCalled(GeckoSession.NavigationDelegate::class, "onNewSession")
     }
 }
\ No newline at end of file
--- 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
@@ -5,22 +5,16 @@ import org.mozilla.gecko.mozglue.SafeInt
 import org.mozilla.geckoview.GeckoSession;
 import org.mozilla.geckoview.GeckoSessionSettings;
 import org.mozilla.geckoview.GeckoView;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
 
 public class TestRunnerActivity extends Activity {
     private static final String LOGTAG = "TestRunnerActivity";
 
     GeckoSession mSession;
     GeckoView mView;
 
     private GeckoSession.NavigationDelegate mNavigationDelegate = new GeckoSession.NavigationDelegate() {
@@ -59,17 +53,17 @@ public class TestRunnerActivity extends 
 
         @Override
         public void onFocusRequest(GeckoSession session) {
 
         }
 
         @Override
         public void onCloseRequest(GeckoSession session) {
-            session.closeWindow();
+            session.close();
         }
 
         @Override
         public void onFullScreen(GeckoSession session, boolean fullScreen) {
 
         }
 
         @Override
@@ -102,32 +96,32 @@ public class TestRunnerActivity extends 
 
         final Intent intent = getIntent();
         GeckoSession.preload(this, new String[] { "-purgecaches" },
                              intent.getExtras(), false /* no multiprocess, see below */);
 
         // We can't use e10s because we get deadlocked when quickly creating and
         // destroying sessions. Bug 1348361.
         mSession = createSession();
-        mSession.openWindow(this);
+        mSession.open(this);
 
         // If we were passed a URI in the Intent, open it
         final Uri uri = intent.getData();
         if (uri != null) {
             mSession.loadUri(uri);
         }
 
         mView = new GeckoView(this);
         mView.setSession(mSession);
         setContentView(mView);
     }
 
     @Override
     protected void onDestroy() {
-        mSession.closeWindow();
+        mSession.close();
         super.onDestroy();
     }
 
     public GeckoView getGeckoView() {
         return mView;
     }
 
     public GeckoSession getGeckoSession() {
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
@@ -615,17 +615,17 @@ public class GeckoSessionTestRule extend
         }
 
         for (final Class<?> cls : CALLBACK_CLASSES) {
             if (cls != null) {
                 getCallbackSetter(cls).invoke(mSession, mCallbackProxy);
             }
         }
 
-        mSession.openWindow(mInstrumentation.getTargetContext());
+        mSession.open(mInstrumentation.getTargetContext());
 
         if (settings.getBoolean(GeckoSessionSettings.USE_MULTIPROCESS)) {
             // Under e10s, we receive an initial about:blank load; don't expose that to the test.
             waitForPageStop();
         }
     }
 
     /**
@@ -633,17 +633,17 @@ public class GeckoSessionTestRule extend
      */
     public void performTestEndCheck() {
         mWaitScopeDelegates.clear();
         mTestScopeDelegates.clear();
     }
 
     protected void cleanupSession() throws Throwable {
         if (mSession.isOpen()) {
-            mSession.closeWindow();
+            mSession.close();
         }
 
         if (mDisplay != null) {
             mDisplay.surfaceDestroyed();
             mSession.releaseDisplay(mDisplay);
             mDisplaySurface.release();
             mDisplayTexture.release();
             mDisplay = null;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -166,17 +166,17 @@ public class GeckoSession extends LayerS
                                     callback.sendSuccess(null);
                                     return;
                                 }
 
                                 if (session.isOpen()) {
                                     throw new IllegalArgumentException("Must use an unopened GeckoSession instance");
                                 }
 
-                                session.openWindow(null);
+                                session.open(null);
                                 callback.sendSuccess(session.getId());
                             }
                         });
                 }
             }
         };
 
     private final GeckoSessionHandler<ProgressDelegate> mProgressHandler =
@@ -596,18 +596,31 @@ public class GeckoSession extends LayerS
 
     public boolean isOpen() {
         return mWindow != null;
     }
 
     /* package */ boolean isReady() {
         return mNativeQueue.isReady();
     }
-
-    public void openWindow(final @Nullable Context appContext) {
+    
+    /**
+     * Opens the session.
+     *
+     * The session is in a 'closed' state when first created. Opening it creates
+     * the underlying Gecko objects necessary to load a page, etc. Most GeckoSession
+     * methods only take affect on an open session, and are queued until the session
+     * is opened here. Opening a session is an asynchronous operation. You can check
+     * the current state via isOpen().
+     *
+     * Call this when you are ready to use a GeckoSession instance.
+     *
+     * @param appContext An application context
+     */
+    public void open(final @Nullable Context appContext) {
         ThreadUtils.assertOnUiThread();
 
         if (isOpen()) {
             throw new IllegalStateException("Session is open");
         }
 
         if (appContext != null) {
             final boolean multiprocess =
@@ -638,17 +651,24 @@ public class GeckoSession extends LayerS
                 GeckoBundle.class, mSettings.asBundle(),
                 String.class, chromeUri,
                 screenId, isPrivate, mId);
         }
 
         onWindowChanged();
     }
 
-    public void closeWindow() {
+    /**
+     * Closes the session.
+     *
+     * This frees the underlying Gecko objects and unloads the current page. The session may be
+     * reopened later, but page state is not restored. Call this when you are finished using
+     * a GeckoSession instance.
+     */
+    public void close() {
         ThreadUtils.assertOnUiThread();
 
         if (!isOpen()) {
             Log.w(LOGTAG, "Attempted to close a GeckoSession that was already closed.");
             return;
         }
 
         if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
@@ -258,17 +258,17 @@ public class GeckoView extends FrameLayo
 
     @Override
     public void onAttachedToWindow() {
         if (mSession == null) {
             setSession(new GeckoSession());
         }
 
         if (!mSession.isOpen()) {
-            mSession.openWindow(getContext().getApplicationContext());
+            mSession.open(getContext().getApplicationContext());
         }
 
         mSession.getTextInputController().setView(this);
 
         super.onAttachedToWindow();
     }
 
     @Override
@@ -278,17 +278,17 @@ public class GeckoView extends FrameLayo
         mSession.getTextInputController().setView(this);
 
         if (mStateSaved) {
             // If we saved state earlier, we don't want to close the window.
             return;
         }
 
         if (mSession != null && mSession.isOpen()) {
-            mSession.closeWindow();
+            mSession.close();
         }
     }
 
     @Override
     public boolean gatherTransparentRegion(final Region region) {
         // For detecting changes in SurfaceView layout, we take a shortcut here and
         // override gatherTransparentRegion, instead of registering a layout listener,
         // which is more expensive.
--- 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
@@ -14,20 +14,18 @@ import android.os.Bundle;
 import android.os.SystemClock;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.WindowManager;
 
 import java.util.Locale;
 
 import org.mozilla.gecko.GeckoThread;
-import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.geckoview.GeckoSession;
 import org.mozilla.geckoview.GeckoSessionSettings;
-import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource;
 import org.mozilla.geckoview.GeckoSession.Response;
 import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate;
 import org.mozilla.geckoview.GeckoView;
 
 public class GeckoViewActivity extends Activity {
     private static final String LOGTAG = "GeckoViewActivity";
     private static final String DEFAULT_URL = "https://mozilla.org";
     private static final String USE_MULTIPROCESS_EXTRA = "use_multiprocess";
@@ -181,17 +179,17 @@ public class GeckoViewActivity extends A
         @Override
         public void onFocusRequest(final GeckoSession session) {
             Log.i(LOGTAG, "Content requesting focus");
         }
 
         @Override
         public void onCloseRequest(final GeckoSession session) {
             if (session != mGeckoSession) {
-                session.closeWindow();
+                session.close();
             }
         }
 
         @Override
         public void onContextMenu(GeckoSession session, int screenX, int screenY,
                                   String uri, String elementSrc) {
             Log.d(LOGTAG, "onContextMenu screenX=" + screenX +
                           " screenY=" + screenY + " uri=" + uri +