diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 23:15:47 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 23:15:47 +0000 |
commit | 3753f52d42975eaefcafca9fc0257ec24e161a9c (patch) | |
tree | c9622baf613dd1b47c304d30e1ded74fa84fce54 /chrome/test/chrome_process_util.cc | |
parent | 9e23bb1bba29dad5305e8f8a08341aefe7275502 (diff) | |
download | chromium_src-3753f52d42975eaefcafca9fc0257ec24e161a9c.zip chromium_src-3753f52d42975eaefcafca9fc0257ec24e161a9c.tar.gz chromium_src-3753f52d42975eaefcafca9fc0257ec24e161a9c.tar.bz2 |
Implement chrome_proces_util for linux and enable download ui test.
To get the PID from the socket, we use lsof (fuser doesn't work with unix sockets apparently).
The download shelf, save page, and browser ui tests now pass.
Review URL: http://codereview.chromium.org/66071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/chrome_process_util.cc')
-rw-r--r-- | chrome/test/chrome_process_util.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc index 128ec33..461194f 100644 --- a/chrome/test/chrome_process_util.cc +++ b/chrome/test/chrome_process_util.cc @@ -8,11 +8,32 @@ #include "base/process_util.h" #include "base/time.h" +#include "chrome/common/chrome_constants.h" #include "chrome/common/result_codes.h" 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. @@ -48,3 +69,25 @@ void TerminateAllChromeProcesses(const FilePath& data_dir) { for (it = handles.begin(); it != handles.end(); ++it) base::CloseProcessHandle(*it); } + +ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir) { + ChromeProcessList result; + + base::ProcessId browser_pid = ChromeBrowserProcessId(data_dir); + if (browser_pid < 0) + return result; + + ChromeProcessFilter filter(browser_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_POSIX) + result.push_back(process_entry->pid); +#endif + } + + return result; +} |