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 // 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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // This is for the code that is to be ran in multiple threads at once, | 32 // This is for the code that is to be ran in multiple threads at once, |
33 // to stress a race condition on first process start. | 33 // to stress a race condition on first process start. |
34 // We use the thread safe ref counted base class so that we can use the | 34 // We use the thread safe ref counted base class so that we can use the |
35 // NewRunnableMethod class to run the StartChrome methods in many threads. | 35 // NewRunnableMethod class to run the StartChrome methods in many threads. |
36 class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> { | 36 class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> { |
37 public: | 37 public: |
38 explicit ChromeStarter(int timeout_ms, const FilePath& user_data_dir) | 38 explicit ChromeStarter(int timeout_ms, const FilePath& user_data_dir) |
39 : ready_event_(false /* manual */, false /* signaled */), | 39 : ready_event_(false /* manual */, false /* signaled */), |
40 done_event_(false /* manual */, false /* signaled */), | 40 done_event_(false /* manual */, false /* signaled */), |
41 process_handle_(NULL), | 41 process_handle_(base::kNullProcessHandle), |
42 process_terminated_(false), | 42 process_terminated_(false), |
43 timeout_ms_(timeout_ms), | 43 timeout_ms_(timeout_ms), |
44 user_data_dir_(user_data_dir) { | 44 user_data_dir_(user_data_dir) { |
45 } | 45 } |
46 | 46 |
47 // We must reset some data members since we reuse the same ChromeStarter | 47 // We must reset some data members since we reuse the same ChromeStarter |
48 // object and start/stop it a few times. We must start fresh! :-) | 48 // object and start/stop it a few times. We must start fresh! :-) |
49 void Reset() { | 49 void Reset() { |
50 ready_event_.Reset(); | 50 ready_event_.Reset(); |
51 done_event_.Reset(); | 51 done_event_.Reset(); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 pending_starters.empty(); | 317 pending_starters.empty(); |
318 if (chrome_starters_[last_index]->process_handle_ != | 318 if (chrome_starters_[last_index]->process_handle_ != |
319 base::kNullProcessHandle) { | 319 base::kNullProcessHandle) { |
320 KillProcessTree(chrome_starters_[last_index]->process_handle_); | 320 KillProcessTree(chrome_starters_[last_index]->process_handle_); |
321 chrome_starters_[last_index]->done_event_.Wait(); | 321 chrome_starters_[last_index]->done_event_.Wait(); |
322 } | 322 } |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 } // namespace | 326 } // namespace |
OLD | NEW |