summaryrefslogtreecommitdiff
path: root/chromium/content/browser/renderer_host/render_process_host_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/renderer_host/render_process_host_impl.cc')
-rw-r--r--chromium/content/browser/renderer_host/render_process_host_impl.cc46
1 files changed, 41 insertions, 5 deletions
diff --git a/chromium/content/browser/renderer_host/render_process_host_impl.cc b/chromium/content/browser/renderer_host/render_process_host_impl.cc
index 8dc869f6971..368ade16b1a 100644
--- a/chromium/content/browser/renderer_host/render_process_host_impl.cc
+++ b/chromium/content/browser/renderer_host/render_process_host_impl.cc
@@ -1166,6 +1166,13 @@ void RemoveCorbExceptionForPluginOnIOThread(int process_id) {
network::CrossOriginReadBlocking::RemoveExceptionForPlugin(process_id);
}
+RenderProcessHostImpl::CodeCacheHostReceiverHandler&
+GetCodeCacheHostReceiverHandler() {
+ static base::NoDestructor<RenderProcessHostImpl::CodeCacheHostReceiverHandler>
+ instance;
+ return *instance;
+}
+
// This is the entry point (i.e. this is called on the UI thread *before*
// we post a task for RemoveCorbExceptionForPluginOnIOThread).
void RemoveCorbExceptionForPluginOnUIThread(int process_id) {
@@ -1609,6 +1616,11 @@ void RenderProcessHostImpl::SetBroadcastChannelProviderRequestHandlerForTesting(
GetBroadcastChannelProviderRequestHandler() = handler;
}
+void RenderProcessHostImpl::SetCodeCacheHostReceiverHandlerForTesting(
+ CodeCacheHostReceiverHandler handler) {
+ GetCodeCacheHostReceiverHandler() = handler;
+}
+
RenderProcessHostImpl::~RenderProcessHostImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#ifndef NDEBUG
@@ -2161,11 +2173,8 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
AddUIThreadInterface(
registry.get(),
- base::BindRepeating(
- &CodeCacheHostImpl::Create, GetID(),
- base::RetainedRef(storage_partition_impl_->GetCacheStorageContext()),
- base::RetainedRef(
- storage_partition_impl_->GetGeneratedCodeCacheContext())));
+ base::BindRepeating(&RenderProcessHostImpl::CreateCodeCacheHost,
+ base::Unretained(this)));
#if BUILDFLAG(ENABLE_REPORTING)
AddUIThreadInterface(
@@ -2346,6 +2355,27 @@ void RenderProcessHostImpl::CreateBroadcastChannelProvider(
id_, std::move(request));
}
+void RenderProcessHostImpl::CreateCodeCacheHost(
+ blink::mojom::CodeCacheHostRequest request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // There should be at most one CodeCacheHostImpl for any given
+ // RenderProcessHost.
+ DCHECK(!code_cache_host_impl_);
+
+ // Create a new CodeCacheHostImpl and bind it to the given receiver.
+ code_cache_host_impl_ = std::make_unique<CodeCacheHostImpl>(
+ GetID(), storage_partition_impl_->GetCacheStorageContext(),
+ storage_partition_impl_->GetGeneratedCodeCacheContext(),
+ std::move(request));
+
+ // If there is a callback registered, then invoke it with the newly
+ // created CodeCacheHostImpl.
+ if (!GetCodeCacheHostReceiverHandler().is_null()) {
+ GetCodeCacheHostReceiverHandler().Run(this, code_cache_host_impl_.get());
+ }
+}
+
void RenderProcessHostImpl::BindVideoDecoderService(
media::mojom::InterfaceFactoryRequest request) {
if (!video_decoder_proxy_)
@@ -4234,6 +4264,12 @@ void RenderProcessHostImpl::ResetIPC() {
// for that.
frame_sink_provider_.Unbind();
+ // If RenderProcessHostImpl is reused, the next renderer will send a new
+ // request for CodeCacheHost. Make sure that we clear the stale
+ // object so that we can clearly create the new CodeCacheHostImpl while
+ // asserting we don't have any duplicates.
+ code_cache_host_impl_.reset();
+
// It's important not to wait for the DeleteTask to delete the channel
// proxy. Kill it off now. That way, in case the profile is going away, the
// rest of the objects attached to this RenderProcessHost start going