OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/child_process_launcher.h" | 5 #include "chrome/browser/child_process_launcher.h" |
6 | 6 |
7 #include <utility> // For std::pair. | 7 #include <utility> // For std::pair. |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lock.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
12 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/synchronization/lock.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
15 #include "chrome/common/chrome_descriptors.h" | 15 #include "chrome/common/chrome_descriptors.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/process_watcher.h" | 17 #include "chrome/common/process_watcher.h" |
18 #include "chrome/common/result_codes.h" | 18 #include "chrome/common/result_codes.h" |
19 | 19 |
20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
21 #include "base/file_path.h" | 21 #include "base/file_path.h" |
22 #include "chrome/common/sandbox_policy.h" | 22 #include "chrome/common/sandbox_policy.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 bool launched = false; | 168 bool launched = false; |
169 #if defined(OS_MACOSX) | 169 #if defined(OS_MACOSX) |
170 // It is possible for the child process to die immediately after | 170 // It is possible for the child process to die immediately after |
171 // launching. To prevent leaking MachBroker map entries in this case, | 171 // launching. To prevent leaking MachBroker map entries in this case, |
172 // lock around all of LaunchApp(). If the child dies, the death | 172 // lock around all of LaunchApp(). If the child dies, the death |
173 // notification will be processed by the MachBroker after the call to | 173 // notification will be processed by the MachBroker after the call to |
174 // AddPlaceholderForPid(), enabling proper cleanup. | 174 // AddPlaceholderForPid(), enabling proper cleanup. |
175 { // begin scope for AutoLock | 175 { // begin scope for AutoLock |
176 MachBroker* broker = MachBroker::GetInstance(); | 176 MachBroker* broker = MachBroker::GetInstance(); |
177 AutoLock lock(broker->GetLock()); | 177 base::AutoLock lock(broker->GetLock()); |
178 | 178 |
179 // This call to |PrepareForFork()| will start the MachBroker listener | 179 // This call to |PrepareForFork()| will start the MachBroker listener |
180 // thread, if it is not already running. Therefore the browser process | 180 // thread, if it is not already running. Therefore the browser process |
181 // will be listening for Mach IPC before LaunchApp() is called. | 181 // will be listening for Mach IPC before LaunchApp() is called. |
182 broker->PrepareForFork(); | 182 broker->PrepareForFork(); |
183 #endif | 183 #endif |
184 // Actually launch the app. | 184 // Actually launch the app. |
185 launched = base::LaunchApp(cmd_line->argv(), env, fds_to_map, | 185 launched = base::LaunchApp(cmd_line->argv(), env, fds_to_map, |
186 /* wait= */false, &handle); | 186 /* wait= */false, &handle); |
187 #if defined(OS_MACOSX) | 187 #if defined(OS_MACOSX) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 if (status != base::TERMINATION_STATUS_STILL_RUNNING) | 333 if (status != base::TERMINATION_STATUS_STILL_RUNNING) |
334 context_->process_.Close(); | 334 context_->process_.Close(); |
335 | 335 |
336 return status; | 336 return status; |
337 } | 337 } |
338 | 338 |
339 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { | 339 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |
340 DCHECK(!context_->starting_); | 340 DCHECK(!context_->starting_); |
341 context_->process_.SetProcessBackgrounded(background); | 341 context_->process_.SetProcessBackgrounded(background); |
342 } | 342 } |
OLD | NEW |