Skip to content

Commit

Permalink
Insure onLoadRequest only waits for correct number of listeners.
Browse files Browse the repository at this point in the history
Fixes #3157

When GeckoView started short cutting onLoadRequest, the number of
Navigation Listeners would be larger when the GeckoRequest was finally
processed so the GeckoResult would never get completed and the load
would never start.
  • Loading branch information
bluemarvin committed Apr 15, 2020
1 parent 55edd67 commit 7300f08
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1004,14 +1004,15 @@ public void onCanGoForward(@NonNull GeckoSession aSession, boolean aCanGoForward
final GeckoResult<AllowOrDeny> result = new GeckoResult<>();
AtomicInteger count = new AtomicInteger(0);
AtomicBoolean allowed = new AtomicBoolean(false);
final int listenerCount = mNavigationListeners.size() - 1;
for (GeckoSession.NavigationDelegate listener: mNavigationListeners) {
GeckoResult<AllowOrDeny> listenerResult = listener.onLoadRequest(aSession, aRequest);
if (listenerResult != null) {
listenerResult.then(value -> {
if (AllowOrDeny.ALLOW.equals(value)) {
allowed.set(true);
}
if (count.getAndIncrement() == mNavigationListeners.size() - 1) {
if (count.getAndIncrement() == listenerCount) {
result.complete(allowed.get() ? AllowOrDeny.ALLOW : AllowOrDeny.DENY);
}

Expand All @@ -1020,7 +1021,7 @@ public void onCanGoForward(@NonNull GeckoSession aSession, boolean aCanGoForward

} else {
allowed.set(true);
if (count.getAndIncrement() == mNavigationListeners.size() - 1) {
if (count.getAndIncrement() == listenerCount) {
result.complete(allowed.get() ? AllowOrDeny.ALLOW : AllowOrDeny.DENY);
}
}
Expand Down

0 comments on commit 7300f08

Please sign in to comment.