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 // This test validates that the ProcessSingleton class properly makes sure | 5 // This test validates that the ProcessSingleton class properly makes sure |
6 // that there is only one main browser process. | 6 // that there is only one main browser process. |
7 // | 7 // |
8 // It is currently compiled and run on Windows and Posix(non-Mac) platforms. | 8 // It is currently compiled and run on Windows and Posix(non-Mac) platforms. |
9 // Mac uses system services and ProcessSingletonMac is a noop. (Maybe it still | 9 // Mac uses system services and ProcessSingletonMac is a noop. (Maybe it still |
10 // makes sense to test that the system services are giving the behavior we | 10 // makes sense to test that the system services are giving the behavior we |
11 // want?) | 11 // want?) |
12 | 12 |
| 13 #include <stddef.h> |
| 14 |
13 #include "base/bind.h" | 15 #include "base/bind.h" |
14 #include "base/command_line.h" | 16 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
16 #include "base/files/scoped_temp_dir.h" | 18 #include "base/files/scoped_temp_dir.h" |
17 #include "base/location.h" | 19 #include "base/location.h" |
| 20 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
19 #include "base/path_service.h" | 22 #include "base/path_service.h" |
20 #include "base/process/launch.h" | 23 #include "base/process/launch.h" |
21 #include "base/process/process.h" | 24 #include "base/process/process.h" |
22 #include "base/process/process_iterator.h" | 25 #include "base/process/process_iterator.h" |
23 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
24 #include "base/synchronization/waitable_event.h" | 27 #include "base/synchronization/waitable_event.h" |
25 #include "base/test/test_timeouts.h" | 28 #include "base/test/test_timeouts.h" |
26 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 30 #include "build/build_config.h" |
27 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
31 #include "chrome/test/base/test_launcher_utils.h" | 35 #include "chrome/test/base/test_launcher_utils.h" |
32 | 36 |
33 namespace { | 37 namespace { |
34 | 38 |
35 // This is for the code that is to be ran in multiple threads at once, | 39 // This is for the code that is to be ran in multiple threads at once, |
36 // to stress a race condition on first process start. | 40 // to stress a race condition on first process start. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // "There can be only one!" :-) | 313 // "There can be only one!" :-) |
310 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); | 314 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); |
311 size_t last_index = pending_starters.front(); | 315 size_t last_index = pending_starters.front(); |
312 pending_starters.clear(); | 316 pending_starters.clear(); |
313 if (chrome_starters_[last_index]->process_.IsValid()) { | 317 if (chrome_starters_[last_index]->process_.IsValid()) { |
314 KillProcessTree(chrome_starters_[last_index]->process_); | 318 KillProcessTree(chrome_starters_[last_index]->process_); |
315 chrome_starters_[last_index]->done_event_.Wait(); | 319 chrome_starters_[last_index]->done_event_.Wait(); |
316 } | 320 } |
317 } | 321 } |
318 } | 322 } |
OLD | NEW |