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 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "base/single_thread_task_runner.h" | 28 #include "base/single_thread_task_runner.h" |
29 #include "base/synchronization/waitable_event.h" | 29 #include "base/synchronization/waitable_event.h" |
30 #include "base/test/test_timeouts.h" | 30 #include "base/test/test_timeouts.h" |
31 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
32 #include "build/build_config.h" | 32 #include "build/build_config.h" |
33 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
34 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/test/base/in_process_browser_test.h" | 36 #include "chrome/test/base/in_process_browser_test.h" |
37 #include "chrome/test/base/test_launcher_utils.h" | 37 #include "chrome/test/base/test_launcher_utils.h" |
38 #include "content/public/common/content_switches.h" | |
Ilya Sherman
2017/06/13 22:42:48
Please revert the changes to this file.
chaopeng
2017/06/28 14:16:51
Done.
| |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 // This is for the code that is to be ran in multiple threads at once, | 42 // This is for the code that is to be ran in multiple threads at once, |
42 // to stress a race condition on first process start. | 43 // to stress a race condition on first process start. |
43 // We use the thread safe ref counted base class so that we can use the | 44 // We use the thread safe ref counted base class so that we can use the |
44 // base::Bind to run the StartChrome methods in many threads. | 45 // base::Bind to run the StartChrome methods in many threads. |
45 class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> { | 46 class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> { |
46 public: | 47 public: |
47 ChromeStarter(base::TimeDelta timeout, const base::FilePath& user_data_dir) | 48 ChromeStarter(base::TimeDelta timeout, const base::FilePath& user_data_dir) |
(...skipping 24 matching lines...) Expand all Loading... | |
72 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); | 73 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); |
73 | 74 |
74 if (first_run) | 75 if (first_run) |
75 command_line.AppendSwitch(switches::kForceFirstRun); | 76 command_line.AppendSwitch(switches::kForceFirstRun); |
76 else | 77 else |
77 command_line.AppendSwitch(switches::kNoFirstRun); | 78 command_line.AppendSwitch(switches::kNoFirstRun); |
78 | 79 |
79 // Add the normal test-mode switches, except for the ones we're adding | 80 // Add the normal test-mode switches, except for the ones we're adding |
80 // ourselves. | 81 // ourselves. |
81 base::CommandLine standard_switches(base::CommandLine::NO_PROGRAM); | 82 base::CommandLine standard_switches(base::CommandLine::NO_PROGRAM); |
83 | |
82 test_launcher_utils::PrepareBrowserCommandLineForTests(&standard_switches); | 84 test_launcher_utils::PrepareBrowserCommandLineForTests(&standard_switches); |
83 const base::CommandLine::SwitchMap& switch_map = | 85 const base::CommandLine::SwitchMap& switch_map = |
84 standard_switches.GetSwitches(); | 86 standard_switches.GetSwitches(); |
85 for (base::CommandLine::SwitchMap::const_iterator i = switch_map.begin(); | 87 for (base::CommandLine::SwitchMap::const_iterator i = switch_map.begin(); |
86 i != switch_map.end(); ++i) { | 88 i != switch_map.end(); ++i) { |
87 const std::string& switch_name = i->first; | 89 const std::string& switch_name = i->first; |
88 if (switch_name == switches::kUserDataDir || | 90 if (switch_name == switches::kUserDataDir || |
89 switch_name == switches::kForceFirstRun || | 91 switch_name == switches::kForceFirstRun || |
90 switch_name == switches::kNoFirstRun) | 92 switch_name == switches::kNoFirstRun) |
91 continue; | 93 continue; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 // "There can be only one!" :-) | 319 // "There can be only one!" :-) |
318 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); | 320 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); |
319 size_t last_index = pending_starters.front(); | 321 size_t last_index = pending_starters.front(); |
320 pending_starters.clear(); | 322 pending_starters.clear(); |
321 if (chrome_starters_[last_index]->process_.IsValid()) { | 323 if (chrome_starters_[last_index]->process_.IsValid()) { |
322 KillProcessTree(chrome_starters_[last_index]->process_); | 324 KillProcessTree(chrome_starters_[last_index]->process_); |
323 chrome_starters_[last_index]->done_event_.Wait(); | 325 chrome_starters_[last_index]->done_event_.Wait(); |
324 } | 326 } |
325 } | 327 } |
326 } | 328 } |
OLD | NEW |