| OLD | NEW |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #include "content/browser/loader/resource_message_filter.h" | 78 #include "content/browser/loader/resource_message_filter.h" |
| 79 #include "content/browser/loader/resource_scheduler_filter.h" | 79 #include "content/browser/loader/resource_scheduler_filter.h" |
| 80 #include "content/browser/media/capture/audio_mirroring_manager.h" | 80 #include "content/browser/media/capture/audio_mirroring_manager.h" |
| 81 #include "content/browser/media/capture/image_capture_impl.h" | 81 #include "content/browser/media/capture/image_capture_impl.h" |
| 82 #include "content/browser/media/media_internals.h" | 82 #include "content/browser/media/media_internals.h" |
| 83 #include "content/browser/media/midi_host.h" | 83 #include "content/browser/media/midi_host.h" |
| 84 #include "content/browser/memory/memory_message_filter.h" | 84 #include "content/browser/memory/memory_message_filter.h" |
| 85 #include "content/browser/message_port_message_filter.h" | 85 #include "content/browser/message_port_message_filter.h" |
| 86 #include "content/browser/mime_registry_impl.h" | 86 #include "content/browser/mime_registry_impl.h" |
| 87 #include "content/browser/mojo/constants.h" | 87 #include "content/browser/mojo/constants.h" |
| 88 #include "content/browser/mojo/mojo_application_host.h" | |
| 89 #include "content/browser/mojo/mojo_child_connection.h" | 88 #include "content/browser/mojo/mojo_child_connection.h" |
| 90 #include "content/browser/notifications/notification_message_filter.h" | 89 #include "content/browser/notifications/notification_message_filter.h" |
| 91 #include "content/browser/notifications/platform_notification_context_impl.h" | 90 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 92 #include "content/browser/permissions/permission_service_context.h" | 91 #include "content/browser/permissions/permission_service_context.h" |
| 93 #include "content/browser/permissions/permission_service_impl.h" | 92 #include "content/browser/permissions/permission_service_impl.h" |
| 94 #include "content/browser/profiler_message_filter.h" | 93 #include "content/browser/profiler_message_filter.h" |
| 95 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 94 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
| 96 #include "content/browser/quota_dispatcher_host.h" | 95 #include "content/browser/quota_dispatcher_host.h" |
| 97 #include "content/browser/renderer_host/clipboard_message_filter.h" | 96 #include "content/browser/renderer_host/clipboard_message_filter.h" |
| 98 #include "content/browser/renderer_host/database_message_filter.h" | 97 #include "content/browser/renderer_host/database_message_filter.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 BrowserContext* browser_context, | 535 BrowserContext* browser_context, |
| 537 StoragePartitionImpl* storage_partition_impl, | 536 StoragePartitionImpl* storage_partition_impl, |
| 538 bool is_for_guests_only) | 537 bool is_for_guests_only) |
| 539 : fast_shutdown_started_(false), | 538 : fast_shutdown_started_(false), |
| 540 deleting_soon_(false), | 539 deleting_soon_(false), |
| 541 #ifndef NDEBUG | 540 #ifndef NDEBUG |
| 542 is_self_deleted_(false), | 541 is_self_deleted_(false), |
| 543 #endif | 542 #endif |
| 544 pending_views_(0), | 543 pending_views_(0), |
| 545 child_token_(mojo::edk::GenerateRandomToken()), | 544 child_token_(mojo::edk::GenerateRandomToken()), |
| 546 mojo_application_host_(new MojoApplicationHost(child_token_)), | |
| 547 visible_widgets_(0), | 545 visible_widgets_(0), |
| 548 is_process_backgrounded_(false), | 546 is_process_backgrounded_(false), |
| 549 is_initialized_(false), | 547 is_initialized_(false), |
| 550 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 548 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 551 browser_context_(browser_context), | 549 browser_context_(browser_context), |
| 552 storage_partition_impl_(storage_partition_impl), | 550 storage_partition_impl_(storage_partition_impl), |
| 553 sudden_termination_allowed_(true), | 551 sudden_termination_allowed_(true), |
| 554 ignore_input_events_(false), | 552 ignore_input_events_(false), |
| 555 is_for_guests_only_(is_for_guests_only), | 553 is_for_guests_only_(is_for_guests_only), |
| 556 gpu_observer_registered_(false), | 554 gpu_observer_registered_(false), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 // render process. This ensures that when a test is being run in one of the | 593 // render process. This ensures that when a test is being run in one of the |
| 596 // single process modes, the global attachment broker is the privileged | 594 // single process modes, the global attachment broker is the privileged |
| 597 // attachment broker, rather than an unprivileged attachment broker. | 595 // attachment broker, rather than an unprivileged attachment broker. |
| 598 #if defined(OS_MACOSX) | 596 #if defined(OS_MACOSX) |
| 599 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded( | 597 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded( |
| 600 MachBroker::GetInstance()); | 598 MachBroker::GetInstance()); |
| 601 #else | 599 #else |
| 602 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded(); | 600 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded(); |
| 603 #endif // defined(OS_MACOSX) | 601 #endif // defined(OS_MACOSX) |
| 604 #endif // USE_ATTACHMENT_BROKER | 602 #endif // USE_ATTACHMENT_BROKER |
| 603 |
| 604 shell::Connector* connector = |
| 605 BrowserContext::GetShellConnectorFor(browser_context_); |
| 606 // Some embedders may not initialize Mojo or the shell connector for a browser |
| 607 // context (e.g. Android WebView)... so just fall back to the per-process |
| 608 // connector. |
| 609 if (!connector) { |
| 610 // Additionally, some test code may not initialize the process-wide |
| 611 // MojoShellConnection prior to this point. This class of test code doesn't |
| 612 // care about render processes so we can initialize a dummy one. |
| 613 if (!MojoShellConnection::GetForProcess()) { |
| 614 shell::mojom::ShellClientRequest request = |
| 615 mojo::GetProxy(&test_shell_client_); |
| 616 MojoShellConnection::SetForProcess(MojoShellConnection::Create( |
| 617 std::move(request))); |
| 618 } |
| 619 connector = MojoShellConnection::GetForProcess()->GetConnector(); |
| 620 } |
| 621 mojo_child_connection_.reset(new MojoChildConnection( |
| 622 kRendererMojoApplicationName, |
| 623 base::StringPrintf("%d_%d", id_, instance_id_++), |
| 624 child_token_, |
| 625 connector)); |
| 605 } | 626 } |
| 606 | 627 |
| 607 // static | 628 // static |
| 608 void RenderProcessHostImpl::ShutDownInProcessRenderer() { | 629 void RenderProcessHostImpl::ShutDownInProcessRenderer() { |
| 609 DCHECK(g_run_renderer_in_process_); | 630 DCHECK(g_run_renderer_in_process_); |
| 610 | 631 |
| 611 switch (g_all_hosts.Pointer()->size()) { | 632 switch (g_all_hosts.Pointer()->size()) { |
| 612 case 0: | 633 case 0: |
| 613 return; | 634 return; |
| 614 case 1: { | 635 case 1: { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 void RenderProcessHostImpl::EnableSendQueue() { | 694 void RenderProcessHostImpl::EnableSendQueue() { |
| 674 is_initialized_ = false; | 695 is_initialized_ = false; |
| 675 } | 696 } |
| 676 | 697 |
| 677 bool RenderProcessHostImpl::Init() { | 698 bool RenderProcessHostImpl::Init() { |
| 678 // calling Init() more than once does nothing, this makes it more convenient | 699 // calling Init() more than once does nothing, this makes it more convenient |
| 679 // for the view host which may not be sure in some cases | 700 // for the view host which may not be sure in some cases |
| 680 if (channel_) | 701 if (channel_) |
| 681 return true; | 702 return true; |
| 682 | 703 |
| 683 shell::Connector* connector = | |
| 684 BrowserContext::GetShellConnectorFor(browser_context_); | |
| 685 // Some embedders may not initialize Mojo or the shell connector for a browser | |
| 686 // context (e.g. Android WebView)... so just fall back to the per-process | |
| 687 // connector. | |
| 688 if (!connector) | |
| 689 connector = MojoShellConnection::GetForProcess()->GetConnector(); | |
| 690 mojo_child_connection_.reset(new MojoChildConnection( | |
| 691 kRendererMojoApplicationName, | |
| 692 base::StringPrintf("%d_%d", id_, instance_id_++), | |
| 693 child_token_, | |
| 694 connector)); | |
| 695 | |
| 696 base::CommandLine::StringType renderer_prefix; | 704 base::CommandLine::StringType renderer_prefix; |
| 697 // A command prefix is something prepended to the command line of the spawned | 705 // A command prefix is something prepended to the command line of the spawned |
| 698 // process. | 706 // process. |
| 699 const base::CommandLine& browser_command_line = | 707 const base::CommandLine& browser_command_line = |
| 700 *base::CommandLine::ForCurrentProcess(); | 708 *base::CommandLine::ForCurrentProcess(); |
| 701 renderer_prefix = | 709 renderer_prefix = |
| 702 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 710 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 703 | 711 |
| 704 #if defined(OS_LINUX) | 712 #if defined(OS_LINUX) |
| 705 int flags = renderer_prefix.empty() ? ChildProcessHost::CHILD_ALLOW_SELF | 713 int flags = renderer_prefix.empty() ? ChildProcessHost::CHILD_ALLOW_SELF |
| (...skipping 28 matching lines...) Expand all Loading... |
| 734 // messages flow between the browser and renderer, this thread is required | 742 // messages flow between the browser and renderer, this thread is required |
| 735 // to prevent a deadlock in single-process mode. Since the primordial | 743 // to prevent a deadlock in single-process mode. Since the primordial |
| 736 // thread in the renderer process runs the WebKit code and can sometimes | 744 // thread in the renderer process runs the WebKit code and can sometimes |
| 737 // make blocking calls to the UI thread (i.e. this thread), they need to run | 745 // make blocking calls to the UI thread (i.e. this thread), they need to run |
| 738 // on separate threads. | 746 // on separate threads. |
| 739 in_process_renderer_.reset( | 747 in_process_renderer_.reset( |
| 740 g_renderer_main_thread_factory(InProcessChildThreadParams( | 748 g_renderer_main_thread_factory(InProcessChildThreadParams( |
| 741 channel_id, | 749 channel_id, |
| 742 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 750 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
| 743 ->task_runner(), | 751 ->task_runner(), |
| 744 mojo_channel_token_, mojo_application_host_->GetToken()))); | 752 mojo_channel_token_, |
| 753 mojo_child_connection_->shell_client_token()))); |
| 745 | 754 |
| 746 base::Thread::Options options; | 755 base::Thread::Options options; |
| 747 #if defined(OS_WIN) && !defined(OS_MACOSX) | 756 #if defined(OS_WIN) && !defined(OS_MACOSX) |
| 748 // In-process plugins require this to be a UI message loop. | 757 // In-process plugins require this to be a UI message loop. |
| 749 options.message_loop_type = base::MessageLoop::TYPE_UI; | 758 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 750 #else | 759 #else |
| 751 // We can't have multiple UI loops on Linux and Android, so we don't support | 760 // We can't have multiple UI loops on Linux and Android, so we don't support |
| 752 // in-process plugins. | 761 // in-process plugins. |
| 753 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 762 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 754 #endif | 763 #endif |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 AddFilter(new MemoryMessageFilter(this)); | 1027 AddFilter(new MemoryMessageFilter(this)); |
| 1019 AddFilter(new PushMessagingMessageFilter( | 1028 AddFilter(new PushMessagingMessageFilter( |
| 1020 GetID(), storage_partition_impl_->GetServiceWorkerContext())); | 1029 GetID(), storage_partition_impl_->GetServiceWorkerContext())); |
| 1021 #if defined(OS_ANDROID) | 1030 #if defined(OS_ANDROID) |
| 1022 AddFilter(new ScreenOrientationMessageFilterAndroid()); | 1031 AddFilter(new ScreenOrientationMessageFilterAndroid()); |
| 1023 #endif | 1032 #endif |
| 1024 } | 1033 } |
| 1025 | 1034 |
| 1026 void RenderProcessHostImpl::RegisterMojoInterfaces() { | 1035 void RenderProcessHostImpl::RegisterMojoInterfaces() { |
| 1027 #if !defined(OS_ANDROID) | 1036 #if !defined(OS_ANDROID) |
| 1028 mojo_application_host_->service_registry()->AddService( | 1037 GetInterfaceRegistry()->AddInterface( |
| 1029 base::Bind(&device::BatteryMonitorImpl::Create)); | 1038 base::Bind(&device::BatteryMonitorImpl::Create)); |
| 1030 #endif | 1039 #endif |
| 1031 | 1040 |
| 1032 mojo_application_host_->service_registry()->AddService( | 1041 GetInterfaceRegistry()->AddInterface( |
| 1033 base::Bind(&PermissionServiceContext::CreateService, | 1042 base::Bind(&PermissionServiceContext::CreateService, |
| 1034 base::Unretained(permission_service_context_.get()))); | 1043 base::Unretained(permission_service_context_.get()))); |
| 1035 | 1044 |
| 1036 // TODO(mcasas): finalize arguments. | 1045 // TODO(mcasas): finalize arguments. |
| 1037 mojo_application_host_->service_registry()->AddService( | 1046 GetInterfaceRegistry()->AddInterface(base::Bind(&ImageCaptureImpl::Create)); |
| 1038 base::Bind(&ImageCaptureImpl::Create)); | |
| 1039 | 1047 |
| 1040 mojo_application_host_->service_registry()->AddService( | 1048 GetInterfaceRegistry()->AddInterface( |
| 1041 base::Bind(&OffscreenCanvasSurfaceImpl::Create)); | 1049 base::Bind(&OffscreenCanvasSurfaceImpl::Create)); |
| 1042 | 1050 |
| 1043 mojo_application_host_->service_registry()->AddService(base::Bind( | 1051 GetInterfaceRegistry()->AddInterface(base::Bind( |
| 1044 &BackgroundSyncContext::CreateService, | 1052 &BackgroundSyncContext::CreateService, |
| 1045 base::Unretained(storage_partition_impl_->GetBackgroundSyncContext()))); | 1053 base::Unretained(storage_partition_impl_->GetBackgroundSyncContext()))); |
| 1046 | 1054 |
| 1047 mojo_application_host_->service_registry()->AddService(base::Bind( | 1055 GetInterfaceRegistry()->AddInterface(base::Bind( |
| 1048 &PlatformNotificationContextImpl::CreateService, | 1056 &PlatformNotificationContextImpl::CreateService, |
| 1049 base::Unretained( | 1057 base::Unretained( |
| 1050 storage_partition_impl_->GetPlatformNotificationContext()), GetID())); | 1058 storage_partition_impl_->GetPlatformNotificationContext()), GetID())); |
| 1051 | 1059 |
| 1052 mojo_application_host_->service_registry()->AddService( | 1060 GetInterfaceRegistry()->AddInterface( |
| 1053 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, | 1061 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, |
| 1054 base::Unretained(this))); | 1062 base::Unretained(this))); |
| 1055 | 1063 |
| 1056 mojo_application_host_->service_registry()->AddService( | 1064 GetInterfaceRegistry()->AddInterface( |
| 1057 base::Bind(&MimeRegistryImpl::Create), | 1065 base::Bind(&MimeRegistryImpl::Create), |
| 1058 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 1066 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 1059 | 1067 |
| 1060 #if defined(OS_ANDROID) | 1068 #if defined(OS_ANDROID) |
| 1061 ServiceRegistrarAndroid::RegisterProcessHostServices( | 1069 ServiceRegistrarAndroid::RegisterProcessHostServices( |
| 1062 mojo_application_host_->service_registry_android()); | 1070 mojo_child_connection_->service_registry_android()); |
| 1063 #endif | 1071 #endif |
| 1064 | 1072 |
| 1065 GetContentClient()->browser()->RegisterRenderProcessMojoServices( | 1073 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
| 1066 mojo_application_host_->service_registry(), this); | 1074 GetInterfaceRegistry(), this); |
| 1067 } | 1075 } |
| 1068 | 1076 |
| 1069 void RenderProcessHostImpl::CreateStoragePartitionService( | 1077 void RenderProcessHostImpl::CreateStoragePartitionService( |
| 1070 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { | 1078 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { |
| 1071 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! | 1079 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! |
| 1072 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1080 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1073 switches::kMojoLocalStorage)) { | 1081 switches::kMojoLocalStorage)) { |
| 1074 storage_partition_impl_->Bind(std::move(request)); | 1082 storage_partition_impl_->Bind(std::move(request)); |
| 1075 } | 1083 } |
| 1076 } | 1084 } |
| 1077 | 1085 |
| 1078 int RenderProcessHostImpl::GetNextRoutingID() { | 1086 int RenderProcessHostImpl::GetNextRoutingID() { |
| 1079 return widget_helper_->GetNextRoutingID(); | 1087 return widget_helper_->GetNextRoutingID(); |
| 1080 } | 1088 } |
| 1081 | 1089 |
| 1082 void RenderProcessHostImpl::ResumeDeferredNavigation( | 1090 void RenderProcessHostImpl::ResumeDeferredNavigation( |
| 1083 const GlobalRequestID& request_id) { | 1091 const GlobalRequestID& request_id) { |
| 1084 widget_helper_->ResumeDeferredNavigation(request_id); | 1092 widget_helper_->ResumeDeferredNavigation(request_id); |
| 1085 } | 1093 } |
| 1086 | 1094 |
| 1087 void RenderProcessHostImpl::NotifyTimezoneChange(const std::string& zone_id) { | 1095 void RenderProcessHostImpl::NotifyTimezoneChange(const std::string& zone_id) { |
| 1088 Send(new ViewMsg_TimezoneChange(zone_id)); | 1096 Send(new ViewMsg_TimezoneChange(zone_id)); |
| 1089 } | 1097 } |
| 1090 | 1098 |
| 1091 ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { | 1099 shell::InterfaceRegistry* RenderProcessHostImpl::GetInterfaceRegistry() { |
| 1092 DCHECK(mojo_application_host_); | 1100 return GetChildConnection()->GetInterfaceRegistry(); |
| 1093 return mojo_application_host_->service_registry(); | 1101 } |
| 1102 |
| 1103 shell::InterfaceProvider* RenderProcessHostImpl::GetRemoteInterfaces() { |
| 1104 return GetChildConnection()->GetRemoteInterfaces(); |
| 1094 } | 1105 } |
| 1095 | 1106 |
| 1096 shell::Connection* RenderProcessHostImpl::GetChildConnection() { | 1107 shell::Connection* RenderProcessHostImpl::GetChildConnection() { |
| 1097 DCHECK(mojo_child_connection_); | 1108 DCHECK(mojo_child_connection_); |
| 1098 return mojo_child_connection_->connection(); | 1109 return mojo_child_connection_->connection(); |
| 1099 } | 1110 } |
| 1100 | 1111 |
| 1101 std::unique_ptr<base::SharedPersistentMemoryAllocator> | 1112 std::unique_ptr<base::SharedPersistentMemoryAllocator> |
| 1102 RenderProcessHostImpl::TakeMetricsAllocator() { | 1113 RenderProcessHostImpl::TakeMetricsAllocator() { |
| 1103 return std::move(metrics_allocator_); | 1114 return std::move(metrics_allocator_); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 base::DoubleToString(display::win::GetDPIScale())); | 1335 base::DoubleToString(display::win::GetDPIScale())); |
| 1325 #endif | 1336 #endif |
| 1326 | 1337 |
| 1327 AppendCompositorCommandLineFlags(command_line); | 1338 AppendCompositorCommandLineFlags(command_line); |
| 1328 | 1339 |
| 1329 if (!mojo_channel_token_.empty()) { | 1340 if (!mojo_channel_token_.empty()) { |
| 1330 command_line->AppendSwitchASCII(switches::kMojoChannelToken, | 1341 command_line->AppendSwitchASCII(switches::kMojoChannelToken, |
| 1331 mojo_channel_token_); | 1342 mojo_channel_token_); |
| 1332 } | 1343 } |
| 1333 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1344 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
| 1334 mojo_application_host_->GetToken()); | 1345 mojo_child_connection_->shell_client_token()); |
| 1335 } | 1346 } |
| 1336 | 1347 |
| 1337 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1348 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
| 1338 const base::CommandLine& browser_cmd, | 1349 const base::CommandLine& browser_cmd, |
| 1339 base::CommandLine* renderer_cmd) const { | 1350 base::CommandLine* renderer_cmd) const { |
| 1340 // Propagate the following switches to the renderer command line (along | 1351 // Propagate the following switches to the renderer command line (along |
| 1341 // with any associated values) if present in the browser command line. | 1352 // with any associated values) if present in the browser command line. |
| 1342 static const char* const kSwitchNames[] = { | 1353 static const char* const kSwitchNames[] = { |
| 1343 switches::kAgcStartupMinVolume, | 1354 switches::kAgcStartupMinVolume, |
| 1344 switches::kAecRefinedAdaptiveFilter, | 1355 switches::kAecRefinedAdaptiveFilter, |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 // rest of the objects attached to this RenderProcessHost start going | 1917 // rest of the objects attached to this RenderProcessHost start going |
| 1907 // away first, since deleting the channel proxy will post a | 1918 // away first, since deleting the channel proxy will post a |
| 1908 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. | 1919 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
| 1909 channel_.reset(); | 1920 channel_.reset(); |
| 1910 | 1921 |
| 1911 // The following members should be cleared in ProcessDied() as well! | 1922 // The following members should be cleared in ProcessDied() as well! |
| 1912 message_port_message_filter_ = NULL; | 1923 message_port_message_filter_ = NULL; |
| 1913 | 1924 |
| 1914 RemoveUserData(kSessionStorageHolderKey); | 1925 RemoveUserData(kSessionStorageHolderKey); |
| 1915 | 1926 |
| 1916 // On shutdown, |this| may not be deleted because the deleter is posted to | |
| 1917 // the current MessageLoop, but MessageLoop deletes all its pending | |
| 1918 // callbacks on shutdown. Since the deleter takes |this| as a raw pointer, | |
| 1919 // deleting the callback doesn't delete |this| resulting in a memory leak. | |
| 1920 // Valgrind complains, so delete |mojo_application_host_| explicitly here to | |
| 1921 // stop valgrind from complaining. | |
| 1922 mojo_application_host_.reset(); | |
| 1923 | |
| 1924 // Remove ourself from the list of renderer processes so that we can't be | 1927 // Remove ourself from the list of renderer processes so that we can't be |
| 1925 // reused in between now and when the Delete task runs. | 1928 // reused in between now and when the Delete task runs. |
| 1926 UnregisterHost(GetID()); | 1929 UnregisterHost(GetID()); |
| 1927 } | 1930 } |
| 1928 } | 1931 } |
| 1929 | 1932 |
| 1930 void RenderProcessHostImpl::AddPendingView() { | 1933 void RenderProcessHostImpl::AddPendingView() { |
| 1931 pending_views_++; | 1934 pending_views_++; |
| 1932 } | 1935 } |
| 1933 | 1936 |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 delete queued_messages_.front(); | 2413 delete queued_messages_.front(); |
| 2411 queued_messages_.pop(); | 2414 queued_messages_.pop(); |
| 2412 } | 2415 } |
| 2413 UpdateProcessPriority(); | 2416 UpdateProcessPriority(); |
| 2414 DCHECK(!is_process_backgrounded_); | 2417 DCHECK(!is_process_backgrounded_); |
| 2415 | 2418 |
| 2416 // RenderProcessExited observers and RenderProcessGone handlers might | 2419 // RenderProcessExited observers and RenderProcessGone handlers might |
| 2417 // navigate or perform other actions that require a connection. Ensure that | 2420 // navigate or perform other actions that require a connection. Ensure that |
| 2418 // there is one before calling them. | 2421 // there is one before calling them. |
| 2419 child_token_ = mojo::edk::GenerateRandomToken(); | 2422 child_token_ = mojo::edk::GenerateRandomToken(); |
| 2420 mojo_application_host_.reset(new MojoApplicationHost(child_token_)); | 2423 shell::Connector* connector = |
| 2424 BrowserContext::GetShellConnectorFor(browser_context_); |
| 2425 if (!connector) |
| 2426 connector = MojoShellConnection::GetForProcess()->GetConnector(); |
| 2427 mojo_child_connection_.reset(new MojoChildConnection( |
| 2428 kRendererMojoApplicationName, |
| 2429 base::StringPrintf("%d_%d", id_, instance_id_++), |
| 2430 child_token_, |
| 2431 connector)); |
| 2421 | 2432 |
| 2422 within_process_died_observer_ = true; | 2433 within_process_died_observer_ = true; |
| 2423 NotificationService::current()->Notify( | 2434 NotificationService::current()->Notify( |
| 2424 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2435 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
| 2425 Details<RendererClosedDetails>(&details)); | 2436 Details<RendererClosedDetails>(&details)); |
| 2426 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2437 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
| 2427 RenderProcessExited(this, status, exit_code)); | 2438 RenderProcessExited(this, status, exit_code)); |
| 2428 within_process_died_observer_ = false; | 2439 within_process_died_observer_ = false; |
| 2429 | 2440 |
| 2430 message_port_message_filter_ = NULL; | 2441 message_port_message_filter_ = NULL; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2825 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2815 | 2826 |
| 2816 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2827 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 2817 // enough information here so that we can determine what the bad message was. | 2828 // enough information here so that we can determine what the bad message was. |
| 2818 base::debug::Alias(&error); | 2829 base::debug::Alias(&error); |
| 2819 bad_message::ReceivedBadMessage(process.get(), | 2830 bad_message::ReceivedBadMessage(process.get(), |
| 2820 bad_message::RPH_MOJO_PROCESS_ERROR); | 2831 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 2821 } | 2832 } |
| 2822 | 2833 |
| 2823 } // namespace content | 2834 } // namespace content |
| OLD | NEW |