• Hiroki Nakagawa's avatar
    Prerender: Remove unused mojom::PrerenderProcessor::Abandon() · 19a1b541
    Hiroki Nakagawa authored
    mojom::PrerenderProcessor::Abandon() is a mojo call from a renderer
    process to the browser process in order to abandon a running prerender,
    but this is never called. This CL removes the mojo function and relevant
    functions (e.g., pre-finalizer).
    
    > Why is this never called?
    
    Abandon() is supposed to be called when a page that has
    <link rel=prerender> navigates away, etc, and apparently
    blink::PrerenderHandle::Dispose() calls it. However, actually Dispose()
    never calls Abandon(). See the following code snippet.
    
      void PrerenderHandle::Dispose() {
        if (remote_processor_.is_bound() &&
            !GetExecutionContext()->IsContextDestroyed())
          remote_processor_->Abandon();
        Detach();
      }
    
    Dispose() is called by ContextLifecycleObserver during the context
    destruction. |remote_processor_| can be unbound at this point because
    the remote processor is retained with MojoHeapRemote that is supposed
    to be reset by ContextLifecycleObserver. There is an ordering issue
    here. Also, even if the remote processor is still bound,
    IsContextDestroyed() always returns true because Dispose() is called
    during the context destruction.
    
    In another case, Dispose() is called on the pre-finalizer, but this
    doesn't work as well because PrerenderHandle::Cancel() that resets
    |remote_processor_| or ContextDestroyed() that calls Dispose() are
    already called before the pre-finalizer.
    
    In summary, both Abandon() and the pre-finalizer are not necessary.
    This CL removes them.
    
    > Mojo connections are managed by MojoHeap variants. Does
    > PrerenderHandle have to explicitly reset them on the context
    > destruction?
    
    That's not necessary. MojoHeap variants automatically reset the
    connections on the context destruction. This CL removes
    ContextLifecycleObserver implementation used for resetting the
    connections from PrerenderHandle.
    
    > Is the browser-side abandon code also never used?
    
    No, it's used. Instead of waiting for Abandon() call from a renderer
    process, PrerenderLinkManager::LinkPrerender in the browser process
    monitors the connection of mojom::PrerenderProcessorClient and abandons
    the running prerender on connection destruction. Therefore, this CL
    doesn't remove the browser-side code.
    
    Bug: 1130360
    Change-Id: I14555530f98d1fb191b04f387636f58a52484c95
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462987
    Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
    Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
    Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
    Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#816897}
    19a1b541
prerender_link_manager.cc 13.7 KB