| 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 3fa4dc89cf090a7724956b500b49ac2a2a802bab..c54f834ff840f4e3edcba91a77bc62292cb4ae16 100644
|
| --- a/content/common/child_process_host_impl.cc
|
| +++ b/content/common/child_process_host_impl.cc
|
| @@ -8,7 +8,9 @@
|
|
|
| #include "base/atomic_sequence_num.h"
|
| #include "base/command_line.h"
|
| +#include "base/debug/leak_annotations.h"
|
| #include "base/files/file_path.h"
|
| +#include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/numerics/safe_math.h"
|
| @@ -16,12 +18,14 @@
|
| #include "base/process/process_metrics.h"
|
| #include "base/rand_util.h"
|
| #include "base/strings/stringprintf.h"
|
| +#include "base/synchronization/lock.h"
|
| #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
|
| #include "content/common/child_process_messages.h"
|
| #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
|
| #include "content/public/common/child_process_host_delegate.h"
|
| #include "content/public/common/content_paths.h"
|
| #include "content/public/common/content_switches.h"
|
| +#include "ipc/attachment_broker.h"
|
| #include "ipc/ipc_channel.h"
|
| #include "ipc/ipc_logging.h"
|
| #include "ipc/message_filter.h"
|
| @@ -30,10 +34,26 @@
|
| #include "base/linux_util.h"
|
| #elif defined(OS_WIN)
|
| #include "content/common/font_cache_dispatcher_win.h"
|
| +#include "ipc/attachment_broker_win.h"
|
| #endif // OS_LINUX
|
|
|
| +base::LazyInstance<base::Lock>::Leaky g_attachment_broker_lock =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +IPC::AttachmentBroker* g_attachment_broker = nullptr;
|
| +
|
| namespace {
|
|
|
| +// Makes a platform specific AttachmentBroker.
|
| +IPC::AttachmentBroker* CreateAttachmentBroker() {
|
| +#if defined(OS_WIN)
|
| + IPC::AttachmentBrokerWin* attachment_broker = new IPC::AttachmentBrokerWin;
|
| + ANNOTATE_LEAKING_OBJECT_PTR(attachment_broker);
|
| + return attachment_broker;
|
| +#else
|
| + return nullptr;
|
| +#endif // defined(OS_WIN)
|
| +}
|
| +
|
| #if defined(OS_MACOSX)
|
| // Given |path| identifying a Mac-style child process executable path, adjusts
|
| // it to correspond to |feature|. For a child process path such as
|
| @@ -137,6 +157,15 @@ base::FilePath ChildProcessHost::GetChildPath(int flags) {
|
| return child_path;
|
| }
|
|
|
| +// static
|
| +IPC::AttachmentBroker* ChildProcessHost::GetAttachmentBroker() {
|
| + base::AutoLock lock(g_attachment_broker_lock.Get());
|
| + if (!g_attachment_broker)
|
| + g_attachment_broker = CreateAttachmentBroker();
|
| +
|
| + return g_attachment_broker;
|
| +}
|
| +
|
| ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate)
|
| : delegate_(delegate),
|
| opening_channel_(false) {
|
| @@ -165,7 +194,8 @@ void ChildProcessHostImpl::ForceShutdown() {
|
|
|
| std::string ChildProcessHostImpl::CreateChannel() {
|
| channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string());
|
| - channel_ = IPC::Channel::CreateServer(channel_id_, this);
|
| + channel_ =
|
| + IPC::Channel::CreateServer(channel_id_, this, GetAttachmentBroker());
|
| if (!channel_->Connect())
|
| return std::string();
|
|
|
|
|