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

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

Issue 2221153003: Establish MojoChildConnection from BrowserChildProcessHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-channel
Patch Set: rebase 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/common/child_process_host_impl.h ('k') | content/common/mojo/constants.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 10 matching lines...) Expand all
21 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
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.mojom.h"
31 #include "ipc/ipc_channel.h" 32 #include "ipc/ipc_channel.h"
32 #include "ipc/ipc_channel_mojo.h" 33 #include "ipc/ipc_channel_mojo.h"
33 #include "ipc/ipc_logging.h" 34 #include "ipc/ipc_logging.h"
34 #include "ipc/message_filter.h" 35 #include "ipc/message_filter.h"
35 #include "mojo/edk/embedder/embedder.h" 36 #include "mojo/edk/embedder/embedder.h"
37 #include "services/shell/public/cpp/interface_provider.h"
36 38
37 #if defined(OS_LINUX) 39 #if defined(OS_LINUX)
38 #include "base/linux_util.h" 40 #include "base/linux_util.h"
39 #elif defined(OS_WIN) 41 #elif defined(OS_WIN)
40 #include "content/common/font_cache_dispatcher_win.h" 42 #include "content/common/font_cache_dispatcher_win.h"
41 #endif // OS_LINUX 43 #endif // OS_LINUX
42 44
43 namespace { 45 namespace {
44 46
45 // Global atomic to generate child process unique IDs. 47 // Global atomic to generate child process unique IDs.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 123 }
122 } 124 }
123 125
124 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) { 126 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) {
125 filters_.push_back(filter); 127 filters_.push_back(filter);
126 128
127 if (channel_) 129 if (channel_)
128 filter->OnFilterAdded(channel_.get()); 130 filter->OnFilterAdded(channel_.get());
129 } 131 }
130 132
133 shell::InterfaceProvider* ChildProcessHostImpl::GetRemoteInterfaces() {
134 return delegate_->GetRemoteInterfaces();
135 }
136
131 void ChildProcessHostImpl::ForceShutdown() { 137 void ChildProcessHostImpl::ForceShutdown() {
132 Send(new ChildProcessMsg_Shutdown()); 138 Send(new ChildProcessMsg_Shutdown());
133 } 139 }
134 140
135 std::string ChildProcessHostImpl::CreateChannelMojo( 141 std::string ChildProcessHostImpl::CreateChannelMojo(
136 const std::string& child_token) { 142 const std::string& child_token) {
137 DCHECK(channel_id_.empty()); 143 DCHECK(channel_id_.empty());
138 channel_id_ = mojo::edk::GenerateRandomToken(); 144 channel_id_ = mojo::edk::GenerateRandomToken();
139 mojo::ScopedMessagePipeHandle host_handle = 145 mojo::ScopedMessagePipeHandle host_handle =
140 mojo::edk::CreateParentMessagePipe(channel_id_, child_token); 146 mojo::edk::CreateParentMessagePipe(channel_id_, child_token);
141 channel_ = IPC::ChannelMojo::Create(std::move(host_handle), 147 channel_ = IPC::ChannelMojo::Create(std::move(host_handle),
142 IPC::Channel::MODE_SERVER, this); 148 IPC::Channel::MODE_SERVER, this);
143 if (!channel_ || !InitChannel()) 149 if (!channel_ || !InitChannel())
144 return std::string(); 150 return std::string();
145 151
146 return channel_id_; 152 return channel_id_;
147 } 153 }
148 154
155 void ChildProcessHostImpl::CreateChannelMojo() {
156 // TODO(rockot): Remove |channel_id_| once this is the only code path by which
157 // the Channel is created. For now it serves to at least mutually exclude
158 // different CreateChannel* calls.
159 DCHECK(channel_id_.empty());
160 channel_id_ = "ChannelMojo";
161
162 shell::InterfaceProvider* remote_interfaces = GetRemoteInterfaces();
163 DCHECK(remote_interfaces);
164
165 IPC::mojom::ChannelBootstrapPtr bootstrap;
166 remote_interfaces->GetInterface(&bootstrap);
167 channel_ = IPC::ChannelMojo::Create(bootstrap.PassInterface().PassHandle(),
168 IPC::Channel::MODE_SERVER, this);
169 DCHECK(channel_);
170
171 bool initialized = InitChannel();
172 DCHECK(initialized);
173 }
174
149 std::string ChildProcessHostImpl::CreateChannel() { 175 std::string ChildProcessHostImpl::CreateChannel() {
150 DCHECK(channel_id_.empty()); 176 DCHECK(channel_id_.empty());
151 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); 177 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string());
152 channel_ = IPC::Channel::CreateServer(channel_id_, this); 178 channel_ = IPC::Channel::CreateServer(channel_id_, this);
153 if (!channel_ || !InitChannel()) 179 if (!channel_ || !InitChannel())
154 return std::string(); 180 return std::string();
155 181
156 return channel_id_; 182 return channel_id_;
157 } 183 }
158 184
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 379 }
354 380
355 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( 381 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
356 gfx::GpuMemoryBufferId id, 382 gfx::GpuMemoryBufferId id,
357 const gpu::SyncToken& sync_token) { 383 const gpu::SyncToken& sync_token) {
358 // Note: Nothing to do here as ownership of shared memory backed 384 // Note: Nothing to do here as ownership of shared memory backed
359 // GpuMemoryBuffers is passed with IPC. 385 // GpuMemoryBuffers is passed with IPC.
360 } 386 }
361 387
362 } // namespace content 388 } // namespace content
OLDNEW
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/common/mojo/constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698