diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 23:28:46 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 23:28:46 +0000 |
commit | ac577490a5c20950f63d655de37058dc41486e99 (patch) | |
tree | e5a53f6cad3317c2451f8ef39bf0b19bd8706e79 /chrome/test/chrome_process_util.cc | |
parent | 0f1169993f28f8da9be5a81496fb2e2abf311387 (diff) | |
download | chromium_src-ac577490a5c20950f63d655de37058dc41486e99.zip chromium_src-ac577490a5c20950f63d655de37058dc41486e99.tar.gz chromium_src-ac577490a5c20950f63d655de37058dc41486e99.tar.bz2 |
Revert 18109, 18111: Windows UI tests failed.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/chrome_process_util.cc')
-rw-r--r-- | chrome/test/chrome_process_util.cc | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc index 4a5f5bb..296b291 100644 --- a/chrome/test/chrome_process_util.cc +++ b/chrome/test/chrome_process_util.cc @@ -5,7 +5,6 @@ #include "chrome/test/chrome_process_util.h" #include <vector> -#include <set> #include "base/process_util.h" #include "base/time.h" @@ -15,6 +14,26 @@ using base::Time; using base::TimeDelta; +namespace { + +class ChromeProcessFilter : public base::ProcessFilter { + public: + explicit ChromeProcessFilter(base::ProcessId browser_pid) + : browser_pid_(browser_pid) {} + + virtual bool Includes(base::ProcessId pid, base::ProcessId parent_pid) const { + // Match browser process itself and its children. + return browser_pid_ == pid || browser_pid_ == parent_pid; + } + + private: + base::ProcessId browser_pid_; + + DISALLOW_COPY_AND_ASSIGN(ChromeProcessFilter); +}; + +} // namespace + void TerminateAllChromeProcesses(const FilePath& data_dir) { // Total time the function will wait for chrome processes // to terminate after it told them to do so. @@ -51,24 +70,6 @@ void TerminateAllChromeProcesses(const FilePath& data_dir) { base::CloseProcessHandle(*it); } -class ChildProcessFilter : public base::ProcessFilter { - public: - explicit ChildProcessFilter(base::ProcessId parent_pid) - : parent_pids_(&parent_pid, (&parent_pid) + 1) {} - - explicit ChildProcessFilter(std::vector<base::ProcessId> parent_pids) - : parent_pids_(parent_pids.begin(), parent_pids.end()) {} - - virtual bool Includes(base::ProcessId pid, base::ProcessId parent_pid) const { - return parent_pids_.find(parent_pid) != parent_pids_.end(); - } - - private: - const std::set<base::ProcessId> parent_pids_; - - DISALLOW_COPY_AND_ASSIGN(ChildProcessFilter); -}; - ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir) { ChromeProcessList result; @@ -76,32 +77,37 @@ ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir) { if (browser_pid < 0) return result; - ChildProcessFilter filter(browser_pid); + // Normally, the browser is the parent process for all the renderers + base::ProcessId parent_pid = browser_pid; + +#if defined(OS_LINUX) + // But if the browser's parent is the same executable as the browser, + // then it's the zygote manager, and it's the parent for all the renderers. + base::ProcessId manager_pid = base::GetParentProcessId(browser_pid); + FilePath selfPath = base::GetProcessExecutablePath(browser_pid); + FilePath managerPath = base::GetProcessExecutablePath(manager_pid); + if (!selfPath.empty() && !managerPath.empty() && selfPath == managerPath) { + LOG(INFO) << "Zygote manager in use."; + parent_pid = manager_pid; + } +#endif + + ChromeProcessFilter filter(parent_pid); base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, &filter); const ProcessEntry* process_entry; while ((process_entry = it.NextProcessEntry())) { #if defined(OS_WIN) result.push_back(process_entry->th32ProcessID); +#elif defined(OS_LINUX) + // Don't count the zygote manager, that screws up unit tests, + // and it will exit cleanly on its own when first client exits. + if (process_entry->pid != manager_pid) + result.push_back(process_entry->pid); #elif defined(OS_POSIX) result.push_back(process_entry->pid); #endif } -#if defined(OS_LINUX) - // On Linux we might be running with a zygote process for the renderers. - // Because of that we sweep the list of processes again and pick those which - // are children of one of the processes that we've already seen. - { - ChildProcessFilter filter(result); - base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, - &filter); - while ((process_entry = it.NextProcessEntry())) - result.push_back(process_entry->pid); - } -#endif - - result.push_back(browser_pid); - return result; } |