mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Support reconnect of the mojo frame channel (fixes issue #3260)
The mojo channel used for frame communication may disconnect for a variety of reasons including frame navigation, frame destruction, or insertion into the BackForwardCache (when the browser-side frame representation is destroyed and closes the connection). When disconnect occurs we now evaluate the situation and reconnect if appropriate. Connections are now initiated solely from the renderer process and the RenderFrame is passed as an argument to FrameAttached() instead of being retrieved independently. Messages are queued while the frame is disconnected and sent only after FrameAttachedAck() is received from the browser process. The renderer process will be crashed intentionally with a "connection retry failure" message if the reconnect fails 3 times in a row.
This commit is contained in:
@@ -130,7 +130,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
|
||||
// cef::mojom::BrowserFrame methods forwarded from CefBrowserFrame.
|
||||
void SendMessage(const std::string& name, base::Value arguments) override;
|
||||
void FrameAttached() override;
|
||||
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
|
||||
bool reattached) override;
|
||||
void DidFinishFrameLoad(const GURL& validated_url,
|
||||
int32_t http_status_code) override;
|
||||
void UpdateDraggableRegions(
|
||||
@@ -152,17 +153,14 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo() const;
|
||||
CefRefPtr<CefBrowserHostBase> GetBrowserHostBase() const;
|
||||
|
||||
// Returns the remote RenderFrame object.
|
||||
using RenderFrameType = mojo::Remote<cef::mojom::RenderFrame>;
|
||||
const RenderFrameType& GetRenderFrame();
|
||||
|
||||
// Send an action to the remote RenderFrame. This will queue the action if the
|
||||
// remote frame is not yet attached.
|
||||
using RenderFrameType = mojo::Remote<cef::mojom::RenderFrame>;
|
||||
using RenderFrameAction = base::OnceCallback<void(const RenderFrameType&)>;
|
||||
void SendToRenderFrame(const std::string& function_name,
|
||||
RenderFrameAction action);
|
||||
|
||||
void FrameAttachedInternal(bool reattached);
|
||||
void OnRenderFrameDisconnect();
|
||||
|
||||
const bool is_main_frame_;
|
||||
|
||||
@@ -179,9 +177,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
// The following members are only accessed on the UI thread.
|
||||
content::RenderFrameHost* render_frame_host_ = nullptr;
|
||||
|
||||
bool is_attached_ = false;
|
||||
|
||||
std::queue<std::pair<std::string, RenderFrameAction>> queued_actions_;
|
||||
std::queue<std::pair<std::string, RenderFrameAction>>
|
||||
queued_renderer_actions_;
|
||||
|
||||
mojo::Remote<cef::mojom::RenderFrame> render_frame_;
|
||||
|
||||
|
Reference in New Issue
Block a user