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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 #include "content/common/child_process_messages.h" 127 #include "content/common/child_process_messages.h"
128 #include "content/common/content_switches_internal.h" 128 #include "content/common/content_switches_internal.h"
129 #include "content/common/frame_messages.h" 129 #include "content/common/frame_messages.h"
130 #include "content/common/gpu_host_messages.h" 130 #include "content/common/gpu_host_messages.h"
131 #include "content/common/in_process_child_thread_params.h" 131 #include "content/common/in_process_child_thread_params.h"
132 #include "content/common/mojo/constants.h" 132 #include "content/common/mojo/constants.h"
133 #include "content/common/mojo/mojo_child_connection.h" 133 #include "content/common/mojo/mojo_child_connection.h"
134 #include "content/common/mojo/mojo_shell_connection_impl.h" 134 #include "content/common/mojo/mojo_shell_connection_impl.h"
135 #include "content/common/render_process_messages.h" 135 #include "content/common/render_process_messages.h"
136 #include "content/common/resource_messages.h" 136 #include "content/common/resource_messages.h"
137 #include "content/common/service_worker/embedded_worker_setup.mojom.h"
137 #include "content/common/site_isolation_policy.h" 138 #include "content/common/site_isolation_policy.h"
138 #include "content/common/view_messages.h" 139 #include "content/common/view_messages.h"
139 #include "content/public/browser/browser_context.h" 140 #include "content/public/browser/browser_context.h"
140 #include "content/public/browser/browser_thread.h" 141 #include "content/public/browser/browser_thread.h"
141 #include "content/public/browser/content_browser_client.h" 142 #include "content/public/browser/content_browser_client.h"
142 #include "content/public/browser/notification_service.h" 143 #include "content/public/browser/notification_service.h"
143 #include "content/public/browser/notification_types.h" 144 #include "content/public/browser/notification_types.h"
144 #include "content/public/browser/render_process_host_factory.h" 145 #include "content/public/browser/render_process_host_factory.h"
145 #include "content/public/browser/render_process_host_observer.h" 146 #include "content/public/browser/render_process_host_observer.h"
146 #include "content/public/browser/render_widget_host.h" 147 #include "content/public/browser/render_widget_host.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder); 456 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder);
456 }; 457 };
457 458
458 void CreateMemoryCoordinatorHandle( 459 void CreateMemoryCoordinatorHandle(
459 int render_process_id, 460 int render_process_id,
460 memory_coordinator::mojom::MemoryCoordinatorHandleRequest request) { 461 memory_coordinator::mojom::MemoryCoordinatorHandleRequest request) {
461 memory_coordinator::MemoryCoordinator::GetInstance()->CreateHandle( 462 memory_coordinator::MemoryCoordinator::GetInstance()->CreateHandle(
462 render_process_id, std::move(request)); 463 render_process_id, std::move(request));
463 } 464 }
464 465
466 class IsolatedWorkerDispatcherRecieverImpl
467 : public mojom::IsolatedWorkerDispatcherReciever {
468 public:
469 IsolatedWorkerDispatcherRecieverImpl(
470 base::WeakPtr<RenderProcessHostImpl> process,
471 mojom::IsolatedWorkerDispatcherRecieverRequest request)
472 : process_(process), binding_(this, std::move(request)) {
473 TRACE_EVENT0("ServiceWorker",
474 "IsolatedWorkerDispatcherRecieverImpl::"
475 "IsolatedWorkerDispatcherRecieverImpl");
476 LOG(ERROR) << "IsolatedWorkerDispatcherRecieverImpl";
477 }
478 ~IsolatedWorkerDispatcherRecieverImpl() override {
479 LOG(ERROR) << "~IsolatedWorkerDispatcherRecieverImpl";
480 }
481
482 void SetDispatcher(mojom::IsolatedWorkerDispatcherPtr dispatcher) override {
483 TRACE_EVENT0("ServiceWorker",
484 "IsolatedWorkerDispatcherRecieverImpl::SetDispatcher");
485 LOG(ERROR) << "IsolatedWorkerDispatcherRecieverImpl::SetDispatcher";
486 if (process_)
487 process_->SetIsolatedWorkerDispatcher(std::move(dispatcher));
488 }
489
490 private:
491 base::WeakPtr<RenderProcessHostImpl> process_;
492 mojo::StrongBinding<mojom::IsolatedWorkerDispatcherReciever> binding_;
493 };
494
495 void CreateIsolatedWorkerDispatcherReciever(
496 base::WeakPtr<RenderProcessHostImpl> process,
497 mojom::IsolatedWorkerDispatcherRecieverRequest request) {
498 TRACE_EVENT0("ServiceWorker", "CreateIsolatedWorkerDispatcherReciever");
499 LOG(ERROR) << "CreateIsolatedWorkerDispatcherReciever";
500 new IsolatedWorkerDispatcherRecieverImpl(process, std::move(request));
501 }
502
465 } // namespace 503 } // namespace
466 504
467 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; 505 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
468 506
469 base::MessageLoop* g_in_process_thread; 507 base::MessageLoop* g_in_process_thread;
470 508
471 // Stores the maximum number of renderer processes the content module can 509 // Stores the maximum number of renderer processes the content module can
472 // create. 510 // create.
473 static size_t g_max_renderer_count_override = 0; 511 static size_t g_max_renderer_count_override = 0;
474 512
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 registry.get(), 1252 registry.get(),
1215 base::Bind(&BackgroundSyncContext::CreateService, 1253 base::Bind(&BackgroundSyncContext::CreateService,
1216 base::Unretained( 1254 base::Unretained(
1217 storage_partition_impl_->GetBackgroundSyncContext()))); 1255 storage_partition_impl_->GetBackgroundSyncContext())));
1218 AddUIThreadInterface( 1256 AddUIThreadInterface(
1219 registry.get(), 1257 registry.get(),
1220 base::Bind(&PlatformNotificationContextImpl::CreateService, 1258 base::Bind(&PlatformNotificationContextImpl::CreateService,
1221 base::Unretained( 1259 base::Unretained(
1222 storage_partition_impl_->GetPlatformNotificationContext()), 1260 storage_partition_impl_->GetPlatformNotificationContext()),
1223 GetID())); 1261 GetID()));
1262 AddUIThreadInterface(registry.get(),
1263 base::Bind(&CreateIsolatedWorkerDispatcherReciever,
1264 weak_factory_.GetWeakPtr()));
1224 AddUIThreadInterface( 1265 AddUIThreadInterface(
1225 registry.get(), 1266 registry.get(),
1226 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, 1267 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService,
1227 base::Unretained(this))); 1268 base::Unretained(this)));
1228 AddUIThreadInterface( 1269 AddUIThreadInterface(
1229 registry.get(), 1270 registry.get(),
1230 base::Bind(&BroadcastChannelProvider::Connect, 1271 base::Bind(&BroadcastChannelProvider::Connect,
1231 base::Unretained( 1272 base::Unretained(
1232 storage_partition_impl_->GetBroadcastChannelProvider()))); 1273 storage_partition_impl_->GetBroadcastChannelProvider())));
1233 if (memory_coordinator::IsEnabled()) { 1274 if (memory_coordinator::IsEnabled()) {
(...skipping 10 matching lines...) Expand all
1244 file_task_runner); 1285 file_task_runner);
1245 #endif 1286 #endif
1246 1287
1247 // These callbacks will be run immediately on the IO thread. 1288 // These callbacks will be run immediately on the IO thread.
1248 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); 1289 registry->AddInterface(base::Bind(&DeviceLightHost::Create));
1249 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); 1290 registry->AddInterface(base::Bind(&DeviceMotionHost::Create));
1250 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); 1291 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create));
1251 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); 1292 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create));
1252 registry->AddInterface( 1293 registry->AddInterface(
1253 base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_)); 1294 base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_));
1295 registry->AddInterface(base::Bind(
1296 &ServiceWorkerContextWrapper::CreateService,
1297 base::Unretained(storage_partition_impl_->GetServiceWorkerContext())));
1254 1298
1255 // This is to support usage of WebSockets in cases in which there is no 1299 // This is to support usage of WebSockets in cases in which there is no
1256 // associated RenderFrame (e.g., Shared Workers). 1300 // associated RenderFrame (e.g., Shared Workers).
1257 AddUIThreadInterface( 1301 AddUIThreadInterface(
1258 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), 1302 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(),
1259 MSG_ROUTING_NONE)); 1303 MSG_ROUTING_NONE));
1260 1304
1261 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), 1305 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(),
1262 this); 1306 this);
1263 1307
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 return; 2972 return;
2929 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 2973 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
2930 2974
2931 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 2975 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
2932 // enough information here so that we can determine what the bad message was. 2976 // enough information here so that we can determine what the bad message was.
2933 base::debug::Alias(&error); 2977 base::debug::Alias(&error);
2934 bad_message::ReceivedBadMessage(process.get(), 2978 bad_message::ReceivedBadMessage(process.get(),
2935 bad_message::RPH_MOJO_PROCESS_ERROR); 2979 bad_message::RPH_MOJO_PROCESS_ERROR);
2936 } 2980 }
2937 2981
2982 void RenderProcessHostImpl::SetIsolatedWorkerDispatcher(
2983 mojo::InterfacePtr<mojom::IsolatedWorkerDispatcher> dispatcher) {
2984 LOG(ERROR)
2985 << "RenderProcessHostImpl::SetIsolatedWorkerDispatcher----------SetSet";
2986 isolated_worker_dispatcher_.reset(
2987 new mojom::IsolatedWorkerDispatcherPtr(std::move(dispatcher)));
2988 if (isolated_worker_dispatcher_callbacks_.empty())
2989 return;
2990 std::vector<base::Callback<void(
2991 mojo::InterfacePtr<mojom::IsolatedWorkerDispatcher>*)>>
2992 callbacks;
2993 callbacks.swap(isolated_worker_dispatcher_callbacks_);
2994 for (auto& callback : callbacks) {
2995 LOG(ERROR)
2996 << "callback>><>>><><><<<>><>>><><><<<>><>>><><><<<>><>>><><><<<";
2997 callback.Run(isolated_worker_dispatcher_.get());
2998 }
2999 }
3000 void RenderProcessHostImpl::GetIsolatedWorkerDispatcher(
3001 const base::Callback<
3002 void(mojo::InterfacePtr<mojom::IsolatedWorkerDispatcher>*)>& callback) {
3003 LOG(ERROR) << "GetIsolatedWorkerDispatcher";
3004 if (isolated_worker_dispatcher_) {
3005 callback.Run(isolated_worker_dispatcher_.get());
3006 return;
3007 }
3008 LOG(ERROR) << "adding to "
3009 "callback>><>>><><><<<>><>>><><><<<>><>>><><><<<>><>>><><><<"
3010 "<";
3011 isolated_worker_dispatcher_callbacks_.push_back(callback);
3012 }
3013
2938 } // namespace content 3014 } // namespace content
OLDNEW
« 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