Bug 1458327 - 5. Fix some comments; r=jchen
authorJim Chen <nchen@mozilla.com>
Fri, 04 May 2018 21:08:10 -0400
changeset 473116 3e1d4faf82ad10e52917fa47a61fc6b67537c27e
parent 473115 3647f62ed6b6f4a45120208a4a1423791ce672e6
child 473117 a9f5a8dc2e2299affb3be272705175c96dbbac87
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1458327
milestone61.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 1458327 - 5. Fix some comments; r=jchen MozReview-Commit-ID: LAgmyGXPPOL
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -649,16 +649,17 @@ public class GeckoSession extends LayerS
         }
         return mWindow.runtime;
     }
 
     private void transferFrom(final Window window,
                               final GeckoSessionSettings settings,
                               final String id) {
         if (isOpen()) {
+            // We will leak the existing Window if we transfer in another one.
             throw new IllegalStateException("Session is open");
         }
 
         if (window != null) {
             onWindowChanged(WINDOW_TRANSFER_IN, /* inProgress */ true);
         }
 
         mWindow = window;
@@ -720,16 +721,23 @@ public class GeckoSession extends LayerS
         }
 
         @Override
         public GeckoSession[] newArray(final int size) {
             return new GeckoSession[size];
         }
     };
 
+    /**
+     * Return whether this session is open.
+     *
+     * @return True if session is open.
+     * @see #open
+     * @see #close
+     */
     public boolean isOpen() {
         return mWindow != null;
     }
 
     /* package */ boolean isReady() {
         return mNativeQueue.isReady();
     }
 
@@ -737,37 +745,35 @@ public class GeckoSession extends LayerS
         final GeckoBundle initData = new GeckoBundle(1);
         initData.putBundle("settings", mSettings.toBundle());
         return initData;
     }
 
     /**
      * Opens the session.
      *
+     * Call this when you are ready to use a GeckoSession instance.
+     *
      * 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.
+     * is opened here. Opening a session is an asynchronous operation.
      *
      * @param runtime The Gecko runtime to attach this session to.
+     * @see #close
+     * @see #isOpen
      */
     public void open(final @NonNull GeckoRuntime runtime) {
         ThreadUtils.assertOnUiThread();
 
         if (isOpen()) {
+            // We will leak the existing Window if we open another one.
             throw new IllegalStateException("Session is open");
         }
 
-        openWindow(runtime);
-    }
-
-    private void openWindow(final @NonNull GeckoRuntime runtime) {
         final String chromeUri = mSettings.getString(GeckoSessionSettings.CHROME_URI);
         final int screenId = mSettings.getInt(GeckoSessionSettings.SCREEN_ID);
         final boolean isPrivate = mSettings.getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE);
 
         mWindow = new Window(runtime, mNativeQueue);
 
         onWindowChanged(WINDOW_OPEN, /* inProgress */ true);
 
@@ -792,16 +798,19 @@ public class GeckoSession extends LayerS
     }
 
     /**
      * 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.
+     *
+     * @see #open
+     * @see #isOpen
      */
     public void close() {
         ThreadUtils.assertOnUiThread();
 
         if (!isOpen()) {
             Log.w(LOGTAG, "Attempted to close a GeckoSession that was already closed.");
             return;
         }