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

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

Issue 1187153003: Update content module for IPC attachment brokering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GPUChannelHostFactory also needs to virtually inherit from SupportsAttachmentBrokering. This patch … Created 5 years, 6 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/npapi/np_channel_base.cc ('k') | content/common/gpu/client/gpu_channel_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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/lazy_instance.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/numerics/safe_math.h" 15 #include "base/numerics/safe_math.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/process/process_metrics.h" 17 #include "base/process/process_metrics.h"
17 #include "base/rand_util.h" 18 #include "base/rand_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 20 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
20 #include "content/common/child_process_messages.h" 21 #include "content/common/child_process_messages.h"
21 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 22 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
22 #include "content/public/common/child_process_host_delegate.h" 23 #include "content/public/common/child_process_host_delegate.h"
23 #include "content/public/common/content_paths.h" 24 #include "content/public/common/content_paths.h"
24 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
25 #include "ipc/ipc_channel.h" 26 #include "ipc/ipc_channel.h"
26 #include "ipc/ipc_logging.h" 27 #include "ipc/ipc_logging.h"
27 #include "ipc/message_filter.h" 28 #include "ipc/message_filter.h"
28 29
29 #if defined(OS_LINUX) 30 #if defined(OS_LINUX)
30 #include "base/linux_util.h" 31 #include "base/linux_util.h"
31 #elif defined(OS_WIN) 32 #elif defined(OS_WIN)
32 #include "content/common/font_cache_dispatcher_win.h" 33 #include "content/common/font_cache_dispatcher_win.h"
34 #include "ipc/attachment_broker_win.h"
33 #endif // OS_LINUX 35 #endif // OS_LINUX
34 36
37 #if defined(OS_WIN)
38 base::LazyInstance<IPC::AttachmentBrokerWin>::Leaky g_attachment_broker =
39 LAZY_INSTANCE_INITIALIZER;
40 #endif // defined(OS_WIN)
41
35 namespace { 42 namespace {
36 43
37 #if defined(OS_MACOSX) 44 #if defined(OS_MACOSX)
38 // Given |path| identifying a Mac-style child process executable path, adjusts 45 // Given |path| identifying a Mac-style child process executable path, adjusts
39 // it to correspond to |feature|. For a child process path such as 46 // it to correspond to |feature|. For a child process path such as
40 // ".../Chromium Helper.app/Contents/MacOS/Chromium Helper", the transformed 47 // ".../Chromium Helper.app/Contents/MacOS/Chromium Helper", the transformed
41 // path for feature "NP" would be 48 // path for feature "NP" would be
42 // ".../Chromium Helper NP.app/Contents/MacOS/Chromium Helper NP". The new 49 // ".../Chromium Helper NP.app/Contents/MacOS/Chromium Helper NP". The new
43 // path is returned. 50 // path is returned.
44 base::FilePath TransformPathForFeature(const base::FilePath& path, 51 base::FilePath TransformPathForFeature(const base::FilePath& path,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // non-executable heap, but the "EH" feature is provided to allow code 137 // non-executable heap, but the "EH" feature is provided to allow code
131 // intolerant of a non-executable heap to work properly on 10.7. This 138 // intolerant of a non-executable heap to work properly on 10.7. This
132 // results in Chromium Helper EH.app or Google Chrome Helper EH.app. 139 // results in Chromium Helper EH.app or Google Chrome Helper EH.app.
133 child_path = TransformPathForFeature(child_path, "EH"); 140 child_path = TransformPathForFeature(child_path, "EH");
134 } 141 }
135 #endif 142 #endif
136 143
137 return child_path; 144 return child_path;
138 } 145 }
139 146
147 // static
148 IPC::AttachmentBroker* ChildProcessHost::GetAttachmentBroker() {
149 #if defined(OS_WIN)
150 return &g_attachment_broker.Get();
151 #else
152 return nullptr;
153 #endif // defined(OS_WIN)
154 }
155
140 ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate) 156 ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate)
141 : delegate_(delegate), 157 : delegate_(delegate),
142 opening_channel_(false) { 158 opening_channel_(false) {
143 #if defined(OS_WIN) 159 #if defined(OS_WIN)
144 AddFilter(new FontCacheDispatcher()); 160 AddFilter(new FontCacheDispatcher());
145 #endif 161 #endif
146 } 162 }
147 163
148 ChildProcessHostImpl::~ChildProcessHostImpl() { 164 ChildProcessHostImpl::~ChildProcessHostImpl() {
149 for (size_t i = 0; i < filters_.size(); ++i) { 165 for (size_t i = 0; i < filters_.size(); ++i) {
150 filters_[i]->OnChannelClosing(); 166 filters_[i]->OnChannelClosing();
151 filters_[i]->OnFilterRemoved(); 167 filters_[i]->OnFilterRemoved();
152 } 168 }
153 } 169 }
154 170
155 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) { 171 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) {
156 filters_.push_back(filter); 172 filters_.push_back(filter);
157 173
158 if (channel_) 174 if (channel_)
159 filter->OnFilterAdded(channel_.get()); 175 filter->OnFilterAdded(channel_.get());
160 } 176 }
161 177
162 void ChildProcessHostImpl::ForceShutdown() { 178 void ChildProcessHostImpl::ForceShutdown() {
163 Send(new ChildProcessMsg_Shutdown()); 179 Send(new ChildProcessMsg_Shutdown());
164 } 180 }
165 181
166 std::string ChildProcessHostImpl::CreateChannel() { 182 std::string ChildProcessHostImpl::CreateChannel() {
167 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); 183 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string());
168 channel_ = IPC::Channel::CreateServer(channel_id_, this); 184 channel_ =
185 IPC::Channel::CreateServer(channel_id_, this, GetAttachmentBroker());
169 if (!channel_->Connect()) 186 if (!channel_->Connect())
170 return std::string(); 187 return std::string();
171 188
172 for (size_t i = 0; i < filters_.size(); ++i) 189 for (size_t i = 0; i < filters_.size(); ++i)
173 filters_[i]->OnFilterAdded(channel_.get()); 190 filters_[i]->OnFilterAdded(channel_.get());
174 191
175 // Make sure these messages get sent first. 192 // Make sure these messages get sent first.
176 #if defined(IPC_MESSAGE_LOG_ENABLED) 193 #if defined(IPC_MESSAGE_LOG_ENABLED)
177 bool enabled = IPC::Logging::GetInstance()->Enabled(); 194 bool enabled = IPC::Logging::GetInstance()->Enabled();
178 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); 195 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 348 }
332 349
333 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( 350 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
334 gfx::GpuMemoryBufferId id, 351 gfx::GpuMemoryBufferId id,
335 uint32 sync_point) { 352 uint32 sync_point) {
336 // Note: Nothing to do here as ownership of shared memory backed 353 // Note: Nothing to do here as ownership of shared memory backed
337 // GpuMemoryBuffers is passed with IPC. 354 // GpuMemoryBuffers is passed with IPC.
338 } 355 }
339 356
340 } // namespace content 357 } // namespace content
OLDNEW
« no previous file with comments | « content/child/npapi/np_channel_base.cc ('k') | content/common/gpu/client/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698