mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Improve timing of frame attach/detach (see #3664)
- Move frame attachment from RenderFrameCreated to DidCommitProvisionalLoad. This has a number of advantages: - Significantly reduces the frequency of disconnects by avoiding the GetInterface/DidCommitNavigation race condition. - Stops connecting temporary frames (created during cross-origin navigation), making callback behavior more consistent. - Split frame detach and destruction notifications into separate callbacks. OnFrameDetached now reflects a potentially recoverable state. Add a new OnFrameDestroyed callback for the unrecoverable destruction state.
This commit is contained in:
@ -68,6 +68,8 @@
|
||||
/// objects are detached at the same time then notifications will be sent for
|
||||
/// any sub-frame objects before the main frame object. Commands can no longer
|
||||
/// be routed and will be discarded.
|
||||
/// - CefFremeHadler::OnFrameDestroyed => An existing main frame or sub-frame
|
||||
/// object has been destroyed.
|
||||
/// - CefFrameHandler::OnMainFrameChanged => A new main frame object has been
|
||||
/// assigned to the browser. This will only occur with cross-origin navigation
|
||||
/// or re-navigation after renderer process termination (due to crashes, etc).
|
||||
@ -76,42 +78,32 @@
|
||||
/// - CefFrameHandler::OnFrameDetached => Any sub-frame objects have lost their
|
||||
/// connection to the renderer process. Commands can no longer be routed and
|
||||
/// will be discarded.
|
||||
/// - CefFreameHandler::OnFrameDestroyed => Any sub-frame objects have been
|
||||
/// destroyed.
|
||||
/// - CefLifeSpanHandler::OnBeforeClose => The browser has been destroyed.
|
||||
/// - CefFrameHandler::OnFrameDetached => The main frame object have lost its
|
||||
/// connection to the renderer process. Notifications will be sent for any
|
||||
/// sub-frame objects before the main frame object. Commands can no longer be
|
||||
/// routed and will be discarded.
|
||||
/// - CefFreameHandler::OnFrameDestroyed => The main frame object has been
|
||||
/// destroyed.
|
||||
/// - CefFrameHandler::OnMainFrameChanged => The final main frame object has
|
||||
/// been removed from the browser.
|
||||
///
|
||||
/// Cross-origin navigation and/or loading receives special handling.
|
||||
/// Special handling applies for cross-origin loading on creation/navigation of
|
||||
/// sub-frames, and cross-origin loading on creation of new popup browsers. A
|
||||
/// temporary frame will first be created in the parent frame's renderer
|
||||
/// process. This temporary frame will never attach and will be discarded after
|
||||
/// the real cross-origin frame is created in the new/target renderer process.
|
||||
/// The client will receive creation callbacks for the temporary frame, followed
|
||||
/// by cross-origin navigation callbacks (2) for the transition from the
|
||||
/// temporary frame to the real frame. The temporary frame will not receive or
|
||||
/// execute commands during this transitional period (any sent commands will be
|
||||
/// discarded).
|
||||
///
|
||||
/// When the main frame navigates to a different origin the OnMainFrameChanged
|
||||
/// callback (2) will be executed with the old and new main frame objects.
|
||||
///
|
||||
/// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
|
||||
/// a different origin from the parent frame, a temporary sub-frame object will
|
||||
/// first be created in the parent's renderer process. That temporary sub-frame
|
||||
/// will then be discarded after the real cross-origin sub-frame is created in
|
||||
/// the new/target renderer process. The client will receive cross-origin
|
||||
/// navigation callbacks (2) for the transition from the temporary sub-frame to
|
||||
/// the real sub-frame. The temporary sub-frame will not receive or execute
|
||||
/// commands during this transitional period (any sent commands will be
|
||||
/// discarded).
|
||||
///
|
||||
/// When a new popup browser is created in a different origin from the parent
|
||||
/// browser, a temporary main frame object for the popup will first be created
|
||||
/// in the parent's renderer process. That temporary main frame will then be
|
||||
/// discarded after the real cross-origin main frame is created in the
|
||||
/// new/target renderer process. The client will receive creation and initial
|
||||
/// navigation callbacks (1) for the temporary main frame, followed by
|
||||
/// cross-origin navigation callbacks (2) for the transition from the temporary
|
||||
/// main frame to the real main frame. The temporary main frame may receive and
|
||||
/// execute commands during this transitional period (any sent commands may be
|
||||
/// executed, but the behavior is potentially undesirable since they execute in
|
||||
/// the parent browser's renderer process and not the new/target renderer
|
||||
/// process).
|
||||
///
|
||||
/// Callbacks will not be executed for placeholders that may be created during
|
||||
/// pre-commit navigation for sub-frames that do not yet exist in the renderer
|
||||
/// process. Placeholders will have CefFrame::GetIdentifier() == -4.
|
||||
@ -126,17 +118,33 @@ class CefFrameHandler : public virtual CefBaseRefCounted {
|
||||
/// Called when a new frame is created. This will be the first notification
|
||||
/// that references |frame|. Any commands that require transport to the
|
||||
/// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
|
||||
/// etc.) will be queued until OnFrameAttached is called for |frame|.
|
||||
/// etc.) will be queued. The queued commands will be sent before
|
||||
/// OnFrameAttached or discarded before OnFrameDestroyed if the frame never
|
||||
/// attaches.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnFrameCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {}
|
||||
|
||||
///
|
||||
/// Called when an existing frame is destroyed. This will be the last
|
||||
/// notification that references |frame| and CefFrame::IsValid() will return
|
||||
/// false for |frame|. If called during browser destruction and after
|
||||
/// CefLifeSpanHandler::OnBeforeClose() then CefBrowser::IsValid() will return
|
||||
/// false for |browser|. Any queued commands that have not been sent will be
|
||||
/// discarded before this callback.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnFrameDestroyed(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {}
|
||||
|
||||
///
|
||||
/// Called when a frame can begin routing commands to/from the associated
|
||||
/// renderer process. |reattached| will be true if the frame was re-attached
|
||||
/// after exiting the BackForwardCache. Any commands that were queued have now
|
||||
/// been dispatched.
|
||||
/// after exiting the BackForwardCache or after encountering a recoverable
|
||||
/// connection error. Any queued commands will now have been dispatched. This
|
||||
/// method will not be called for temporary frames created during cross-origin
|
||||
/// navigation.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnFrameAttached(CefRefPtr<CefBrowser> browser,
|
||||
@ -144,11 +152,17 @@ class CefFrameHandler : public virtual CefBaseRefCounted {
|
||||
bool reattached) {}
|
||||
|
||||
///
|
||||
/// Called when a frame loses its connection to the renderer process and will
|
||||
/// be destroyed. Any pending or future commands will be discarded and
|
||||
/// CefFrame::IsValid() will now return false for |frame|. If called after
|
||||
/// CefLifeSpanHandler::OnBeforeClose() during browser destruction then
|
||||
/// CefBrowser::IsValid() will return false for |browser|.
|
||||
/// Called when a frame loses its connection to the renderer process. This may
|
||||
/// occur when a frame is destroyed, enters the BackForwardCache, or
|
||||
/// encounters a rare connection error. In the case of frame destruction this
|
||||
/// call will be followed by a (potentially async) call to OnFrameDestroyed.
|
||||
/// If frame destruction is occuring synchronously then CefFrame::IsValid()
|
||||
/// will return false for |frame|. If called during browser destruction and
|
||||
/// after CefLifeSpanHandler::OnBeforeClose() then CefBrowser::IsValid() will
|
||||
/// return false for |browser|. If, in the non-destruction case, the same
|
||||
/// frame later exits the BackForwardCache or recovers from a connection error
|
||||
/// then there will be a follow-up call to OnFrameAttached. This method will
|
||||
/// not be called for temporary frames created during cross-origin navigation.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnFrameDetached(CefRefPtr<CefBrowser> browser,
|
||||
@ -160,13 +174,13 @@ class CefFrameHandler : public virtual CefBaseRefCounted {
|
||||
/// re-navigation after renderer process termination (due to crashes, etc).
|
||||
/// |old_frame| will be NULL and |new_frame| will be non-NULL when a main
|
||||
/// frame is assigned to |browser| for the first time. |old_frame| will be
|
||||
/// non-NULL and |new_frame| will be NULL and when a main frame is removed
|
||||
/// from |browser| for the last time. Both |old_frame| and |new_frame| will be
|
||||
/// non-NULL and |new_frame| will be NULL when a main frame is removed from
|
||||
/// |browser| for the last time. Both |old_frame| and |new_frame| will be
|
||||
/// non-NULL for cross-origin navigations or re-navigation after renderer
|
||||
/// process termination. This method will be called after OnFrameCreated() for
|
||||
/// |new_frame| and/or after OnFrameDetached() for |old_frame|. If called
|
||||
/// after CefLifeSpanHandler::OnBeforeClose() during browser destruction then
|
||||
/// CefBrowser::IsValid() will return false for |browser|.
|
||||
/// |new_frame| and/or after OnFrameDestroyed() for |old_frame|. If called
|
||||
/// during browser destruction and after CefLifeSpanHandler::OnBeforeClose()
|
||||
/// then CefBrowser::IsValid() will return false for |browser|.
|
||||
///
|
||||
/*--cef(optional_param=old_frame,optional_param=new_frame)--*/
|
||||
virtual void OnMainFrameChanged(CefRefPtr<CefBrowser> browser,
|
||||
|
Reference in New Issue
Block a user