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

[Workers] Replace RenderProcessHostDestroyed with RenderProcessExited

This change is necessary to add dedicated workers to the performance
manager graph.

An invariant of the WorkerNode is that its ProcessNode is always valid.
This can only be accomplished by making sure that the WorkerNode is
destroyed before its ProcessNode.

Because the performance_manager::RenderProcessUserData class also
subscribes to the RenderProcessHostObserver interface and deletes the
ProcessNode when its RenderProcessHost is destroyed, we can't use
RenderProcessHostDestroyed in DedicatedWorkerHost because there are no
guaranteed ordering on the notification. In fact, since the
DedicatedWorkerHost always subscribe to the RenderProcessHost after the
performance_manager::RenderProcessUserData class, we always get the
wrong ordering in practice.

This can be easily fixed by replacing the usage of
RenderProcessHostDestroyed by RenderProcessExited in the
DedicatedWorkerHost class, which is always invoked first.

It also happens that it is a correct change to make because it is when
the process exits that the mojo connections with the renderer are
closed, not when the RenderProcessHost is destroyed.

For consistency, the same change is done with the SharedWorkerHost.

Bug: 993029, 1035555
Change-Id: Ib7d71e810cbb8d41f7a7475818d16428eff4e74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006069
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733481}
parent 178a82eb
...@@ -99,8 +99,9 @@ void DedicatedWorkerHost::LifecycleStateChanged( ...@@ -99,8 +99,9 @@ void DedicatedWorkerHost::LifecycleStateChanged(
} }
} }
void DedicatedWorkerHost::RenderProcessHostDestroyed( void DedicatedWorkerHost::RenderProcessExited(
RenderProcessHost* render_process_host) { RenderProcessHost* render_process_host,
const ChildProcessTerminationInfo& info) {
DCHECK_EQ(worker_process_host_, render_process_host); DCHECK_EQ(worker_process_host_, render_process_host);
delete this; delete this;
......
...@@ -113,8 +113,8 @@ class DedicatedWorkerHost final : public blink::mojom::DedicatedWorkerHost, ...@@ -113,8 +113,8 @@ class DedicatedWorkerHost final : public blink::mojom::DedicatedWorkerHost,
private: private:
// RenderProcessHostObserver: // RenderProcessHostObserver:
void RenderProcessHostDestroyed( void RenderProcessExited(RenderProcessHost* render_process_host,
RenderProcessHost* render_process_host) override; const ChildProcessTerminationInfo& info) override;
// Called from WorkerScriptFetchInitiator. Continues starting the dedicated // Called from WorkerScriptFetchInitiator. Continues starting the dedicated
// worker in the renderer process. // worker in the renderer process.
......
...@@ -389,8 +389,9 @@ void SharedWorkerHost::OnFeatureUsed(blink::mojom::WebFeature feature) { ...@@ -389,8 +389,9 @@ void SharedWorkerHost::OnFeatureUsed(blink::mojom::WebFeature feature) {
info.client->OnFeatureUsed(feature); info.client->OnFeatureUsed(feature);
} }
void SharedWorkerHost::RenderProcessHostDestroyed( void SharedWorkerHost::RenderProcessExited(
RenderProcessHost* render_process_host) { RenderProcessHost* render_process_host,
const ChildProcessTerminationInfo& info) {
DCHECK_EQ(worker_process_host_, render_process_host); DCHECK_EQ(worker_process_host_, render_process_host);
Destruct(); Destruct();
} }
......
...@@ -159,9 +159,9 @@ class CONTENT_EXPORT SharedWorkerHost : public blink::mojom::SharedWorkerHost, ...@@ -159,9 +159,9 @@ class CONTENT_EXPORT SharedWorkerHost : public blink::mojom::SharedWorkerHost,
void OnScriptLoadFailed() override; void OnScriptLoadFailed() override;
void OnFeatureUsed(blink::mojom::WebFeature feature) override; void OnFeatureUsed(blink::mojom::WebFeature feature) override;
// RenderProcessHost: // RenderProcessHostObserver:
void RenderProcessHostDestroyed( void RenderProcessExited(RenderProcessHost* render_process_host,
RenderProcessHost* render_process_host) override; const ChildProcessTerminationInfo& info) override;
// Returns the frame ids of this worker's clients. // Returns the frame ids of this worker's clients.
std::vector<GlobalFrameRoutingId> GetRenderFrameIDsForWorker(); std::vector<GlobalFrameRoutingId> GetRenderFrameIDsForWorker();
......
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