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

Side by Side Diff: content/common/child_process_host_impl.cc

Issue 1959313002: Use ChannelMojo for the utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-all-processes
Patch Set: Created 4 years, 7 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/common/child_process_host_impl.h ('k') | content/public/common/child_process_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 DCHECK(channel_id_.empty());
137 channel_id_ = mojo::edk::GenerateRandomToken();
138 mojo::ScopedMessagePipeHandle host_handle =
139 mojo::edk::CreateParentMessagePipe(channel_id_);
140 channel_ = IPC::ChannelMojo::Create(std::move(host_handle),
141 IPC::Channel::MODE_SERVER, this);
142 if (!channel_ || !CreateChannelCommon())
143 return std::string();
144
145 return channel_id_;
146 }
147
133 std::string ChildProcessHostImpl::CreateChannel() { 148 std::string ChildProcessHostImpl::CreateChannel() {
149 DCHECK(channel_id_.empty());
134 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); 150 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string());
135 channel_ = IPC::Channel::CreateServer(channel_id_, this); 151 channel_ = IPC::Channel::CreateServer(channel_id_, this);
152 if (!channel_ || !CreateChannelCommon())
153 return std::string();
154
155 return channel_id_;
156 }
157
158 bool ChildProcessHostImpl::CreateChannelCommon() {
ncarter (slow) 2016/05/10 16:50:10 Consider calling this InitChannel()/ConnectChannel
Anand Mistry (off Chromium) 2016/05/11 00:21:22 Done.
136 #if USE_ATTACHMENT_BROKER 159 #if USE_ATTACHMENT_BROKER
137 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( 160 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
138 channel_.get(), base::MessageLoopForIO::current()->task_runner()); 161 channel_.get(), base::MessageLoopForIO::current()->task_runner());
139 #endif 162 #endif
140 if (!channel_->Connect()) { 163 if (!channel_->Connect()) {
141 #if USE_ATTACHMENT_BROKER 164 #if USE_ATTACHMENT_BROKER
142 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( 165 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
143 channel_.get()); 166 channel_.get());
144 #endif 167 #endif
145 return std::string(); 168 return false;
146 } 169 }
147 170
148 for (size_t i = 0; i < filters_.size(); ++i) 171 for (size_t i = 0; i < filters_.size(); ++i)
149 filters_[i]->OnFilterAdded(channel_.get()); 172 filters_[i]->OnFilterAdded(channel_.get());
150 173
151 // Make sure these messages get sent first. 174 // Make sure these messages get sent first.
152 #if defined(IPC_MESSAGE_LOG_ENABLED) 175 #if defined(IPC_MESSAGE_LOG_ENABLED)
153 bool enabled = IPC::Logging::GetInstance()->Enabled(); 176 bool enabled = IPC::Logging::GetInstance()->Enabled();
154 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); 177 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled));
155 #endif 178 #endif
156 179
157 opening_channel_ = true; 180 opening_channel_ = true;
158 181
159 return channel_id_; 182 return true;
160 } 183 }
161 184
162 bool ChildProcessHostImpl::IsChannelOpening() { 185 bool ChildProcessHostImpl::IsChannelOpening() {
163 return opening_channel_; 186 return opening_channel_;
164 } 187 }
165 188
166 #if defined(OS_POSIX) 189 #if defined(OS_POSIX)
167 base::ScopedFD ChildProcessHostImpl::TakeClientFileDescriptor() { 190 base::ScopedFD ChildProcessHostImpl::TakeClientFileDescriptor() {
168 return channel_->TakeClientFileDescriptor(); 191 return channel_->TakeClientFileDescriptor();
169 } 192 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 352 }
330 353
331 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( 354 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
332 gfx::GpuMemoryBufferId id, 355 gfx::GpuMemoryBufferId id,
333 const gpu::SyncToken& sync_token) { 356 const gpu::SyncToken& sync_token) {
334 // Note: Nothing to do here as ownership of shared memory backed 357 // Note: Nothing to do here as ownership of shared memory backed
335 // GpuMemoryBuffers is passed with IPC. 358 // GpuMemoryBuffers is passed with IPC.
336 } 359 }
337 360
338 } // namespace content 361 } // namespace content
OLDNEW
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/public/common/child_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698