Commit b3d355f2 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

OOPIF-ize hung renderers part 1

This modernizes the WebContentsObserver interface.

BUG=767526

Change-Id: I55b92fabf7a62cc932124822a91da1ffe2230549
Reviewed-on: https://chromium-review.googlesource.com/889939Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532563}
parent f3c86172
......@@ -13,12 +13,11 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
using content::RenderFrameHost;
using content::RenderWidgetHost;
using content::RenderProcessHost;
using content::SiteInstance;
using content::WebContents;
......@@ -55,7 +54,7 @@ class WebContentsEntry : public content::WebContentsObserver {
RenderFrameHost* new_host) override;
void RenderFrameCreated(RenderFrameHost*) override;
void WebContentsDestroyed() override;
void OnRendererUnresponsive(RenderWidgetHost* render_widget_host) override;
void OnRendererUnresponsive(RenderProcessHost* render_process_host) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
void TitleWasSet(content::NavigationEntry* entry) override;
......@@ -206,12 +205,11 @@ void WebContentsEntry::WebContentsDestroyed() {
}
void WebContentsEntry::OnRendererUnresponsive(
RenderWidgetHost* render_widget_host) {
// Find the first RenderFrameHost matching the RenderWidgetHost.
RenderProcessHost* render_process_host) {
// Find the first RenderFrameHost matching the RenderProcessHost.
RendererTask* task = nullptr;
for (const auto& pair : tasks_by_frames_) {
if (pair.first->GetView() == render_widget_host->GetView()) {
DCHECK_EQ(pair.first->GetProcess(), render_widget_host->GetProcess());
if (pair.first->GetProcess() == render_process_host) {
task = pair.second;
break;
}
......
......@@ -5413,8 +5413,10 @@ void WebContentsImpl::OnIgnoredUIEvent() {
void WebContentsImpl::RendererUnresponsive(
RenderWidgetHostImpl* render_widget_host) {
RenderProcessHost* hung_process = render_widget_host->GetProcess();
for (auto& observer : observers_)
observer.OnRendererUnresponsive(render_widget_host);
observer.OnRendererUnresponsive(hung_process);
// Don't show hung renderer dialog for a swapped out RVH.
if (render_widget_host != GetRenderViewHost()->GetWidget())
......
......@@ -33,6 +33,7 @@ namespace content {
class NavigationEntry;
class NavigationHandle;
class RenderFrameHost;
class RenderProcessHost;
class RenderViewHost;
class RenderWidgetHost;
class WebContents;
......@@ -128,9 +129,9 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener {
virtual void RenderViewHostChanged(RenderViewHost* old_host,
RenderViewHost* new_host) {}
// This method is invoked when the process for the current main
// RenderFrameHost becomes unresponsive.
virtual void OnRendererUnresponsive(RenderWidgetHost* render_widget_host) {}
// This method is invoked when a process in the WebContents becomes
// unresponsive.
virtual void OnRendererUnresponsive(RenderProcessHost* render_process_host) {}
// Navigation ----------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment