Commit 9185728d authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Invoke RenderProcessExited() in MockRenderProcessHost::Cleanup()

This CL makes it so that the behavior of the mock class is closer to
real implementation of RenderProcessHost.

This change will be used in a follow up CL where the lifetime of a
class is tied to the existence of the renderer process.

Bug: 993029, 1035555
Change-Id: I0c933c7c0b3890bc561015be847e145fdd96410a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006450
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733471}
parent babee477
...@@ -100,7 +100,6 @@ void MockRenderProcessHost::SimulateRenderProcessExit( ...@@ -100,7 +100,6 @@ void MockRenderProcessHost::SimulateRenderProcessExit(
termination_info.status = status; termination_info.status = status;
termination_info.exit_code = exit_code; termination_info.exit_code = exit_code;
termination_info.renderer_has_visible_clients = VisibleClientCount() > 0; termination_info.renderer_has_visible_clients = VisibleClientCount() > 0;
termination_info.renderer_was_subframe = GetFrameDepth() > 0;
NotificationService::current()->Notify( NotificationService::current()->Notify(
NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this),
Details<ChildProcessTerminationInfo>(&termination_info)); Details<ChildProcessTerminationInfo>(&termination_info));
...@@ -268,6 +267,15 @@ static void DeleteIt(base::WeakPtr<MockRenderProcessHost> h) { ...@@ -268,6 +267,15 @@ static void DeleteIt(base::WeakPtr<MockRenderProcessHost> h) {
void MockRenderProcessHost::Cleanup() { void MockRenderProcessHost::Cleanup() {
if (listeners_.IsEmpty()) { if (listeners_.IsEmpty()) {
if (IsInitializedAndNotDead()) {
ChildProcessTerminationInfo termination_info;
termination_info.status = base::TERMINATION_STATUS_NORMAL_TERMINATION;
termination_info.exit_code = 0;
termination_info.renderer_has_visible_clients = VisibleClientCount() > 0;
for (auto& observer : observers_)
observer.RenderProcessExited(this, termination_info);
}
for (auto& observer : observers_) for (auto& observer : observers_)
observer.RenderProcessHostDestroyed(this); observer.RenderProcessHostDestroyed(this);
// Post the delete of |this| as a WeakPtr so that if |this| is deleted by a // Post the delete of |this| as a WeakPtr so that if |this| is deleted by a
......
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