Index: content/common/child_process_host_impl.cc |
diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc |
index d69d5352a285f8a16065536a3f3708fc23f494e9..9654d1bcda54d1943a9e4f2feda32c7b165e4423 100644 |
--- a/content/common/child_process_host_impl.cc |
+++ b/content/common/child_process_host_impl.cc |
@@ -86,19 +86,6 @@ ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate) |
#if defined(OS_WIN) |
AddFilter(new FontCacheDispatcher()); |
#endif |
- |
-#if USE_ATTACHMENT_BROKER |
-#if defined(OS_MACOSX) && !defined(OS_IOS) |
- // On Mac, the privileged AttachmentBroker needs a reference to the Mach port |
- // Provider, which is only available in the chrome/ module. The attachment |
- // broker must already be created. |
- DCHECK(IPC::AttachmentBroker::GetGlobal()); |
-#else |
- // Construct the privileged attachment broker early in the life cycle of a |
- // child process. |
- IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded(); |
-#endif // defined(OS_MACOSX) && !defined(OS_IOS) |
-#endif // USE_ATTACHMENT_BROKER |
} |
ChildProcessHostImpl::~ChildProcessHostImpl() { |
@@ -109,8 +96,11 @@ ChildProcessHostImpl::~ChildProcessHostImpl() { |
return; |
#if USE_ATTACHMENT_BROKER |
- IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
- channel_.get()); |
+ // In unit tests, the attachment broker may not have been initialized. |
+ if (IPC::AttachmentBroker::GetGlobal()) { |
+ IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
+ channel_.get()); |
+ } |
#endif |
for (size_t i = 0; i < filters_.size(); ++i) { |
filters_[i]->OnChannelClosing(); |
@@ -135,8 +125,11 @@ std::string ChildProcessHostImpl::CreateChannel() { |
if (!channel_->Connect()) |
return std::string(); |
#if USE_ATTACHMENT_BROKER |
- IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( |
- channel_.get()); |
+ // In unit tests, the attachment broker may not have been initialized. |
+ if (IPC::AttachmentBroker::GetGlobal()) { |
+ IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( |
+ channel_.get()); |
+ } |
#endif |
for (size_t i = 0; i < filters_.size(); ++i) |