Refactor NavigationPredictor to use and expose its WebContents
NavigationPredictor is currently tied to a RFH via mojo channels but the lifetime of a RFH is difficult to reason about, especially during a navigation to a different origin. This CL moves NavigationPredictor to a WebContents-centric approach with the added benefits of easier lifetime management and easier use in dependent code. Of important note: * The mojo channels that manage the lifetime of a NavigationPredictor are still tied to the main frame RFH since that maps to how renderers actually work. * A NavigationPredictor can enter a "lame duck" state where it is observing a WebContents that has been destroyed, but has yet to be destroyed itself by mojo. Thankfully, this is easily detected since a WebContentsObserver's web_contents() method returns nullptr when this occurs. Both places where web_contents() is used are now guarded by this check. * Multiple RFHs may belong to one WebContents, but only one NavigationPredictor will be created for each WebContents because the RFH must be the single mainframe to construct a NavigationPredictor. Bug: 1023485, 1041828 Change-Id: I6234225132048c70539395a3d1869602e7b0a0ec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008775 Commit-Queue: Robert Ogden <robertogden@chromium.org> Reviewed-by:Ryan Sturm <ryansturm@chromium.org> Cr-Commit-Position: refs/heads/master@{#734090}
Showing
Please register or sign in to comment