[Android] Tweak ChromeTabUtils.waitForTabPageLoaded loading state logic.

ChromeTabUtils.waitForTabPageLoaded was previously using Tab.isLoading()
to determine whether a tab had previously finished loading, then using
TabObserver.onPageLoadFinished to determine when a tab that hadn't
previously finished loading did so. Unfortunately, Tab's loading state
as tracked by Tab.mIsLoading is modified by the Tab.onLoadStopped
(which, in turn, calls TabObserver.onLoadStopped), not by
Tab.didPageLoadFinish (which, in turn, calls
TabObserver.onPageLoadFinished). The disconnect here means that it's
possible for ChromeTabUtils.waitForTabPageLoaded to see a Tab that is
still loading according to mIsLoading but has already fired
onPageLoadFinished. In such a scenario, waitForTabPageLoaded will time
out without ever seeing a call to onPageLoadFinished even though the
page has loaded.

This CL changes the observer used by ChromeTabUtils. Instead of simply
waiting for onPageLoadFinished, it now will:
 - recognize that the Tab has successfully loaded upon receiving
   onPageLoadFinished (same as now)
 - recognize that the Tab has failed to load upon receiving onCrash
 - note whether onLoadStopped has been called. If a timeout is hit and
   onLoadStopped has been called, the Tab is on the correct page, and
   the Tab hasn't crashed, waitForTabPageLoaded will assume that the
   Tab has successfully loaded.

BUG=709004

Review-Url: https://codereview.chromium.org/2859053004
Cr-Commit-Position: refs/heads/master@{#470172}


CrOS-Libchrome-Original-Commit: 8e566f616c9ecf713ce7e1283405adfb756a6915
1 file changed
tree: b85787b35fdcdc3d47ef380224496ff94595be04
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/