Bug 1458327 - 5. Fix some comments; r=me draft
authorJim Chen <nchen@mozilla.com>
Fri, 04 May 2018 21:08:10 -0400
changeset 791732 2cc9bf22128fd613892900c5a2e642ec936d1ceb
parent 791731 dddd54c65a238c3acaf45112509015d7d3341d7e
push id108891
push userbmo:nchen@mozilla.com
push dateSat, 05 May 2018 01:08:49 +0000
reviewersme
bugs1458327
milestone61.0a1
Bug 1458327 - 5. Fix some comments; r=me 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;
         }