Commit 7f57b6c6 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Chromium LUCI CQ

Return nullptr from GetRenderer() when the map doesn't have the process

Previously RendererStartupHelper::GetRenderer() returns
mojom::Renderer* having DCHECK that makes sure the map includes
it. But, GetRenderer() would be accessed before the map is updated.

This CL returns nullptr from RendererStartupHelper::GetRenderer()
when |process_mojo_map_| doesn't have the information corresponding
to the process.

Bug: 1157200
Change-Id: Ifacc4cfcd9457716d7eca700b7df4be8576f68b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583663
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836393}
parent 0d2a8075
......@@ -794,7 +794,8 @@ void ActivityLog::CheckActive(bool use_cached) {
RendererStartupHelperFactory::GetForBrowserContext(
host->GetBrowserContext())
->GetRenderer(host);
renderer->SetActivityLoggingEnabled(is_active_);
if (renderer)
renderer->SetActivityLoggingEnabled(is_active_);
}
}
}
......
......@@ -289,8 +289,9 @@ void RendererStartupHelper::OnExtensionUnloaded(const Extension& extension) {
const std::set<content::RenderProcessHost*>& loaded_process_set =
extension_process_map_[extension.id()];
for (content::RenderProcessHost* process : loaded_process_set) {
DCHECK(base::Contains(process_mojo_map_, process));
GetRenderer(process)->UnloadExtension(extension.id());
mojom::Renderer* renderer = GetRenderer(process);
if (renderer)
renderer->UnloadExtension(extension.id());
}
// Resets registered origin access lists in the BrowserContext asynchronously.
......@@ -317,7 +318,8 @@ RendererStartupHelper::BindNewRendererRemote(
mojom::Renderer* RendererStartupHelper::GetRenderer(
content::RenderProcessHost* process) {
DCHECK(base::Contains(process_mojo_map_, process));
if (!base::Contains(process_mojo_map_, process))
return nullptr;
return process_mojo_map_.find(process)->second.get();
}
//////////////////////////////////////////////////////////////////////////////
......
......@@ -68,8 +68,10 @@ class RendererStartupHelper : public KeyedService,
void OnExtensionUnloaded(const Extension& extension);
void OnExtensionLoaded(const Extension& extension);
// Returns mojom::Renderer* corresponding to |process|. Note that the callers
// should pass a valid content::RenderProcessHost*.
// Returns mojom::Renderer* corresponding to |process|. This would return
// nullptr when it's called before |process| is inserted to
// |process_mojo_map_| or after it's deleted. Note that the callers should
// pass a valid content::RenderProcessHost*.
mojom::Renderer* GetRenderer(content::RenderProcessHost* process);
protected:
......
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