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

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

Issue 2143893007: Remove attachment brokering from non-NaCl child processes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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/child/child_thread_impl.cc ('k') | no next file » | 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/hash.h" 12 #include "base/hash.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/numerics/safe_math.h" 16 #include "base/numerics/safe_math.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/process/process_metrics.h" 18 #include "base/process/process_metrics.h"
19 #include "base/rand_util.h" 19 #include "base/rand_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
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"
30 #include "ipc/attachment_broker_privileged.h"
31 #include "ipc/ipc_channel.h" 29 #include "ipc/ipc_channel.h"
32 #include "ipc/ipc_channel_mojo.h" 30 #include "ipc/ipc_channel_mojo.h"
33 #include "ipc/ipc_logging.h" 31 #include "ipc/ipc_logging.h"
34 #include "ipc/message_filter.h" 32 #include "ipc/message_filter.h"
35 #include "mojo/edk/embedder/embedder.h" 33 #include "mojo/edk/embedder/embedder.h"
36 34
37 #if defined(OS_LINUX) 35 #if defined(OS_LINUX)
38 #include "base/linux_util.h" 36 #include "base/linux_util.h"
39 #elif defined(OS_WIN) 37 #elif defined(OS_WIN)
40 #include "content/common/font_cache_dispatcher_win.h" 38 #include "content/common/font_cache_dispatcher_win.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 PathService::Get(CHILD_PROCESS_EXE, &child_path); 80 PathService::Get(CHILD_PROCESS_EXE, &child_path);
83 return child_path; 81 return child_path;
84 } 82 }
85 83
86 ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate) 84 ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate)
87 : delegate_(delegate), 85 : delegate_(delegate),
88 opening_channel_(false) { 86 opening_channel_(false) {
89 #if defined(OS_WIN) 87 #if defined(OS_WIN)
90 AddFilter(new FontCacheDispatcher()); 88 AddFilter(new FontCacheDispatcher());
91 #endif 89 #endif
92
93 #if USE_ATTACHMENT_BROKER
94 #if defined(OS_MACOSX)
95 // On Mac, the privileged AttachmentBroker needs a reference to the Mach port
96 // Provider, which is only available in the chrome/ module. The attachment
97 // broker must already be created.
98 DCHECK(IPC::AttachmentBroker::GetGlobal());
99 #else
100 // Construct the privileged attachment broker early in the life cycle of a
101 // child process.
102 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded();
103 #endif // defined(OS_MACOSX)
104 #endif // USE_ATTACHMENT_BROKER
105 } 90 }
106 91
107 ChildProcessHostImpl::~ChildProcessHostImpl() { 92 ChildProcessHostImpl::~ChildProcessHostImpl() {
108 // If a channel was never created than it wasn't registered and the filters 93 // If a channel was never created than it wasn't registered and the filters
109 // weren't notified. For the sake of symmetry don't call the matching teardown 94 // weren't notified. For the sake of symmetry don't call the matching teardown
110 // functions. This is analogous to how RenderProcessHostImpl handles things. 95 // functions. This is analogous to how RenderProcessHostImpl handles things.
111 if (!channel_) 96 if (!channel_)
112 return; 97 return;
113 98
114 #if USE_ATTACHMENT_BROKER
115 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
116 channel_.get());
117 #endif
118 for (size_t i = 0; i < filters_.size(); ++i) { 99 for (size_t i = 0; i < filters_.size(); ++i) {
119 filters_[i]->OnChannelClosing(); 100 filters_[i]->OnChannelClosing();
120 filters_[i]->OnFilterRemoved(); 101 filters_[i]->OnFilterRemoved();
121 } 102 }
122 } 103 }
123 104
124 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) { 105 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) {
125 filters_.push_back(filter); 106 filters_.push_back(filter);
126 107
127 if (channel_) 108 if (channel_)
(...skipping 22 matching lines...) Expand all
150 DCHECK(channel_id_.empty()); 131 DCHECK(channel_id_.empty());
151 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); 132 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string());
152 channel_ = IPC::Channel::CreateServer(channel_id_, this); 133 channel_ = IPC::Channel::CreateServer(channel_id_, this);
153 if (!channel_ || !InitChannel()) 134 if (!channel_ || !InitChannel())
154 return std::string(); 135 return std::string();
155 136
156 return channel_id_; 137 return channel_id_;
157 } 138 }
158 139
159 bool ChildProcessHostImpl::InitChannel() { 140 bool ChildProcessHostImpl::InitChannel() {
160 #if USE_ATTACHMENT_BROKER 141 if (!channel_->Connect())
161 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
162 channel_.get(), base::MessageLoopForIO::current()->task_runner());
163 #endif
164 if (!channel_->Connect()) {
165 #if USE_ATTACHMENT_BROKER
166 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
167 channel_.get());
168 #endif
169 return false; 142 return false;
170 }
171 143
172 for (size_t i = 0; i < filters_.size(); ++i) 144 for (size_t i = 0; i < filters_.size(); ++i)
173 filters_[i]->OnFilterAdded(channel_.get()); 145 filters_[i]->OnFilterAdded(channel_.get());
174 146
175 // Make sure these messages get sent first. 147 // Make sure these messages get sent first.
176 #if defined(IPC_MESSAGE_LOG_ENABLED) 148 #if defined(IPC_MESSAGE_LOG_ENABLED)
177 bool enabled = IPC::Logging::GetInstance()->Enabled(); 149 bool enabled = IPC::Logging::GetInstance()->Enabled();
178 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); 150 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled));
179 #endif 151 #endif
180 152
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 325 }
354 326
355 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( 327 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
356 gfx::GpuMemoryBufferId id, 328 gfx::GpuMemoryBufferId id,
357 const gpu::SyncToken& sync_token) { 329 const gpu::SyncToken& sync_token) {
358 // Note: Nothing to do here as ownership of shared memory backed 330 // Note: Nothing to do here as ownership of shared memory backed
359 // GpuMemoryBuffers is passed with IPC. 331 // GpuMemoryBuffers is passed with IPC.
360 } 332 }
361 333
362 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698