OLD | NEW |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #if defined(OS_POSIX) | 60 #if defined(OS_POSIX) |
61 terminate_child_on_shutdown_ = !CommandLine::ForCurrentProcess()-> | 61 terminate_child_on_shutdown_ = !CommandLine::ForCurrentProcess()-> |
62 HasSwitch(switches::kChildCleanExit); | 62 HasSwitch(switches::kChildCleanExit); |
63 #else | 63 #else |
64 terminate_child_on_shutdown_ = true; | 64 terminate_child_on_shutdown_ = true; |
65 #endif | 65 #endif |
66 } | 66 } |
67 | 67 |
68 void Launch( | 68 void Launch( |
69 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
70 const FilePath& exposed_dir, | 70 const base::FilePath& exposed_dir, |
71 #elif defined(OS_ANDROID) | 71 #elif defined(OS_ANDROID) |
72 int ipcfd, | 72 int ipcfd, |
73 #elif defined(OS_POSIX) | 73 #elif defined(OS_POSIX) |
74 bool use_zygote, | 74 bool use_zygote, |
75 const base::EnvironmentVector& environ, | 75 const base::EnvironmentVector& environ, |
76 int ipcfd, | 76 int ipcfd, |
77 #endif | 77 #endif |
78 CommandLine* cmd_line, | 78 CommandLine* cmd_line, |
79 int child_process_id, | 79 int child_process_id, |
80 Client* client) { | 80 Client* client) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 ~Context() { | 146 ~Context() { |
147 Terminate(); | 147 Terminate(); |
148 } | 148 } |
149 | 149 |
150 static void LaunchInternal( | 150 static void LaunchInternal( |
151 // |this_object| is NOT thread safe. Only use it to post a task back. | 151 // |this_object| is NOT thread safe. Only use it to post a task back. |
152 scoped_refptr<Context> this_object, | 152 scoped_refptr<Context> this_object, |
153 BrowserThread::ID client_thread_id, | 153 BrowserThread::ID client_thread_id, |
154 int child_process_id, | 154 int child_process_id, |
155 #if defined(OS_WIN) | 155 #if defined(OS_WIN) |
156 const FilePath& exposed_dir, | 156 const base::FilePath& exposed_dir, |
157 #elif defined(OS_ANDROID) | 157 #elif defined(OS_ANDROID) |
158 int ipcfd, | 158 int ipcfd, |
159 #elif defined(OS_POSIX) | 159 #elif defined(OS_POSIX) |
160 bool use_zygote, | 160 bool use_zygote, |
161 const base::EnvironmentVector& env, | 161 const base::EnvironmentVector& env, |
162 int ipcfd, | 162 int ipcfd, |
163 #endif | 163 #endif |
164 CommandLine* cmd_line) { | 164 CommandLine* cmd_line) { |
165 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); | 165 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); |
166 | 166 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // The fd to close after creating the process. | 372 // The fd to close after creating the process. |
373 int ipcfd_; | 373 int ipcfd_; |
374 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 374 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
375 bool zygote_; | 375 bool zygote_; |
376 #endif | 376 #endif |
377 }; | 377 }; |
378 | 378 |
379 | 379 |
380 ChildProcessLauncher::ChildProcessLauncher( | 380 ChildProcessLauncher::ChildProcessLauncher( |
381 #if defined(OS_WIN) | 381 #if defined(OS_WIN) |
382 const FilePath& exposed_dir, | 382 const base::FilePath& exposed_dir, |
383 #elif defined(OS_POSIX) | 383 #elif defined(OS_POSIX) |
384 bool use_zygote, | 384 bool use_zygote, |
385 const base::EnvironmentVector& environ, | 385 const base::EnvironmentVector& environ, |
386 int ipcfd, | 386 int ipcfd, |
387 #endif | 387 #endif |
388 CommandLine* cmd_line, | 388 CommandLine* cmd_line, |
389 int child_process_id, | 389 int child_process_id, |
390 Client* client) { | 390 Client* client) { |
391 context_ = new Context(); | 391 context_ = new Context(); |
392 context_->Launch( | 392 context_->Launch( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 GetHandle(), background)); | 461 GetHandle(), background)); |
462 } | 462 } |
463 | 463 |
464 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 464 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
465 bool terminate_on_shutdown) { | 465 bool terminate_on_shutdown) { |
466 if (context_) | 466 if (context_) |
467 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 467 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
468 } | 468 } |
469 | 469 |
470 } // namespace content | 470 } // namespace content |
OLD | NEW |