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

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

Issue 2118243002: [proof-of-concept] SW thread independent of the main thread Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 dc2f91b48d2f6c51019369ede5ac168eda7a8622..3045dc571dc8f8fcdb13bfbb192390c2093b878b 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -134,6 +134,7 @@
#include "content/common/mojo/mojo_shell_connection_impl.h"
#include "content/common/render_process_messages.h"
#include "content/common/resource_messages.h"
+#include "content/common/service_worker/embedded_worker_setup.mojom.h"
#include "content/common/site_isolation_policy.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_context.h"
@@ -462,6 +463,43 @@ void CreateMemoryCoordinatorHandle(
render_process_id, std::move(request));
}
+class IsolatedWorkerDispatcherRecieverImpl
+ : public mojom::IsolatedWorkerDispatcherReciever {
+ public:
+ IsolatedWorkerDispatcherRecieverImpl(
+ base::WeakPtr<RenderProcessHostImpl> process,
+ mojom::IsolatedWorkerDispatcherRecieverRequest request)
+ : process_(process), binding_(this, std::move(request)) {
+ TRACE_EVENT0("ServiceWorker",
+ "IsolatedWorkerDispatcherRecieverImpl::"
+ "IsolatedWorkerDispatcherRecieverImpl");
+ LOG(ERROR) << "IsolatedWorkerDispatcherRecieverImpl";
+ }
+ ~IsolatedWorkerDispatcherRecieverImpl() override {
+ LOG(ERROR) << "~IsolatedWorkerDispatcherRecieverImpl";
+ }
+
+ void SetDispatcher(mojom::IsolatedWorkerDispatcherPtr dispatcher) override {
+ TRACE_EVENT0("ServiceWorker",
+ "IsolatedWorkerDispatcherRecieverImpl::SetDispatcher");
+ LOG(ERROR) << "IsolatedWorkerDispatcherRecieverImpl::SetDispatcher";
+ if (process_)
+ process_->SetIsolatedWorkerDispatcher(std::move(dispatcher));
+ }
+
+ private:
+ base::WeakPtr<RenderProcessHostImpl> process_;
+ mojo::StrongBinding<mojom::IsolatedWorkerDispatcherReciever> binding_;
+};
+
+void CreateIsolatedWorkerDispatcherReciever(
+ base::WeakPtr<RenderProcessHostImpl> process,
+ mojom::IsolatedWorkerDispatcherRecieverRequest request) {
+ TRACE_EVENT0("ServiceWorker", "CreateIsolatedWorkerDispatcherReciever");
+ LOG(ERROR) << "CreateIsolatedWorkerDispatcherReciever";
+ new IsolatedWorkerDispatcherRecieverImpl(process, std::move(request));
+}
+
} // namespace
RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
@@ -1221,6 +1259,9 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
base::Unretained(
storage_partition_impl_->GetPlatformNotificationContext()),
GetID()));
+ AddUIThreadInterface(registry.get(),
+ base::Bind(&CreateIsolatedWorkerDispatcherReciever,
+ weak_factory_.GetWeakPtr()));
AddUIThreadInterface(
registry.get(),
base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService,
@@ -1251,6 +1292,9 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create));
registry->AddInterface(
base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_));
+ registry->AddInterface(base::Bind(
+ &ServiceWorkerContextWrapper::CreateService,
+ base::Unretained(storage_partition_impl_->GetServiceWorkerContext())));
// This is to support usage of WebSockets in cases in which there is no
// associated RenderFrame (e.g., Shared Workers).
@@ -2935,4 +2979,36 @@ void RenderProcessHostImpl::OnMojoError(
bad_message::RPH_MOJO_PROCESS_ERROR);
}
+void RenderProcessHostImpl::SetIsolatedWorkerDispatcher(
+ mojo::InterfacePtr<mojom::IsolatedWorkerDispatcher> dispatcher) {
+ LOG(ERROR)
+ << "RenderProcessHostImpl::SetIsolatedWorkerDispatcher----------SetSet";
+ isolated_worker_dispatcher_.reset(
+ new mojom::IsolatedWorkerDispatcherPtr(std::move(dispatcher)));
+ if (isolated_worker_dispatcher_callbacks_.empty())
+ return;
+ std::vector<base::Callback<void(
+ mojo::InterfacePtr<mojom::IsolatedWorkerDispatcher>*)>>
+ callbacks;
+ callbacks.swap(isolated_worker_dispatcher_callbacks_);
+ for (auto& callback : callbacks) {
+ LOG(ERROR)
+ << "callback>><>>><><><<<>><>>><><><<<>><>>><><><<<>><>>><><><<<";
+ callback.Run(isolated_worker_dispatcher_.get());
+ }
+}
+void RenderProcessHostImpl::GetIsolatedWorkerDispatcher(
+ const base::Callback<
+ void(mojo::InterfacePtr<mojom::IsolatedWorkerDispatcher>*)>& callback) {
+ LOG(ERROR) << "GetIsolatedWorkerDispatcher";
+ if (isolated_worker_dispatcher_) {
+ callback.Run(isolated_worker_dispatcher_.get());
+ return;
+ }
+ LOG(ERROR) << "adding to "
+ "callback>><>>><><><<<>><>>><><><<<>><>>><><><<<>><>>><><><<"
+ "<";
+ isolated_worker_dispatcher_callbacks_.push_back(callback);
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/service_worker/service_worker_context_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698