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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2255493004: Synchronously disable ConnectionFilterImpl when its RPHI cleans up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-connection-filter-race
Patch Set: . 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 unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #include <limits> 11 #include <limits>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/base_switches.h" 15 #include "base/base_switches.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/bind_helpers.h" 17 #include "base/bind_helpers.h"
18 #include "base/callback.h" 18 #include "base/callback.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/debug/dump_without_crashing.h" 20 #include "base/debug/dump_without_crashing.h"
21 #include "base/feature_list.h" 21 #include "base/feature_list.h"
22 #include "base/files/file.h" 22 #include "base/files/file.h"
23 #include "base/lazy_instance.h" 23 #include "base/lazy_instance.h"
24 #include "base/location.h" 24 #include "base/location.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/macros.h" 26 #include "base/macros.h"
27 #include "base/memory/ref_counted.h"
27 #include "base/memory/shared_memory.h" 28 #include "base/memory/shared_memory.h"
28 #include "base/memory/shared_memory_handle.h" 29 #include "base/memory/shared_memory_handle.h"
29 #include "base/metrics/histogram.h" 30 #include "base/metrics/histogram.h"
30 #include "base/metrics/persistent_histogram_allocator.h" 31 #include "base/metrics/persistent_histogram_allocator.h"
31 #include "base/metrics/persistent_memory_allocator.h" 32 #include "base/metrics/persistent_memory_allocator.h"
32 #include "base/process/process_handle.h" 33 #include "base/process/process_handle.h"
33 #include "base/rand_util.h" 34 #include "base/rand_util.h"
34 #include "base/single_thread_task_runner.h" 35 #include "base/single_thread_task_runner.h"
35 #include "base/stl_util.h" 36 #include "base/stl_util.h"
36 #include "base/strings/string_number_conversions.h" 37 #include "base/strings/string_number_conversions.h"
37 #include "base/strings/stringprintf.h" 38 #include "base/strings/stringprintf.h"
38 #include "base/supports_user_data.h" 39 #include "base/supports_user_data.h"
40 #include "base/synchronization/lock.h"
39 #include "base/sys_info.h" 41 #include "base/sys_info.h"
40 #include "base/threading/thread.h" 42 #include "base/threading/thread.h"
41 #include "base/threading/thread_restrictions.h" 43 #include "base/threading/thread_restrictions.h"
42 #include "base/threading/thread_task_runner_handle.h" 44 #include "base/threading/thread_task_runner_handle.h"
43 #include "base/trace_event/trace_event.h" 45 #include "base/trace_event/trace_event.h"
44 #include "base/tracked_objects.h" 46 #include "base/tracked_objects.h"
45 #include "build/build_config.h" 47 #include "build/build_config.h"
46 #include "cc/base/switches.h" 48 #include "cc/base/switches.h"
47 #include "cc/output/buffer_to_texture_target_map.h" 49 #include "cc/output/buffer_to_texture_target_map.h"
48 #include "components/memory_coordinator/browser/memory_coordinator.h" 50 #include "components/memory_coordinator/browser/memory_coordinator.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 458
457 base::MessageLoop* g_in_process_thread; 459 base::MessageLoop* g_in_process_thread;
458 460
459 // Stores the maximum number of renderer processes the content module can 461 // Stores the maximum number of renderer processes the content module can
460 // create. 462 // create.
461 static size_t g_max_renderer_count_override = 0; 463 static size_t g_max_renderer_count_override = 0;
462 464
463 // static 465 // static
464 bool g_run_renderer_in_process_ = false; 466 bool g_run_renderer_in_process_ = false;
465 467
468 // Held by the RPH and used to control an (unowned) ConnectionFilterImpl from
469 // any thread.
470 class RenderProcessHostImpl::ConnectionFilterController
471 : public base::RefCountedThreadSafe<ConnectionFilterController> {
472 public:
473 // |filter| is not owned by this object.
474 explicit ConnectionFilterController(ConnectionFilterImpl* filter)
475 : filter_(filter) {}
476
477 void DisableFilter();
478
479 private:
480 friend class base::RefCountedThreadSafe<ConnectionFilterController>;
481 friend class ConnectionFilterImpl;
482
483 ~ConnectionFilterController() {}
484
485 void Detach() {
486 base::AutoLock lock(lock_);
487 filter_ = nullptr;
488 }
489
490 base::Lock lock_;
491 ConnectionFilterImpl* filter_;
492 };
493
466 // Held by the RPH's BrowserContext's MojoShellConnection, ownership transferred 494 // Held by the RPH's BrowserContext's MojoShellConnection, ownership transferred
467 // back to RPH upon RPH destruction. 495 // back to RPH upon RPH destruction.
468 class RenderProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter { 496 class RenderProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter {
469 public: 497 public:
470 ConnectionFilterImpl( 498 ConnectionFilterImpl(
471 const shell::Identity& child_identity, 499 const shell::Identity& child_identity,
472 std::unique_ptr<shell::InterfaceRegistry> registry) 500 std::unique_ptr<shell::InterfaceRegistry> registry)
473 : child_identity_(child_identity), 501 : child_identity_(child_identity),
474 registry_(std::move(registry)), 502 registry_(std::move(registry)),
503 controller_(new ConnectionFilterController(this)),
475 weak_factory_(this) { 504 weak_factory_(this) {
476 // Registration of this filter may race with browser shutdown, in which case 505 // Registration of this filter may race with browser shutdown, in which case
477 // it's possible for this filter to be destroyed on the main thread. This 506 // it's possible for this filter to be destroyed on the main thread. This
478 // is fine as long as the filter hasn't been used on the IO thread yet. We 507 // is fine as long as the filter hasn't been used on the IO thread yet. We
479 // detach the ThreadChecker initially and the first use of the filter will 508 // detach the ThreadChecker initially and the first use of the filter will
480 // bind it. 509 // bind it.
481 thread_checker_.DetachFromThread(); 510 thread_checker_.DetachFromThread();
482 } 511 }
483 512
484 ~ConnectionFilterImpl() override { 513 ~ConnectionFilterImpl() override {
485 DCHECK(thread_checker_.CalledOnValidThread()); 514 DCHECK(thread_checker_.CalledOnValidThread());
515 controller_->Detach();
516 }
517
518 scoped_refptr<ConnectionFilterController> controller() { return controller_; }
519
520 void Disable() {
521 base::AutoLock lock(enabled_lock_);
522 enabled_ = false;
486 } 523 }
487 524
488 private: 525 private:
489 // ConnectionFilter: 526 // ConnectionFilter:
490 bool OnConnect(const shell::Identity& remote_identity, 527 bool OnConnect(const shell::Identity& remote_identity,
491 shell::InterfaceRegistry* registry, 528 shell::InterfaceRegistry* registry,
492 shell::Connector* connector) override { 529 shell::Connector* connector) override {
493 DCHECK(thread_checker_.CalledOnValidThread()); 530 DCHECK(thread_checker_.CalledOnValidThread());
494 DCHECK_CURRENTLY_ON(BrowserThread::IO); 531 DCHECK_CURRENTLY_ON(BrowserThread::IO);
495 // We only fulfill connections from the renderer we host. 532 // We only fulfill connections from the renderer we host.
496 if (child_identity_.name() != remote_identity.name() || 533 if (child_identity_.name() != remote_identity.name() ||
497 child_identity_.instance() != remote_identity.instance()) { 534 child_identity_.instance() != remote_identity.instance()) {
498 return false; 535 return false;
499 } 536 }
500 537
538 base::AutoLock lock(enabled_lock_);
539 if (!enabled_)
540 return false;
541
501 std::set<std::string> interface_names; 542 std::set<std::string> interface_names;
502 registry_->GetInterfaceNames(&interface_names); 543 registry_->GetInterfaceNames(&interface_names);
503 for (auto& interface_name : interface_names) { 544 for (auto& interface_name : interface_names) {
504 // Note that the added callbacks may outlive this object, which is 545 // Note that the added callbacks may outlive this object, which is
505 // destroyed in RPH::Cleanup(). 546 // destroyed in RPH::Cleanup().
506 registry->AddInterface(interface_name, 547 registry->AddInterface(interface_name,
507 base::Bind(&ConnectionFilterImpl::GetInterface, 548 base::Bind(&ConnectionFilterImpl::GetInterface,
508 weak_factory_.GetWeakPtr(), 549 weak_factory_.GetWeakPtr(),
509 interface_name)); 550 interface_name));
510 } 551 }
511 return true; 552 return true;
512 } 553 }
513 554
514 void GetInterface(const std::string& interface_name, 555 void GetInterface(const std::string& interface_name,
515 mojo::ScopedMessagePipeHandle handle) { 556 mojo::ScopedMessagePipeHandle handle) {
516 DCHECK(thread_checker_.CalledOnValidThread()); 557 DCHECK(thread_checker_.CalledOnValidThread());
517 DCHECK_CURRENTLY_ON(BrowserThread::IO); 558 DCHECK_CURRENTLY_ON(BrowserThread::IO);
518 shell::mojom::InterfaceProvider* provider = registry_.get(); 559 shell::mojom::InterfaceProvider* provider = registry_.get();
519 provider->GetInterface(interface_name, std::move(handle)); 560
561 base::AutoLock lock(enabled_lock_);
562 if (enabled_)
563 provider->GetInterface(interface_name, std::move(handle));
520 } 564 }
521 565
522 base::ThreadChecker thread_checker_; 566 base::ThreadChecker thread_checker_;
523 shell::Identity child_identity_; 567 shell::Identity child_identity_;
524 std::unique_ptr<shell::InterfaceRegistry> registry_; 568 std::unique_ptr<shell::InterfaceRegistry> registry_;
569 scoped_refptr<ConnectionFilterController> controller_;
570
571 // Guards |enabled_|.
572 base::Lock enabled_lock_;
573 bool enabled_ = true;
574
525 base::WeakPtrFactory<ConnectionFilterImpl> weak_factory_; 575 base::WeakPtrFactory<ConnectionFilterImpl> weak_factory_;
526 576
527 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); 577 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl);
528 }; 578 };
529 579
580 void RenderProcessHostImpl::ConnectionFilterController::DisableFilter() {
581 base::AutoLock lock(lock_);
582 if (filter_)
583 filter_->Disable();
584 }
585
530 base::MessageLoop* 586 base::MessageLoop*
531 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { 587 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
532 return g_in_process_thread; 588 return g_in_process_thread;
533 } 589 }
534 590
535 // static 591 // static
536 size_t RenderProcessHost::GetMaxRendererProcessCount() { 592 size_t RenderProcessHost::GetMaxRendererProcessCount() {
537 if (g_max_renderer_count_override) 593 if (g_max_renderer_count_override)
538 return g_max_renderer_count_override; 594 return g_max_renderer_count_override;
539 595
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 #endif 680 #endif
625 worker_ref_count_(0), 681 worker_ref_count_(0),
626 max_worker_count_(0), 682 max_worker_count_(0),
627 permission_service_context_(new PermissionServiceContext(this)), 683 permission_service_context_(new PermissionServiceContext(this)),
628 channel_connected_(false), 684 channel_connected_(false),
629 sent_render_process_ready_(false), 685 sent_render_process_ready_(false),
630 #if defined(OS_ANDROID) 686 #if defined(OS_ANDROID)
631 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL, 687 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL,
632 base::WaitableEvent::InitialState::NOT_SIGNALED), 688 base::WaitableEvent::InitialState::NOT_SIGNALED),
633 #endif 689 #endif
690 instance_weak_factory_(
691 new base::WeakPtrFactory<RenderProcessHostImpl>(this)),
634 weak_factory_(this) { 692 weak_factory_(this) {
635 widget_helper_ = new RenderWidgetHelper(); 693 widget_helper_ = new RenderWidgetHelper();
636 694
637 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); 695 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID());
638 696
639 CHECK(!BrowserMainRunner::ExitedMainMessageLoop()); 697 CHECK(!BrowserMainRunner::ExitedMainMessageLoop());
640 RegisterHost(GetID(), this); 698 RegisterHost(GetID(), this);
641 g_all_hosts.Get().set_check_on_null_data(true); 699 g_all_hosts.Get().set_check_on_null_data(true);
642 // Initialize |child_process_activity_time_| to a reasonable value. 700 // Initialize |child_process_activity_time_| to a reasonable value.
643 mark_child_process_activity_time(); 701 mark_child_process_activity_time();
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 void RenderProcessHostImpl::RegisterMojoInterfaces() { 1167 void RenderProcessHostImpl::RegisterMojoInterfaces() {
1110 std::unique_ptr<shell::InterfaceRegistry> registry( 1168 std::unique_ptr<shell::InterfaceRegistry> registry(
1111 new shell::InterfaceRegistry); 1169 new shell::InterfaceRegistry);
1112 #if defined(OS_ANDROID) 1170 #if defined(OS_ANDROID)
1113 interface_registry_android_ = 1171 interface_registry_android_ =
1114 InterfaceRegistryAndroid::Create(registry.get()); 1172 InterfaceRegistryAndroid::Create(registry.get());
1115 InterfaceRegistrarAndroid::ExposeInterfacesToRenderer( 1173 InterfaceRegistrarAndroid::ExposeInterfacesToRenderer(
1116 interface_registry_android_.get()); 1174 interface_registry_android_.get());
1117 #endif 1175 #endif
1118 1176
1119 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner =
1120 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
1121 #if !defined(OS_ANDROID) 1177 #if !defined(OS_ANDROID)
1122 registry->AddInterface(base::Bind(&device::BatteryMonitorImpl::Create), 1178 AddUIThreadInterface(
1123 ui_task_runner); 1179 registry.get(), base::Bind(&device::BatteryMonitorImpl::Create));
1124 #endif 1180 #endif
1125 registry->AddInterface( 1181 AddUIThreadInterface(
1182 registry.get(),
1126 base::Bind(&PermissionServiceContext::CreateService, 1183 base::Bind(&PermissionServiceContext::CreateService,
1127 base::Unretained(permission_service_context_.get())), 1184 base::Unretained(permission_service_context_.get())));
1128 ui_task_runner);
1129 // TODO(mcasas): finalize arguments. 1185 // TODO(mcasas): finalize arguments.
1130 registry->AddInterface(base::Bind(&ImageCaptureImpl::Create), 1186 AddUIThreadInterface(registry.get(), base::Bind(&ImageCaptureImpl::Create));
1131 ui_task_runner); 1187 AddUIThreadInterface(registry.get(),
1132 registry->AddInterface(base::Bind(&OffscreenCanvasSurfaceImpl::Create), 1188 base::Bind(&OffscreenCanvasSurfaceImpl::Create));
1133 ui_task_runner); 1189 AddUIThreadInterface(
1134 registry->AddInterface( 1190 registry.get(),
1135 base::Bind(&BackgroundSyncContext::CreateService, 1191 base::Bind(&BackgroundSyncContext::CreateService,
1136 base::Unretained( 1192 base::Unretained(
1137 storage_partition_impl_->GetBackgroundSyncContext())), 1193 storage_partition_impl_->GetBackgroundSyncContext())));
1138 ui_task_runner); 1194 AddUIThreadInterface(
1139 registry->AddInterface( 1195 registry.get(),
1140 base::Bind(&PlatformNotificationContextImpl::CreateService, 1196 base::Bind(&PlatformNotificationContextImpl::CreateService,
1141 base::Unretained( 1197 base::Unretained(
1142 storage_partition_impl_->GetPlatformNotificationContext()), 1198 storage_partition_impl_->GetPlatformNotificationContext()),
1143 GetID()), 1199 GetID()));
1144 ui_task_runner); 1200 AddUIThreadInterface(
1145 registry->AddInterface( 1201 registry.get(),
1146 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, 1202 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService,
1147 base::Unretained(this)), 1203 base::Unretained(this)));
1148 ui_task_runner); 1204 AddUIThreadInterface(
1149 registry->AddInterface( 1205 registry.get(),
1150 base::Bind(&BroadcastChannelProvider::Connect, 1206 base::Bind(&BroadcastChannelProvider::Connect,
1151 base::Unretained( 1207 base::Unretained(
1152 storage_partition_impl_->GetBroadcastChannelProvider())), 1208 storage_partition_impl_->GetBroadcastChannelProvider())));
1153 ui_task_runner);
1154 if (memory_coordinator::IsEnabled()) { 1209 if (memory_coordinator::IsEnabled()) {
1155 registry->AddInterface(base::Bind(&CreateMemoryCoordinatorHandle, GetID()), 1210 AddUIThreadInterface(
1156 ui_task_runner); 1211 registry.get(), base::Bind(&CreateMemoryCoordinatorHandle, GetID()));
1157 } 1212 }
1158 1213
1159 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = 1214 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner =
1160 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE); 1215 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE);
1161 registry->AddInterface(base::Bind(&MimeRegistryImpl::Create), 1216 registry->AddInterface(base::Bind(&MimeRegistryImpl::Create),
1162 file_task_runner); 1217 file_task_runner);
1163 #if defined(USE_MINIKIN_HYPHENATION) 1218 #if defined(USE_MINIKIN_HYPHENATION)
1164 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create), 1219 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create),
1165 file_task_runner); 1220 file_task_runner);
1166 #endif 1221 #endif
1167 1222
1168 // These callbacks will be run immediately on the IO thread. 1223 // These callbacks will be run immediately on the IO thread.
1169 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); 1224 registry->AddInterface(base::Bind(&DeviceLightHost::Create));
1170 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); 1225 registry->AddInterface(base::Bind(&DeviceMotionHost::Create));
1171 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); 1226 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create));
1172 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); 1227 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create));
1173 registry->AddInterface( 1228 registry->AddInterface(
1174 base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_)); 1229 base::Bind(&URLLoaderFactoryImpl::Create, resource_message_filter_));
1175 1230
1176 // This is to support usage of WebSockets in cases in which there is no 1231 // This is to support usage of WebSockets in cases in which there is no
1177 // associated RenderFrame (e.g., Shared Workers). 1232 // associated RenderFrame (e.g., Shared Workers).
1178 registry->AddInterface( 1233 AddUIThreadInterface(
1179 base::Bind(&WebSocketManager::CreateWebSocket, GetID(), MSG_ROUTING_NONE), 1234 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(),
1180 ui_task_runner); 1235 MSG_ROUTING_NONE));
1181 1236
1182 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), 1237 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(),
1183 this); 1238 this);
1184 1239
1185 MojoShellConnection* mojo_shell_connection = 1240 MojoShellConnection* mojo_shell_connection =
1186 BrowserContext::GetMojoShellConnectionFor(browser_context_); 1241 BrowserContext::GetMojoShellConnectionFor(browser_context_);
1187 std::unique_ptr<ConnectionFilterImpl> connection_filter( 1242 std::unique_ptr<ConnectionFilterImpl> connection_filter(
1188 new ConnectionFilterImpl(mojo_child_connection_->child_identity(), 1243 new ConnectionFilterImpl(mojo_child_connection_->child_identity(),
1189 std::move(registry))); 1244 std::move(registry)));
1190 connection_filter_ = 1245 connection_filter_controller_ = connection_filter->controller();
1246 connection_filter_id_ =
1191 mojo_shell_connection->AddConnectionFilter(std::move(connection_filter)); 1247 mojo_shell_connection->AddConnectionFilter(std::move(connection_filter));
1192 } 1248 }
1193 1249
1194 void RenderProcessHostImpl::CreateStoragePartitionService( 1250 void RenderProcessHostImpl::CreateStoragePartitionService(
1195 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { 1251 mojo::InterfaceRequest<mojom::StoragePartitionService> request) {
1196 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! 1252 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW!
1197 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1253 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1198 switches::kMojoLocalStorage)) { 1254 switches::kMojoLocalStorage)) {
1199 storage_partition_impl_->Bind(std::move(request)); 1255 storage_partition_impl_->Bind(std::move(request));
1200 } 1256 }
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 RenderProcessHostObserver, observers_, 2036 RenderProcessHostObserver, observers_,
1981 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION, 2037 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION,
1982 0)); 2038 0));
1983 } 2039 }
1984 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, 2040 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_,
1985 RenderProcessHostDestroyed(this)); 2041 RenderProcessHostDestroyed(this));
1986 NotificationService::current()->Notify( 2042 NotificationService::current()->Notify(
1987 NOTIFICATION_RENDERER_PROCESS_TERMINATED, 2043 NOTIFICATION_RENDERER_PROCESS_TERMINATED,
1988 Source<RenderProcessHost>(this), NotificationService::NoDetails()); 2044 Source<RenderProcessHost>(this), NotificationService::NoDetails());
1989 2045
1990 if (connection_filter_ != MojoShellConnection::kInvalidConnectionFilterId) { 2046 if (connection_filter_id_ !=
2047 MojoShellConnection::kInvalidConnectionFilterId) {
1991 MojoShellConnection* mojo_shell_connection = 2048 MojoShellConnection* mojo_shell_connection =
1992 BrowserContext::GetMojoShellConnectionFor(browser_context_); 2049 BrowserContext::GetMojoShellConnectionFor(browser_context_);
1993 mojo_shell_connection->RemoveConnectionFilter(connection_filter_); 2050 connection_filter_controller_->DisableFilter();
1994 connection_filter_ = MojoShellConnection::kInvalidConnectionFilterId; 2051 mojo_shell_connection->RemoveConnectionFilter(connection_filter_id_);
2052 connection_filter_id_ = MojoShellConnection::kInvalidConnectionFilterId;
1995 } 2053 }
1996 2054
1997 #ifndef NDEBUG 2055 #ifndef NDEBUG
1998 is_self_deleted_ = true; 2056 is_self_deleted_ = true;
1999 #endif 2057 #endif
2000 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 2058 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
2001 deleting_soon_ = true; 2059 deleting_soon_ = true;
2002 2060
2003 #if USE_ATTACHMENT_BROKER 2061 #if USE_ATTACHMENT_BROKER
2004 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( 2062 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
2005 channel_.get()); 2063 channel_.get());
2006 #endif 2064 #endif
2007 2065
2008 // It's important not to wait for the DeleteTask to delete the channel 2066 // It's important not to wait for the DeleteTask to delete the channel
2009 // proxy. Kill it off now. That way, in case the profile is going away, the 2067 // proxy. Kill it off now. That way, in case the profile is going away, the
2010 // rest of the objects attached to this RenderProcessHost start going 2068 // rest of the objects attached to this RenderProcessHost start going
2011 // away first, since deleting the channel proxy will post a 2069 // away first, since deleting the channel proxy will post a
2012 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. 2070 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread.
2013 channel_.reset(); 2071 channel_.reset();
2014 2072
2015 // The following members should be cleared in ProcessDied() as well! 2073 // The following members should be cleared in ProcessDied() as well!
2016 message_port_message_filter_ = NULL; 2074 message_port_message_filter_ = NULL;
2017 2075
2018 RemoveUserData(kSessionStorageHolderKey); 2076 RemoveUserData(kSessionStorageHolderKey);
2019 2077
2020 // Remove ourself from the list of renderer processes so that we can't be 2078 // Remove ourself from the list of renderer processes so that we can't be
2021 // reused in between now and when the Delete task runs. 2079 // reused in between now and when the Delete task runs.
2022 UnregisterHost(GetID()); 2080 UnregisterHost(GetID());
2081
2082 instance_weak_factory_.reset(
2083 new base::WeakPtrFactory<RenderProcessHostImpl>(this));
2023 } 2084 }
2024 } 2085 }
2025 2086
2026 void RenderProcessHostImpl::AddPendingView() { 2087 void RenderProcessHostImpl::AddPendingView() {
2027 pending_views_++; 2088 pending_views_++;
2028 } 2089 }
2029 2090
2030 void RenderProcessHostImpl::RemovePendingView() { 2091 void RenderProcessHostImpl::RemovePendingView() {
2031 DCHECK(pending_views_); 2092 DCHECK(pending_views_);
2032 pending_views_--; 2093 pending_views_--;
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 2898 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
2838 2899
2839 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 2900 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
2840 // enough information here so that we can determine what the bad message was. 2901 // enough information here so that we can determine what the bad message was.
2841 base::debug::Alias(&error); 2902 base::debug::Alias(&error);
2842 bad_message::ReceivedBadMessage(process.get(), 2903 bad_message::ReceivedBadMessage(process.get(),
2843 bad_message::RPH_MOJO_PROCESS_ERROR); 2904 bad_message::RPH_MOJO_PROCESS_ERROR);
2844 } 2905 }
2845 2906
2846 } // namespace content 2907 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698