mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Improve logging of frame connection state (see issue #3260)
Run with "--vmodule=frame_*=1 --enable-logging=stderr --no-sandbox" on the command-line to see these log messages from both the browser and renderer processes.
This commit is contained in:
@ -225,9 +225,11 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
|
|||||||
// Explicitly Detach everything but the current main frame.
|
// Explicitly Detach everything but the current main frame.
|
||||||
const auto& frame_info = *it2;
|
const auto& frame_info = *it2;
|
||||||
if (frame_info->frame_ && !frame_info->IsCurrentMainFrame()) {
|
if (frame_info->frame_ && !frame_info->IsCurrentMainFrame()) {
|
||||||
if (frame_info->frame_->Detach())
|
if (frame_info->frame_->Detach(
|
||||||
|
CefFrameHostImpl::DetachReason::RENDER_FRAME_DELETED)) {
|
||||||
MaybeNotifyFrameDetached(browser_, frame_info->frame_);
|
MaybeNotifyFrameDetached(browser_, frame_info->frame_);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
frame_info_set_.erase(it2);
|
frame_info_set_.erase(it2);
|
||||||
}
|
}
|
||||||
@ -408,9 +410,10 @@ void CefBrowserInfo::SetMainFrame(CefRefPtr<CefBrowserHostBase> browser,
|
|||||||
CefRefPtr<CefFrameHostImpl> old_frame;
|
CefRefPtr<CefFrameHostImpl> old_frame;
|
||||||
if (main_frame_) {
|
if (main_frame_) {
|
||||||
old_frame = main_frame_;
|
old_frame = main_frame_;
|
||||||
if (old_frame->Detach())
|
if (old_frame->Detach(CefFrameHostImpl::DetachReason::NEW_MAIN_FRAME)) {
|
||||||
MaybeNotifyFrameDetached(browser, old_frame);
|
MaybeNotifyFrameDetached(browser, old_frame);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
main_frame_ = frame;
|
main_frame_ = frame;
|
||||||
|
|
||||||
@ -489,10 +492,12 @@ void CefBrowserInfo::RemoveAllFrames(
|
|||||||
// Explicitly Detach everything but the current main frame.
|
// Explicitly Detach everything but the current main frame.
|
||||||
for (auto& info : frame_info_set_) {
|
for (auto& info : frame_info_set_) {
|
||||||
if (info->frame_ && !info->IsCurrentMainFrame()) {
|
if (info->frame_ && !info->IsCurrentMainFrame()) {
|
||||||
if (info->frame_->Detach())
|
if (info->frame_->Detach(
|
||||||
|
CefFrameHostImpl::DetachReason::BROWSER_DESTROYED)) {
|
||||||
MaybeNotifyFrameDetached(old_browser, info->frame_);
|
MaybeNotifyFrameDetached(old_browser, info->frame_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (main_frame_)
|
if (main_frame_)
|
||||||
SetMainFrame(old_browser, nullptr);
|
SetMainFrame(old_browser, nullptr);
|
||||||
|
@ -439,9 +439,27 @@ content::RenderFrameHost* CefFrameHostImpl::GetRenderFrameHost() const {
|
|||||||
return render_frame_host_;
|
return render_frame_host_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefFrameHostImpl::Detach() {
|
bool CefFrameHostImpl::Detach(DetachReason reason) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
if (VLOG_IS_ON(1)) {
|
||||||
|
std::string reason_str;
|
||||||
|
switch (reason) {
|
||||||
|
case DetachReason::RENDER_FRAME_DELETED:
|
||||||
|
reason_str = "RENDER_FRAME_DELETED";
|
||||||
|
break;
|
||||||
|
case DetachReason::NEW_MAIN_FRAME:
|
||||||
|
reason_str = "NEW_MAIN_FRAME";
|
||||||
|
break;
|
||||||
|
case DetachReason::BROWSER_DESTROYED:
|
||||||
|
reason_str = "BROWSER_DESTROYED";
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
VLOG(1) << GetDebugString() << " detached (reason=" << reason_str
|
||||||
|
<< ", is_connected=" << render_frame_.is_bound() << ")";
|
||||||
|
}
|
||||||
|
|
||||||
// May be called multiple times (e.g. from CefBrowserInfo SetMainFrame and
|
// May be called multiple times (e.g. from CefBrowserInfo SetMainFrame and
|
||||||
// RemoveFrame).
|
// RemoveFrame).
|
||||||
bool first_detach = false;
|
bool first_detach = false;
|
||||||
@ -539,9 +557,7 @@ void CefFrameHostImpl::SendToRenderFrame(const std::string& function_name,
|
|||||||
return;
|
return;
|
||||||
} else if (!render_frame_host_) {
|
} else if (!render_frame_host_) {
|
||||||
// We've been detached.
|
// We've been detached.
|
||||||
LOG(WARNING) << function_name << " sent to detached "
|
LOG(WARNING) << function_name << " sent to detached " << GetDebugString()
|
||||||
<< (is_main_frame_ ? "main" : "sub") << "frame "
|
|
||||||
<< frame_util::GetFrameDebugString(frame_id_)
|
|
||||||
<< " will be ignored";
|
<< " will be ignored";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -603,11 +619,7 @@ void CefFrameHostImpl::FrameAttached(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reattached) {
|
VLOG(1) << GetDebugString() << " " << (reattached ? "re" : "") << "connected";
|
||||||
LOG(INFO) << (is_main_frame_ ? "main" : "sub") << "frame "
|
|
||||||
<< frame_util::GetFrameDebugString(frame_id_)
|
|
||||||
<< " has reconnected";
|
|
||||||
}
|
|
||||||
|
|
||||||
render_frame_.Bind(std::move(render_frame_remote));
|
render_frame_.Bind(std::move(render_frame_remote));
|
||||||
render_frame_.set_disconnect_handler(
|
render_frame_.set_disconnect_handler(
|
||||||
@ -662,6 +674,11 @@ void CefFrameHostImpl::UpdateDraggableRegions(
|
|||||||
browser, this, std::move(draggable_regions));
|
browser, this, std::move(draggable_regions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CefFrameHostImpl::GetDebugString() const {
|
||||||
|
return "frame " + frame_util::GetFrameDebugString(frame_id_) +
|
||||||
|
(is_main_frame_ ? " (main)" : " (sub)");
|
||||||
|
}
|
||||||
|
|
||||||
void CefExecuteJavaScriptWithUserGestureForTests(CefRefPtr<CefFrame> frame,
|
void CefExecuteJavaScriptWithUserGestureForTests(CefRefPtr<CefFrame> frame,
|
||||||
const CefString& javascript) {
|
const CefString& javascript) {
|
||||||
CefFrameHostImpl* impl = static_cast<CefFrameHostImpl*>(frame.get());
|
CefFrameHostImpl* impl = static_cast<CefFrameHostImpl*>(frame.get());
|
||||||
|
@ -112,11 +112,17 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
|||||||
// thread.
|
// thread.
|
||||||
content::RenderFrameHost* GetRenderFrameHost() const;
|
content::RenderFrameHost* GetRenderFrameHost() const;
|
||||||
|
|
||||||
|
enum class DetachReason {
|
||||||
|
RENDER_FRAME_DELETED,
|
||||||
|
NEW_MAIN_FRAME,
|
||||||
|
BROWSER_DESTROYED,
|
||||||
|
};
|
||||||
|
|
||||||
// Owned frame objects will be detached explicitly when the associated
|
// Owned frame objects will be detached explicitly when the associated
|
||||||
// RenderFrame is deleted. Temporary frame objects will be detached
|
// RenderFrame is deleted. Temporary frame objects will be detached
|
||||||
// implicitly via CefBrowserInfo::browser() returning nullptr. Returns true
|
// implicitly via CefBrowserInfo::browser() returning nullptr. Returns true
|
||||||
// if this was the first call to Detach() for the frame.
|
// if this was the first call to Detach() for the frame.
|
||||||
bool Detach();
|
bool Detach(DetachReason reason);
|
||||||
|
|
||||||
// A frame has swapped to active status from prerendering or the back-forward
|
// A frame has swapped to active status from prerendering or the back-forward
|
||||||
// cache. We may need to re-attach if the RFH has changed. See
|
// cache. We may need to re-attach if the RFH has changed. See
|
||||||
@ -160,6 +166,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
|||||||
|
|
||||||
void OnRenderFrameDisconnect();
|
void OnRenderFrameDisconnect();
|
||||||
|
|
||||||
|
std::string GetDebugString() const;
|
||||||
|
|
||||||
const bool is_main_frame_;
|
const bool is_main_frame_;
|
||||||
|
|
||||||
// The following members may be read/modified from any thread. All access must
|
// The following members may be read/modified from any thread. All access must
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "libcef/renderer/thread_util.h"
|
#include "libcef/renderer/thread_util.h"
|
||||||
#include "libcef/renderer/v8_impl.h"
|
#include "libcef/renderer/v8_impl.h"
|
||||||
|
|
||||||
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "content/renderer/render_frame_impl.h"
|
#include "content/renderer/render_frame_impl.h"
|
||||||
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
|
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
|
||||||
@ -331,13 +332,13 @@ CefFrameImpl::CreateResourceLoadInfoNotifierWrapper() {
|
|||||||
|
|
||||||
void CefFrameImpl::OnAttached() {
|
void CefFrameImpl::OnAttached() {
|
||||||
// Called indirectly from RenderFrameCreated.
|
// Called indirectly from RenderFrameCreated.
|
||||||
ConnectBrowserFrame();
|
ConnectBrowserFrame(ConnectReason::RENDER_FRAME_CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefFrameImpl::OnWasShown() {
|
void CefFrameImpl::OnWasShown() {
|
||||||
if (browser_connection_state_ == ConnectionState::DISCONNECTED) {
|
if (browser_connection_state_ == ConnectionState::DISCONNECTED) {
|
||||||
// Reconnect a frame that has exited the bfcache.
|
// Reconnect a frame that has exited the bfcache.
|
||||||
ConnectBrowserFrame();
|
ConnectBrowserFrame(ConnectReason::WAS_SHOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +450,7 @@ void CefFrameImpl::OnDetached() {
|
|||||||
|
|
||||||
browser_->FrameDetached(frame_id_);
|
browser_->FrameDetached(frame_id_);
|
||||||
|
|
||||||
OnBrowserFrameDisconnect();
|
OnDisconnect(DisconnectReason::DETACHED);
|
||||||
|
|
||||||
browser_ = nullptr;
|
browser_ = nullptr;
|
||||||
url_loader_factory_.reset();
|
url_loader_factory_.reset();
|
||||||
@ -457,8 +458,7 @@ void CefFrameImpl::OnDetached() {
|
|||||||
// In case we never attached.
|
// In case we never attached.
|
||||||
while (!queued_browser_actions_.empty()) {
|
while (!queued_browser_actions_.empty()) {
|
||||||
auto& action = queued_browser_actions_.front();
|
auto& action = queued_browser_actions_.front();
|
||||||
LOG(WARNING) << action.first << " sent to detached frame "
|
LOG(WARNING) << action.first << " sent to detached " << GetDebugString()
|
||||||
<< frame_util::GetFrameDebugString(frame_id_)
|
|
||||||
<< " will be ignored";
|
<< " will be ignored";
|
||||||
queued_browser_actions_.pop();
|
queued_browser_actions_.pop();
|
||||||
}
|
}
|
||||||
@ -466,8 +466,7 @@ void CefFrameImpl::OnDetached() {
|
|||||||
// In case we're destroyed without the context being created.
|
// In case we're destroyed without the context being created.
|
||||||
while (!queued_context_actions_.empty()) {
|
while (!queued_context_actions_.empty()) {
|
||||||
auto& action = queued_context_actions_.front();
|
auto& action = queued_context_actions_.front();
|
||||||
LOG(WARNING) << action.first << " sent to detached frame "
|
LOG(WARNING) << action.first << " sent to detached " << GetDebugString()
|
||||||
<< frame_util::GetFrameDebugString(frame_id_)
|
|
||||||
<< " will be ignored";
|
<< " will be ignored";
|
||||||
queued_context_actions_.pop();
|
queued_context_actions_.pop();
|
||||||
}
|
}
|
||||||
@ -487,33 +486,44 @@ void CefFrameImpl::ExecuteOnLocalFrame(const std::string& function_name,
|
|||||||
if (frame_) {
|
if (frame_) {
|
||||||
std::move(action).Run(frame_);
|
std::move(action).Run(frame_);
|
||||||
} else {
|
} else {
|
||||||
LOG(WARNING) << function_name << " sent to detached frame "
|
LOG(WARNING) << function_name << " sent to detached " << GetDebugString()
|
||||||
<< frame_util::GetFrameDebugString(frame_id_)
|
|
||||||
<< " will be ignored";
|
<< " will be ignored";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefFrameImpl::ConnectBrowserFrame() {
|
void CefFrameImpl::ConnectBrowserFrame(ConnectReason reason) {
|
||||||
DCHECK(browser_connection_state_ == ConnectionState::DISCONNECTED ||
|
DCHECK(browser_connection_state_ == ConnectionState::DISCONNECTED ||
|
||||||
browser_connection_state_ == ConnectionState::RECONNECT_PENDING);
|
browser_connection_state_ == ConnectionState::RECONNECT_PENDING);
|
||||||
|
|
||||||
|
if (VLOG_IS_ON(1)) {
|
||||||
|
std::string reason_str;
|
||||||
|
switch (reason) {
|
||||||
|
case ConnectReason::RENDER_FRAME_CREATED:
|
||||||
|
reason_str = "RENDER_FRAME_CREATED";
|
||||||
|
break;
|
||||||
|
case ConnectReason::WAS_SHOWN:
|
||||||
|
reason_str = "WAS_SHOWN";
|
||||||
|
break;
|
||||||
|
case ConnectReason::RETRY:
|
||||||
|
reason_str = base::StringPrintf(
|
||||||
|
"RETRY %zu/%zu", browser_connect_retry_ct_, kConnectionRetryMaxCt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
VLOG(1) << GetDebugString() << " connection request (reason=" << reason_str
|
||||||
|
<< ")";
|
||||||
|
}
|
||||||
|
|
||||||
// Don't attempt to connect an invalid or bfcache'd frame. If a bfcache'd
|
// Don't attempt to connect an invalid or bfcache'd frame. If a bfcache'd
|
||||||
// frame returns to active status a reconnect will be triggered via
|
// frame returns to active status a reconnect will be triggered via
|
||||||
// OnWasShown().
|
// OnWasShown().
|
||||||
if (!frame_ || blink_glue::IsInBackForwardCache(frame_)) {
|
if (!frame_ || blink_glue::IsInBackForwardCache(frame_)) {
|
||||||
browser_connection_state_ = ConnectionState::DISCONNECTED;
|
browser_connection_state_ = ConnectionState::DISCONNECTED;
|
||||||
browser_connect_timer_.Stop();
|
browser_connect_timer_.Stop();
|
||||||
LOG(INFO) << "Connection retry canceled for frame "
|
VLOG(1) << GetDebugString() << " connection retry canceled (reason="
|
||||||
<< frame_util::GetFrameDebugString(frame_id_);
|
<< (frame_ ? "BFCACHED" : "INVALID") << ")";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser_connect_retry_ct_ > 0) {
|
|
||||||
LOG(INFO) << "Connection retry " << browser_connect_retry_ct_ << "/"
|
|
||||||
<< kConnectionRetryMaxCt << " for frame "
|
|
||||||
<< frame_util::GetFrameDebugString(frame_id_);
|
|
||||||
}
|
|
||||||
|
|
||||||
browser_connection_state_ = ConnectionState::CONNECTION_PENDING;
|
browser_connection_state_ = ConnectionState::CONNECTION_PENDING;
|
||||||
browser_connect_timer_.Start(FROM_HERE, kConnectionTimeout, this,
|
browser_connect_timer_.Start(FROM_HERE, kConnectionTimeout, this,
|
||||||
&CefFrameImpl::OnBrowserFrameTimeout);
|
&CefFrameImpl::OnBrowserFrameTimeout);
|
||||||
@ -522,12 +532,13 @@ void CefFrameImpl::ConnectBrowserFrame() {
|
|||||||
CHECK(browser_frame);
|
CHECK(browser_frame);
|
||||||
|
|
||||||
// If the channel is working we should get a call to FrameAttachedAck().
|
// If the channel is working we should get a call to FrameAttachedAck().
|
||||||
// Otherwise, OnBrowserFrameDisconnect() should be called to retry the
|
// Otherwise, OnDisconnect() should be called to retry the
|
||||||
// connection.
|
// connection.
|
||||||
browser_frame->FrameAttached(receiver_.BindNewPipeAndPassRemote(),
|
browser_frame->FrameAttached(receiver_.BindNewPipeAndPassRemote(),
|
||||||
browser_connect_retry_ct_ > 0);
|
browser_connect_retry_ct_ > 0);
|
||||||
receiver_.set_disconnect_handler(
|
receiver_.set_disconnect_handler(
|
||||||
base::BindOnce(&CefFrameImpl::OnBrowserFrameDisconnect, this));
|
base::BindOnce(&CefFrameImpl::OnDisconnect, this,
|
||||||
|
DisconnectReason::RENDER_FRAME_DISCONNECT));
|
||||||
}
|
}
|
||||||
|
|
||||||
const mojo::Remote<cef::mojom::BrowserFrame>& CefFrameImpl::GetBrowserFrame(
|
const mojo::Remote<cef::mojom::BrowserFrame>& CefFrameImpl::GetBrowserFrame(
|
||||||
@ -542,19 +553,19 @@ const mojo::Remote<cef::mojom::BrowserFrame>& CefFrameImpl::GetBrowserFrame(
|
|||||||
render_frame->GetBrowserInterfaceBroker()->GetInterface(
|
render_frame->GetBrowserInterfaceBroker()->GetInterface(
|
||||||
browser_frame_.BindNewPipeAndPassReceiver());
|
browser_frame_.BindNewPipeAndPassReceiver());
|
||||||
browser_frame_.set_disconnect_handler(
|
browser_frame_.set_disconnect_handler(
|
||||||
base::BindOnce(&CefFrameImpl::OnBrowserFrameDisconnect, this));
|
base::BindOnce(&CefFrameImpl::OnDisconnect, this,
|
||||||
|
DisconnectReason::BROWSER_FRAME_DISCONNECT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return browser_frame_;
|
return browser_frame_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefFrameImpl::OnBrowserFrameTimeout() {
|
void CefFrameImpl::OnBrowserFrameTimeout() {
|
||||||
LOG(ERROR) << "Connection timeout for frame "
|
LOG(ERROR) << GetDebugString() << " connection timeout";
|
||||||
<< frame_util::GetFrameDebugString(frame_id_);
|
OnDisconnect(DisconnectReason::CONNECT_TIMEOUT);
|
||||||
OnBrowserFrameDisconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefFrameImpl::OnBrowserFrameDisconnect() {
|
void CefFrameImpl::OnDisconnect(DisconnectReason reason) {
|
||||||
// Ignore multiple calls in close proximity (which may occur if both
|
// Ignore multiple calls in close proximity (which may occur if both
|
||||||
// |browser_frame_| and |receiver_| disconnect). |frame_| will be nullptr
|
// |browser_frame_| and |receiver_| disconnect). |frame_| will be nullptr
|
||||||
// when called from/after OnDetached().
|
// when called from/after OnDetached().
|
||||||
@ -563,6 +574,46 @@ void CefFrameImpl::OnBrowserFrameDisconnect() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VLOG_IS_ON(1)) {
|
||||||
|
std::string reason_str;
|
||||||
|
switch (reason) {
|
||||||
|
case DisconnectReason::DETACHED:
|
||||||
|
reason_str = "DETACHED";
|
||||||
|
break;
|
||||||
|
case DisconnectReason::CONNECT_TIMEOUT:
|
||||||
|
reason_str = "CONNECT_TIMEOUT";
|
||||||
|
break;
|
||||||
|
case DisconnectReason::RENDER_FRAME_DISCONNECT:
|
||||||
|
reason_str = "RENDER_FRAME_DISCONNECT";
|
||||||
|
break;
|
||||||
|
case DisconnectReason::BROWSER_FRAME_DISCONNECT:
|
||||||
|
reason_str = "BROWSER_FRAME_DISCONNECT";
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string state_str;
|
||||||
|
switch (browser_connection_state_) {
|
||||||
|
case ConnectionState::DISCONNECTED:
|
||||||
|
state_str = "DISCONNECTED";
|
||||||
|
break;
|
||||||
|
case ConnectionState::CONNECTION_PENDING:
|
||||||
|
state_str = "CONNECTION_PENDING";
|
||||||
|
break;
|
||||||
|
case ConnectionState::CONNECTION_ACKED:
|
||||||
|
state_str = "CONNECTION_ACKED";
|
||||||
|
break;
|
||||||
|
case ConnectionState::RECONNECT_PENDING:
|
||||||
|
state_str = "RECONNECT_PENDING";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!frame_)
|
||||||
|
state_str += ", FRAME_INVALID";
|
||||||
|
|
||||||
|
VLOG(1) << GetDebugString() << " disconnected (reason=" << reason_str
|
||||||
|
<< ", current_state=" << state_str << ")";
|
||||||
|
}
|
||||||
|
|
||||||
browser_frame_.reset();
|
browser_frame_.reset();
|
||||||
receiver_.reset();
|
receiver_.reset();
|
||||||
browser_connection_state_ = ConnectionState::DISCONNECTED;
|
browser_connection_state_ = ConnectionState::DISCONNECTED;
|
||||||
@ -571,6 +622,8 @@ void CefFrameImpl::OnBrowserFrameDisconnect() {
|
|||||||
// Only retry if the frame is still valid.
|
// Only retry if the frame is still valid.
|
||||||
if (frame_) {
|
if (frame_) {
|
||||||
if (browser_connect_retry_ct_++ < kConnectionRetryMaxCt) {
|
if (browser_connect_retry_ct_++ < kConnectionRetryMaxCt) {
|
||||||
|
VLOG(1) << GetDebugString() << " connection retry scheduled";
|
||||||
|
|
||||||
// Retry after a delay in case the frame is currently navigating, being
|
// Retry after a delay in case the frame is currently navigating, being
|
||||||
// destroyed, or entering the bfcache. In the navigation case the retry
|
// destroyed, or entering the bfcache. In the navigation case the retry
|
||||||
// will likely succeed. In the destruction case the retry will be
|
// will likely succeed. In the destruction case the retry will be
|
||||||
@ -578,12 +631,13 @@ void CefFrameImpl::OnBrowserFrameDisconnect() {
|
|||||||
// may not be updated immediately, so we allow the reconnect timer to
|
// may not be updated immediately, so we allow the reconnect timer to
|
||||||
// trigger and check the status in ConnectBrowserFrame() instead.
|
// trigger and check the status in ConnectBrowserFrame() instead.
|
||||||
browser_connection_state_ = ConnectionState::RECONNECT_PENDING;
|
browser_connection_state_ = ConnectionState::RECONNECT_PENDING;
|
||||||
browser_connect_timer_.Start(FROM_HERE, kConnectionRetryDelay, this,
|
browser_connect_timer_.Start(
|
||||||
&CefFrameImpl::ConnectBrowserFrame);
|
FROM_HERE, kConnectionRetryDelay,
|
||||||
|
base::BindOnce(&CefFrameImpl::ConnectBrowserFrame, this,
|
||||||
|
ConnectReason::RETRY));
|
||||||
} else {
|
} else {
|
||||||
// Trigger a crash in official builds.
|
// Trigger a crash in official builds.
|
||||||
LOG(FATAL) << "Connection retry failure for frame "
|
LOG(FATAL) << GetDebugString() << " connection retry failed";
|
||||||
<< frame_util::GetFrameDebugString(frame_id_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -592,8 +646,7 @@ void CefFrameImpl::SendToBrowserFrame(const std::string& function_name,
|
|||||||
BrowserFrameAction action) {
|
BrowserFrameAction action) {
|
||||||
if (!frame_) {
|
if (!frame_) {
|
||||||
// We've been detached.
|
// We've been detached.
|
||||||
LOG(WARNING) << function_name << " sent to detached frame "
|
LOG(WARNING) << function_name << " sent to detached " << GetDebugString()
|
||||||
<< frame_util::GetFrameDebugString(frame_id_)
|
|
||||||
<< " will be ignored";
|
<< " will be ignored";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -763,6 +816,10 @@ void CefFrameImpl::ContextLifecycleStateChanged(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CefFrameImpl::GetDebugString() const {
|
||||||
|
return "frame " + frame_util::GetFrameDebugString(frame_id_);
|
||||||
|
}
|
||||||
|
|
||||||
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -109,8 +109,14 @@ class CefFrameImpl
|
|||||||
void ExecuteOnLocalFrame(const std::string& function_name,
|
void ExecuteOnLocalFrame(const std::string& function_name,
|
||||||
LocalFrameAction action);
|
LocalFrameAction action);
|
||||||
|
|
||||||
|
enum class ConnectReason {
|
||||||
|
RENDER_FRAME_CREATED,
|
||||||
|
WAS_SHOWN,
|
||||||
|
RETRY,
|
||||||
|
};
|
||||||
|
|
||||||
// Initiate the connection to the BrowserFrame channel.
|
// Initiate the connection to the BrowserFrame channel.
|
||||||
void ConnectBrowserFrame();
|
void ConnectBrowserFrame(ConnectReason reason);
|
||||||
|
|
||||||
// Returns the remote BrowserFrame object.
|
// Returns the remote BrowserFrame object.
|
||||||
using BrowserFrameType = mojo::Remote<cef::mojom::BrowserFrame>;
|
using BrowserFrameType = mojo::Remote<cef::mojom::BrowserFrame>;
|
||||||
@ -119,10 +125,17 @@ class CefFrameImpl
|
|||||||
// Called if the BrowserFrame connection attempt times out.
|
// Called if the BrowserFrame connection attempt times out.
|
||||||
void OnBrowserFrameTimeout();
|
void OnBrowserFrameTimeout();
|
||||||
|
|
||||||
// Called if/when the BrowserFrame channel is disconnected. This may occur due
|
enum class DisconnectReason {
|
||||||
// to frame navigation, destruction, or insertion into the bfcache (when the
|
DETACHED,
|
||||||
// browser-side frame representation is destroyed and closes the connection).
|
CONNECT_TIMEOUT,
|
||||||
void OnBrowserFrameDisconnect();
|
RENDER_FRAME_DISCONNECT,
|
||||||
|
BROWSER_FRAME_DISCONNECT,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Called if/when a disconnect occurs. This may occur due to frame navigation,
|
||||||
|
// destruction, or insertion into the bfcache (when the browser-side frame
|
||||||
|
// representation is destroyed and closes the connection).
|
||||||
|
void OnDisconnect(DisconnectReason reason);
|
||||||
|
|
||||||
// Send an action to the remote BrowserFrame. This will queue the action if
|
// Send an action to the remote BrowserFrame. This will queue the action if
|
||||||
// the remote frame is not yet attached.
|
// the remote frame is not yet attached.
|
||||||
@ -152,6 +165,8 @@ class CefFrameImpl
|
|||||||
void ContextLifecycleStateChanged(
|
void ContextLifecycleStateChanged(
|
||||||
blink::mojom::blink::FrameLifecycleState state) override;
|
blink::mojom::blink::FrameLifecycleState state) override;
|
||||||
|
|
||||||
|
std::string GetDebugString() const;
|
||||||
|
|
||||||
CefBrowserImpl* browser_;
|
CefBrowserImpl* browser_;
|
||||||
blink::WebLocalFrame* frame_;
|
blink::WebLocalFrame* frame_;
|
||||||
const int64 frame_id_;
|
const int64 frame_id_;
|
||||||
|
Reference in New Issue
Block a user