OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/common/child_process_host_impl.h" | 5 #include "content/common/child_process_host_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/common/child_process_messages.h" | 24 #include "content/common/child_process_messages.h" |
25 #include "content/public/common/child_process_host_delegate.h" | 25 #include "content/public/common/child_process_host_delegate.h" |
26 #include "content/public/common/content_paths.h" | 26 #include "content/public/common/content_paths.h" |
27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
28 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 28 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
29 #include "ipc/attachment_broker.h" | 29 #include "ipc/attachment_broker.h" |
30 #include "ipc/attachment_broker_privileged.h" | 30 #include "ipc/attachment_broker_privileged.h" |
31 #include "ipc/ipc_channel.h" | 31 #include "ipc/ipc_channel.h" |
32 #include "ipc/ipc_logging.h" | 32 #include "ipc/ipc_logging.h" |
33 #include "ipc/message_filter.h" | 33 #include "ipc/message_filter.h" |
| 34 #include "ipc/mojo/ipc_channel_mojo.h" |
| 35 #include "mojo/edk/embedder/embedder.h" |
34 | 36 |
35 #if defined(OS_LINUX) | 37 #if defined(OS_LINUX) |
36 #include "base/linux_util.h" | 38 #include "base/linux_util.h" |
37 #elif defined(OS_WIN) | 39 #elif defined(OS_WIN) |
38 #include "content/common/font_cache_dispatcher_win.h" | 40 #include "content/common/font_cache_dispatcher_win.h" |
39 #endif // OS_LINUX | 41 #endif // OS_LINUX |
40 | 42 |
41 namespace { | 43 namespace { |
42 | 44 |
43 // Global atomic to generate child process unique IDs. | 45 // Global atomic to generate child process unique IDs. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 filters_.push_back(filter); | 125 filters_.push_back(filter); |
124 | 126 |
125 if (channel_) | 127 if (channel_) |
126 filter->OnFilterAdded(channel_.get()); | 128 filter->OnFilterAdded(channel_.get()); |
127 } | 129 } |
128 | 130 |
129 void ChildProcessHostImpl::ForceShutdown() { | 131 void ChildProcessHostImpl::ForceShutdown() { |
130 Send(new ChildProcessMsg_Shutdown()); | 132 Send(new ChildProcessMsg_Shutdown()); |
131 } | 133 } |
132 | 134 |
| 135 std::string ChildProcessHostImpl::CreateChannelMojo( |
| 136 const std::string& child_token) { |
| 137 DCHECK(channel_id_.empty()); |
| 138 channel_id_ = mojo::edk::GenerateRandomToken(); |
| 139 mojo::ScopedMessagePipeHandle host_handle = |
| 140 mojo::edk::CreateParentMessagePipe(channel_id_, child_token); |
| 141 channel_ = IPC::ChannelMojo::Create(std::move(host_handle), |
| 142 IPC::Channel::MODE_SERVER, this); |
| 143 if (!channel_ || !InitChannel()) |
| 144 return std::string(); |
| 145 |
| 146 return channel_id_; |
| 147 } |
| 148 |
133 std::string ChildProcessHostImpl::CreateChannel() { | 149 std::string ChildProcessHostImpl::CreateChannel() { |
| 150 DCHECK(channel_id_.empty()); |
134 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); | 151 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); |
135 channel_ = IPC::Channel::CreateServer(channel_id_, this); | 152 channel_ = IPC::Channel::CreateServer(channel_id_, this); |
| 153 if (!channel_ || !InitChannel()) |
| 154 return std::string(); |
| 155 |
| 156 return channel_id_; |
| 157 } |
| 158 |
| 159 bool ChildProcessHostImpl::InitChannel() { |
136 #if USE_ATTACHMENT_BROKER | 160 #if USE_ATTACHMENT_BROKER |
137 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( | 161 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( |
138 channel_.get(), base::MessageLoopForIO::current()->task_runner()); | 162 channel_.get(), base::MessageLoopForIO::current()->task_runner()); |
139 #endif | 163 #endif |
140 if (!channel_->Connect()) { | 164 if (!channel_->Connect()) { |
141 #if USE_ATTACHMENT_BROKER | 165 #if USE_ATTACHMENT_BROKER |
142 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( | 166 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
143 channel_.get()); | 167 channel_.get()); |
144 #endif | 168 #endif |
145 return std::string(); | 169 return false; |
146 } | 170 } |
147 | 171 |
148 for (size_t i = 0; i < filters_.size(); ++i) | 172 for (size_t i = 0; i < filters_.size(); ++i) |
149 filters_[i]->OnFilterAdded(channel_.get()); | 173 filters_[i]->OnFilterAdded(channel_.get()); |
150 | 174 |
151 // Make sure these messages get sent first. | 175 // Make sure these messages get sent first. |
152 #if defined(IPC_MESSAGE_LOG_ENABLED) | 176 #if defined(IPC_MESSAGE_LOG_ENABLED) |
153 bool enabled = IPC::Logging::GetInstance()->Enabled(); | 177 bool enabled = IPC::Logging::GetInstance()->Enabled(); |
154 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); | 178 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); |
155 #endif | 179 #endif |
156 | 180 |
157 opening_channel_ = true; | 181 opening_channel_ = true; |
158 | 182 |
159 return channel_id_; | 183 return true; |
160 } | 184 } |
161 | 185 |
162 bool ChildProcessHostImpl::IsChannelOpening() { | 186 bool ChildProcessHostImpl::IsChannelOpening() { |
163 return opening_channel_; | 187 return opening_channel_; |
164 } | 188 } |
165 | 189 |
166 #if defined(OS_POSIX) | 190 #if defined(OS_POSIX) |
167 base::ScopedFD ChildProcessHostImpl::TakeClientFileDescriptor() { | 191 base::ScopedFD ChildProcessHostImpl::TakeClientFileDescriptor() { |
168 return channel_->TakeClientFileDescriptor(); | 192 return channel_->TakeClientFileDescriptor(); |
169 } | 193 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 353 } |
330 | 354 |
331 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( | 355 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( |
332 gfx::GpuMemoryBufferId id, | 356 gfx::GpuMemoryBufferId id, |
333 const gpu::SyncToken& sync_token) { | 357 const gpu::SyncToken& sync_token) { |
334 // Note: Nothing to do here as ownership of shared memory backed | 358 // Note: Nothing to do here as ownership of shared memory backed |
335 // GpuMemoryBuffers is passed with IPC. | 359 // GpuMemoryBuffers is passed with IPC. |
336 } | 360 } |
337 | 361 |
338 } // namespace content | 362 } // namespace content |
OLD | NEW |