Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 0589ae0fd41baea60f25ee2b9d37029e560ae10d..a29d33ee5c050ea02fcc936da9ea812b5d7b77fb 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -78,6 +78,7 @@
#include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
#include "content/browser/loader/resource_message_filter.h"
#include "content/browser/loader/resource_scheduler_filter.h"
+#include "content/browser/loader/url_loader_factory_impl.h"
#include "content/browser/media/capture/audio_mirroring_manager.h"
#include "content/browser/media/capture/image_capture_impl.h"
#include "content/browser/media/media_internals.h"
@@ -132,6 +133,7 @@
#include "content/common/render_process_messages.h"
#include "content/common/resource_messages.h"
#include "content/common/site_isolation_policy.h"
+#include "content/common/url_loader_factory.mojom.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -447,6 +449,10 @@ std::string UintVectorToString(const std::vector<unsigned>& vector) {
return str;
}
+void Noop(scoped_refptr<ResourceMessageFilter> unused) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
} // namespace
RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
@@ -628,6 +634,7 @@ void RenderProcessHostImpl::RegisterRendererMainThreadFactory(
}
RenderProcessHostImpl::~RenderProcessHostImpl() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
#ifndef NDEBUG
DCHECK(is_self_deleted_)
<< "RenderProcessHostImpl is destroyed by something other than itself";
@@ -857,16 +864,16 @@ void RenderProcessHostImpl::CreateMessageFilters() {
scoped_refptr<ChromeBlobStorageContext> blob_storage_context =
ChromeBlobStorageContext::GetFor(browser_context);
- ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter(
+ resource_message_filter_ = new ResourceMessageFilter(
GetID(), PROCESS_TYPE_RENDERER,
- storage_partition_impl_->GetAppCacheService(),
- blob_storage_context.get(),
+ storage_partition_impl_->GetAppCacheService(), blob_storage_context.get(),
storage_partition_impl_->GetFileSystemContext(),
storage_partition_impl_->GetServiceWorkerContext(),
storage_partition_impl_->GetHostZoomLevelContext(),
get_contexts_callback);
- AddFilter(resource_message_filter);
+ AddFilter(resource_message_filter_.get());
+
MediaStreamManager* media_stream_manager =
BrowserMainLoop::GetInstance()->media_stream_manager();
// The AudioInputRendererHost and AudioRendererHost needs to be available for
@@ -1051,6 +1058,9 @@ void RenderProcessHostImpl::RegisterMojoServices() {
mojo_application_host_->service_registry_android());
#endif
+ mojo_application_host_->service_registry()->AddService(base::Bind(
+ &RenderProcessHostImpl::CreateURLLoaderFactory, base::Unretained(this)));
+
GetContentClient()->browser()->RegisterRenderProcessMojoServices(
mojo_application_host_->service_registry());
}
@@ -1064,6 +1074,12 @@ void RenderProcessHostImpl::CreateStoragePartitionService(
}
}
+void RenderProcessHostImpl::CreateURLLoaderFactory(
+ mojo::InterfaceRequest<mojom::URLLoaderFactory> request) {
+ url_loader_factory_.reset(
+ new URLLoaderFactoryImpl(resource_message_filter_, std::move(request)));
+}
+
int RenderProcessHostImpl::GetNextRoutingID() {
return widget_helper_->GetNextRoutingID();
}
@@ -1801,6 +1817,7 @@ bool RenderProcessHostImpl::IgnoreInputEvents() const {
}
void RenderProcessHostImpl::Cleanup() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
// If within_process_died_observer_ is true, one of our observers performed an
// action that caused us to die (e.g. http://crbug.com/339504). Therefore,
// delay the destruction until all of the observer callbacks have been made,
@@ -1880,6 +1897,11 @@ void RenderProcessHostImpl::Cleanup() {
// The following members should be cleared in ProcessDied() as well!
message_port_message_filter_ = NULL;
+ url_loader_factory_ = nullptr;
+ // We need to destruct the filter on the IO thread.
jam 2016/05/13 00:55:06 the standard way we deal with this for BrowserMess
yhirano 2016/05/17 12:38:49 Thanks, Done.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&Noop, std::move(resource_message_filter_)));
RemoveUserData(kSessionStorageHolderKey);
@@ -2397,6 +2419,11 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead,
within_process_died_observer_ = false;
message_port_message_filter_ = NULL;
+ url_loader_factory_ = nullptr;
+ // We need to destruct the filter on the IO thread.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&Noop, std::move(resource_message_filter_)));
RemoveUserData(kSessionStorageHolderKey);
IDMap<IPC::Listener>::iterator iter(&listeners_);

Powered by Google App Engine
This is Rietveld 408576698