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

Side by Side Diff: content/browser/child_process_launcher.cc

Issue 22911027: Pass StatsTable shared memory via global descriptors on Posix rather than using named shared memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
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/browser/child_process_launcher.h" 5 #include "content/browser/child_process_launcher.h"
6 6
7 #include <utility> // For std::pair. 7 #include <utility> // For std::pair.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 20 matching lines...) Expand all
31 #elif defined(OS_ANDROID) 31 #elif defined(OS_ANDROID)
32 #include "base/android/jni_android.h" 32 #include "base/android/jni_android.h"
33 #include "content/browser/android/child_process_launcher_android.h" 33 #include "content/browser/android/child_process_launcher_android.h"
34 #elif defined(OS_POSIX) 34 #elif defined(OS_POSIX)
35 #include "base/memory/singleton.h" 35 #include "base/memory/singleton.h"
36 #include "content/browser/renderer_host/render_sandbox_host_linux.h" 36 #include "content/browser/renderer_host/render_sandbox_host_linux.h"
37 #include "content/browser/zygote_host/zygote_host_impl_linux.h" 37 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
38 #endif 38 #endif
39 39
40 #if defined(OS_POSIX) 40 #if defined(OS_POSIX)
41 #include "base/metrics/stats_table.h"
41 #include "base/posix/global_descriptors.h" 42 #include "base/posix/global_descriptors.h"
42 #endif 43 #endif
43 44
44 namespace content { 45 namespace content {
45 46
46 // Having the functionality of ChildProcessLauncher be in an internal 47 // Having the functionality of ChildProcessLauncher be in an internal
47 // ref counted object allows us to automatically terminate the process when the 48 // ref counted object allows us to automatically terminate the process when the
48 // parent class destructs, while still holding on to state that we need. 49 // parent class destructs, while still holding on to state that we need.
49 class ChildProcessLauncher::Context 50 class ChildProcessLauncher::Context
50 : public base::RefCountedThreadSafe<ChildProcessLauncher::Context> { 51 : public base::RefCountedThreadSafe<ChildProcessLauncher::Context> {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Android WebView runs in single process, ensure that we never get here 201 // Android WebView runs in single process, ensure that we never get here
201 // when running in single process mode. 202 // when running in single process mode.
202 CHECK(!cmd_line->HasSwitch(switches::kSingleProcess)); 203 CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
203 204
204 std::string process_type = 205 std::string process_type =
205 cmd_line->GetSwitchValueASCII(switches::kProcessType); 206 cmd_line->GetSwitchValueASCII(switches::kProcessType);
206 std::vector<FileDescriptorInfo> files_to_register; 207 std::vector<FileDescriptorInfo> files_to_register;
207 files_to_register.push_back( 208 files_to_register.push_back(
208 FileDescriptorInfo(kPrimaryIPCChannel, 209 FileDescriptorInfo(kPrimaryIPCChannel,
209 base::FileDescriptor(ipcfd, false))); 210 base::FileDescriptor(ipcfd, false)));
211 base::StatsTable* stats_table;
212 if ((stats_table = base::StatsTable::current()) != NULL) {
jar (doing other things) 2013/08/21 01:09:46 nit: initialize during the definition, rather than
rmcilroy 2013/08/21 10:37:16 Done.
213 files_to_register.push_back(
214 FileDescriptorInfo(kStatsTableSharedMemFd,
215 stats_table->GetSharedMemoryHandle()));
jar (doing other things) 2013/08/21 01:09:46 nit: indent: align under first argument.
rmcilroy 2013/08/21 10:37:16 I was copying line 210 above. I've now changed bo
216 }
210 217
211 GetContentClient()->browser()-> 218 GetContentClient()->browser()->
212 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id, 219 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id,
213 &files_to_register); 220 &files_to_register);
214 221
215 StartChildProcess(cmd_line->argv(), files_to_register, 222 StartChildProcess(cmd_line->argv(), files_to_register,
216 base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted, 223 base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted,
217 this_object, client_thread_id, begin_launch_time)); 224 this_object, client_thread_id, begin_launch_time));
218 225
219 #elif defined(OS_POSIX) 226 #elif defined(OS_POSIX)
220 base::ProcessHandle handle = base::kNullProcessHandle; 227 base::ProcessHandle handle = base::kNullProcessHandle;
221 // We need to close the client end of the IPC channel to reliably detect 228 // We need to close the client end of the IPC channel to reliably detect
222 // child termination. 229 // child termination.
223 file_util::ScopedFD ipcfd_closer(&ipcfd); 230 file_util::ScopedFD ipcfd_closer(&ipcfd);
224 231
225 std::string process_type = 232 std::string process_type =
226 cmd_line->GetSwitchValueASCII(switches::kProcessType); 233 cmd_line->GetSwitchValueASCII(switches::kProcessType);
227 std::vector<FileDescriptorInfo> files_to_register; 234 std::vector<FileDescriptorInfo> files_to_register;
228 files_to_register.push_back( 235 files_to_register.push_back(
229 FileDescriptorInfo(kPrimaryIPCChannel, 236 FileDescriptorInfo(kPrimaryIPCChannel,
230 base::FileDescriptor(ipcfd, false))); 237 base::FileDescriptor(ipcfd, false)));
231 238 base::StatsTable* stats_table;
239 if ((stats_table = base::StatsTable::current()) != NULL) {
jar (doing other things) 2013/08/21 01:09:46 nit: initialize in definition, rather than during
rmcilroy 2013/08/21 10:37:16 Done.
240 files_to_register.push_back(
241 FileDescriptorInfo(kStatsTableSharedMemFd,
242 stats_table->GetSharedMemoryHandle()));
jar (doing other things) 2013/08/21 01:09:46 nit: indent
rmcilroy 2013/08/21 10:37:16 Done.
243 }
232 #if !defined(OS_MACOSX) 244 #if !defined(OS_MACOSX)
233 GetContentClient()->browser()-> 245 GetContentClient()->browser()->
234 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id, 246 GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id,
235 &files_to_register); 247 &files_to_register);
236 if (use_zygote) { 248 if (use_zygote) {
237 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(), 249 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(),
238 files_to_register, 250 files_to_register,
239 process_type); 251 process_type);
240 } else 252 } else
241 // Fall through to the normal posix case below when we're not zygoting. 253 // Fall through to the normal posix case below when we're not zygoting.
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 GetHandle(), background)); 505 GetHandle(), background));
494 } 506 }
495 507
496 void ChildProcessLauncher::SetTerminateChildOnShutdown( 508 void ChildProcessLauncher::SetTerminateChildOnShutdown(
497 bool terminate_on_shutdown) { 509 bool terminate_on_shutdown) {
498 if (context_.get()) 510 if (context_.get())
499 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); 511 context_->set_terminate_child_on_shutdown(terminate_on_shutdown);
500 } 512 }
501 513
502 } // namespace content 514 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698