Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Ensure suspended sessions are not readded to a-c SessionStore (#3668)
Browse files Browse the repository at this point in the history
Fixes #3620
  • Loading branch information
bluemarvin committed Jul 10, 2020
1 parent 5a794b6 commit 45f818a
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class Session implements ContentBlocking.Delegate, GeckoSession.Navigatio
private transient byte[] mPrivatePage;
private transient boolean mFirstContentfulPaint;
private transient long mKeepAlive;
private transient boolean mSessionRemoved;

public interface BitmapChangedListener {
void onBitmapChanged(Session aSession, Bitmap aBitmap);
Expand Down Expand Up @@ -159,9 +160,6 @@ private void initialize() {
protected void shutdown() {
if (mState.mSession != null) {
closeSession(mState);
mSessionChangeListeners.forEach(listener -> {
listener.onSessionRemoved(mState.mId);
});
mState.mSession = null;
}

Expand All @@ -172,6 +170,13 @@ protected void shutdown() {
}
}

if (!mSessionRemoved) {
mSessionChangeListeners.forEach(listener -> {
listener.onSessionRemoved(mState.mId);
});
mSessionRemoved = true;
}

mQueuedCalls.clear();
mNavigationListeners.clear();
mProgressListeners.clear();
Expand Down Expand Up @@ -467,8 +472,9 @@ private void restore() {

// We call restore when a session is first activated and when it's recreated.
// We only need to notify of the session creation if it's not a recreation.
if (mState.mSessionState == null) {
if (mSessionRemoved) {
mSessionChangeListeners.forEach(listener -> listener.onSessionAdded(this));
mSessionRemoved = false;
}

openSession();
Expand Down

0 comments on commit 45f818a

Please sign in to comment.