Use observer to provide OnRendererUnresponsive
This commit is contained in:
parent
bffb31c337
commit
a3124e8873
4 changed files with 19 additions and 14 deletions
|
@ -636,8 +636,6 @@ void WebContents::RendererUnresponsive(
|
|||
content::WebContents* source,
|
||||
const content::WebContentsUnresponsiveState& unresponsive_state) {
|
||||
Emit("unresponsive");
|
||||
if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window())
|
||||
owner_window()->RendererUnresponsive(source);
|
||||
}
|
||||
|
||||
void WebContents::RendererResponsive(content::WebContents* source) {
|
||||
|
|
|
@ -49,6 +49,13 @@ class WebViewGuestDelegate;
|
|||
|
||||
namespace api {
|
||||
|
||||
// Certain events are only in WebContentsDelegate, provide our own Observer to
|
||||
// dispatch those events.
|
||||
class ExtendedWebContentsObserver {
|
||||
virtual void OnRendererResponsive() {}
|
||||
};
|
||||
|
||||
// Wrapper around the content::WebContents.
|
||||
class WebContents : public mate::TrackableObject<WebContents>,
|
||||
public CommonWebContentsDelegate,
|
||||
public content::WebContentsObserver {
|
||||
|
|
|
@ -474,17 +474,6 @@ void NativeWindow::CloseContents(content::WebContents* source) {
|
|||
window_unresposive_closure_.Cancel();
|
||||
}
|
||||
|
||||
void NativeWindow::RendererUnresponsive(content::WebContents* source) {
|
||||
// Schedule the unresponsive shortly later, since we may receive the
|
||||
// responsive event soon. This could happen after the whole application had
|
||||
// blocked for a while.
|
||||
// Also notice that when closing this event would be ignored because we have
|
||||
// explicitly started a close timeout counter. This is on purpose because we
|
||||
// don't want the unresponsive event to be sent too early when user is closing
|
||||
// the window.
|
||||
ScheduleUnresponsiveEvent(50);
|
||||
}
|
||||
|
||||
void NativeWindow::RendererResponsive(content::WebContents* source) {
|
||||
window_unresposive_closure_.Cancel();
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
|
@ -659,6 +648,17 @@ void NativeWindow::BeforeUnloadDialogCancelled() {
|
|||
window_unresposive_closure_.Cancel();
|
||||
}
|
||||
|
||||
void NativeWindow::OnRendererUnresponsive(content::RenderWidgetHost*) {
|
||||
// Schedule the unresponsive shortly later, since we may receive the
|
||||
// responsive event soon. This could happen after the whole application had
|
||||
// blocked for a while.
|
||||
// Also notice that when closing this event would be ignored because we have
|
||||
// explicitly started a close timeout counter. This is on purpose because we
|
||||
// don't want the unresponsive event to be sent too early when user is closing
|
||||
// the window.
|
||||
ScheduleUnresponsiveEvent(50);
|
||||
}
|
||||
|
||||
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||
if (!window_unresposive_closure_.IsCancelled())
|
||||
return;
|
||||
|
|
|
@ -235,7 +235,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||
|
||||
// Methods called by the WebContents.
|
||||
virtual void CloseContents(content::WebContents* source);
|
||||
virtual void RendererUnresponsive(content::WebContents* source);
|
||||
virtual void RendererResponsive(content::WebContents* source);
|
||||
virtual void HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
|
@ -317,6 +316,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadDialogCancelled() override;
|
||||
void OnRendererUnresponsive(content::RenderWidgetHost*) override;
|
||||
|
||||
private:
|
||||
// Schedule a notification unresponsive event.
|
||||
|
|
Loading…
Reference in a new issue