| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/test/chrome_process_util.h" | 5 #include "chrome/test/chrome_process_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 base::CloseProcessHandle(*it); | 70 base::CloseProcessHandle(*it); |
| 71 } | 71 } |
| 72 | 72 |
| 73 ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir) { | 73 ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir) { |
| 74 ChromeProcessList result; | 74 ChromeProcessList result; |
| 75 | 75 |
| 76 base::ProcessId browser_pid = ChromeBrowserProcessId(data_dir); | 76 base::ProcessId browser_pid = ChromeBrowserProcessId(data_dir); |
| 77 if (browser_pid < 0) | 77 if (browser_pid < 0) |
| 78 return result; | 78 return result; |
| 79 | 79 |
| 80 ChromeProcessFilter filter(browser_pid); | 80 // Normally, the browser is the parent process for all the renderers |
| 81 base::ProcessId parent_pid = browser_pid; |
| 82 |
| 83 #if defined(OS_LINUX) |
| 84 // But if the browser's parent is the same executable as the browser, |
| 85 // then it's the zygote manager, and it's the parent for all the renderers. |
| 86 base::ProcessId manager_pid = base::GetParentProcessId(browser_pid); |
| 87 FilePath selfPath = base::GetProcessExecutablePath(browser_pid); |
| 88 FilePath managerPath = base::GetProcessExecutablePath(manager_pid); |
| 89 if (!selfPath.empty() && !managerPath.empty() && selfPath == managerPath) { |
| 90 LOG(INFO) << "Zygote manager in use."; |
| 91 parent_pid = manager_pid; |
| 92 } |
| 93 #endif |
| 94 |
| 95 ChromeProcessFilter filter(parent_pid); |
| 81 base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, &filter); | 96 base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, &filter); |
| 82 | 97 |
| 83 const ProcessEntry* process_entry; | 98 const ProcessEntry* process_entry; |
| 84 while ((process_entry = it.NextProcessEntry())) { | 99 while ((process_entry = it.NextProcessEntry())) { |
| 85 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
| 86 result.push_back(process_entry->th32ProcessID); | 101 result.push_back(process_entry->th32ProcessID); |
| 102 #elif defined(OS_LINUX) |
| 103 // Don't count the zygote manager, that screws up unit tests, |
| 104 // and it will exit cleanly on its own when first client exits. |
| 105 if (process_entry->pid != manager_pid) |
| 106 result.push_back(process_entry->pid); |
| 87 #elif defined(OS_POSIX) | 107 #elif defined(OS_POSIX) |
| 88 result.push_back(process_entry->pid); | 108 result.push_back(process_entry->pid); |
| 89 #endif | 109 #endif |
| 90 } | 110 } |
| 91 | 111 |
| 92 return result; | 112 return result; |
| 93 } | 113 } |
| OLD | NEW |