summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/process_util_win.cc5
-rw-r--r--chrome/chrome.gyp6
-rw-r--r--chrome/common/chrome_process_filter.cc35
-rw-r--r--chrome/common/chrome_process_filter.h30
-rw-r--r--chrome/common/common.vcproj8
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.vcproj12
-rw-r--r--chrome/test/chrome_process_util.cc50
-rw-r--r--chrome/test/chrome_process_util.h26
-rw-r--r--chrome/test/chrome_process_util_win.cc63
-rw-r--r--chrome/test/interactive_ui/interactive_ui.vcproj12
-rw-r--r--chrome/test/memory_test/memory_test.cc49
-rw-r--r--chrome/test/memory_test/memory_test.vcproj12
-rw-r--r--chrome/test/page_cycler/page_cycler_test.cc54
-rw-r--r--chrome/test/page_cycler/page_cycler_tests.vcproj12
-rw-r--r--chrome/test/perf/mem_usage.cc22
-rw-r--r--chrome/test/plugin/plugin_tests.vcproj12
-rw-r--r--chrome/test/reliability/reliability_tests.vcproj12
-rw-r--r--chrome/test/selenium/selenium_tests.vcproj12
-rw-r--r--chrome/test/startup/startup_tests.vcproj12
-rw-r--r--chrome/test/tab_switching/tab_switching.vcproj12
-rw-r--r--chrome/test/ui/ui_test.cc29
-rw-r--r--chrome/test/ui/ui_tests.vcproj12
-rw-r--r--chrome/test/url_fetch_test/url_fetch_test.vcproj12
23 files changed, 349 insertions, 160 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 955c086..2fe9a00 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -34,7 +34,10 @@ ProcessHandle GetCurrentProcessHandle() {
}
bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
- ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE,
+ ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE |
+ PROCESS_TERMINATE |
+ PROCESS_QUERY_INFORMATION |
+ SYNCHRONIZE,
FALSE, pid);
if (result == INVALID_HANDLE_VALUE)
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 4e9bff2..75bc37a 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -161,8 +161,6 @@
'common/chrome_plugin_lib.h',
'common/chrome_plugin_util.cc',
'common/chrome_plugin_util.h',
- 'common/chrome_process_filter.cc',
- 'common/chrome_process_filter.h',
'common/chrome_switches.cc',
'common/chrome_switches.h',
'common/classfactory.cc',
@@ -346,7 +344,6 @@
'sources!': [
'common/gfx/emf.cc',
'common/gfx/icon_util.cc',
- 'common/chrome_process_filter.cc',
'common/classfactory.cc',
'common/drag_drop_types.cc',
'common/os_exchange_data.cc',
@@ -1796,6 +1793,9 @@
'test/automation/tab_proxy.h',
'test/automation/window_proxy.cc',
'test/automation/window_proxy.h',
+ 'test/chrome_process_util.cc',
+ 'test/chrome_process_util.h',
+ 'test/chrome_process_util_win.cc',
'test/testing_profile.cc',
'test/testing_profile.h',
],
diff --git a/chrome/common/chrome_process_filter.cc b/chrome/common/chrome_process_filter.cc
deleted file mode 100644
index 2b12d2d..0000000
--- a/chrome/common/chrome_process_filter.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <windows.h>
-
-#include "chrome/common/chrome_process_filter.h"
-
-#include "base/path_service.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
-
-BrowserProcessFilter::BrowserProcessFilter(const std::wstring user_data_dir)
- : browser_process_id_(0),
- user_data_dir_(user_data_dir) {
- // Find the message window (if any) for the current user data directory,
- // and get its process ID. We'll only count browser processes that either
- // have the same process ID or have that process ID as their parent.
-
- if (user_data_dir_.length() == 0)
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
-
-
- HWND message_window = FindWindowEx(HWND_MESSAGE, NULL,
- chrome::kMessageWindowClass,
- user_data_dir_.c_str());
- if (message_window)
- GetWindowThreadProcessId(message_window, &browser_process_id_);
-}
-
-bool BrowserProcessFilter::Includes(base::ProcessId pid,
- base::ProcessId parent_pid) const {
- return browser_process_id_ && (browser_process_id_ == pid ||
- browser_process_id_ == parent_pid);
-}
diff --git a/chrome/common/chrome_process_filter.h b/chrome/common/chrome_process_filter.h
deleted file mode 100644
index 8421fce..0000000
--- a/chrome/common/chrome_process_filter.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_CHROME_PROCESS_FILTER_H__
-#define CHROME_COMMON_CHROME_PROCESS_FILTER_H__
-
-#include "base/process_util.h"
-
-// Filter all chrome browser processes that run with the same user data
-// directory.
-class BrowserProcessFilter : public base::ProcessFilter {
- public:
- // Create the filter for the given user_data_dir.
- // If user_data_dir is an empty string, will use the PathService
- // user_data_dir (e.g. chrome::DIR_USER_DATA).
- explicit BrowserProcessFilter(const std::wstring user_data_dir);
-
- uint32 browser_process_id() const { return browser_process_id_; }
-
- virtual bool Includes(base::ProcessId pid, base::ProcessId parent_pid) const;
-
- private:
- std::wstring user_data_dir_;
- DWORD browser_process_id_;
-
- DISALLOW_EVIL_CONSTRUCTORS(BrowserProcessFilter);
-};
-
-#endif // CHROME_COMMON_CHROME_PROCESS_FILTER_H__
diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj
index a5ec901..5a26a5e 100644
--- a/chrome/common/common.vcproj
+++ b/chrome/common/common.vcproj
@@ -454,14 +454,6 @@
>
</File>
<File
- RelativePath=".\chrome_process_filter.cc"
- >
- </File>
- <File
- RelativePath=".\chrome_process_filter.h"
- >
- </File>
- <File
RelativePath=".\chrome_switches.cc"
>
</File>
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.vcproj b/chrome/test/automated_ui_tests/automated_ui_tests.vcproj
index ff233cc..002596e 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.vcproj
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.vcproj
@@ -162,6 +162,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc
new file mode 100644
index 0000000..128ec33
--- /dev/null
+++ b/chrome/test/chrome_process_util.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/test/chrome_process_util.h"
+
+#include <vector>
+
+#include "base/process_util.h"
+#include "base/time.h"
+#include "chrome/common/result_codes.h"
+
+using base::Time;
+using base::TimeDelta;
+
+void TerminateAllChromeProcesses(const FilePath& data_dir) {
+ // Total time the function will wait for chrome processes
+ // to terminate after it told them to do so.
+ const TimeDelta kExitTimeout = TimeDelta::FromMilliseconds(5000);
+
+ ChromeProcessList process_pids(GetRunningChromeProcesses(data_dir));
+
+ std::vector<base::ProcessHandle> handles;
+ {
+ ChromeProcessList::const_iterator it;
+ for (it = process_pids.begin(); it != process_pids.end(); ++it) {
+ base::ProcessHandle handle;
+ // Ignore processes for which we can't open the handle. We don't guarantee
+ // that all processes will terminate, only try to do so.
+ if (base::OpenProcessHandle(*it, &handle))
+ handles.push_back(handle);
+ }
+ }
+
+ std::vector<base::ProcessHandle>::const_iterator it;
+ for (it = handles.begin(); it != handles.end(); ++it)
+ base::KillProcess(*it, ResultCodes::TASKMAN_KILL, false);
+
+ const Time start = Time::Now();
+ for (it = handles.begin();
+ it != handles.end() && Time::Now() - start < kExitTimeout;
+ ++it) {
+ // TODO(phajdan.jr): Fix int/int64 problems with TimeDelta::InMilliseconds.
+ int wait_time_ms = static_cast<int>((Time::Now() - start).InMilliseconds());
+ base::WaitForSingleProcess(*it, wait_time_ms);
+ }
+
+ for (it = handles.begin(); it != handles.end(); ++it)
+ base::CloseProcessHandle(*it);
+}
diff --git a/chrome/test/chrome_process_util.h b/chrome/test/chrome_process_util.h
new file mode 100644
index 0000000..31f3b5f
--- /dev/null
+++ b/chrome/test/chrome_process_util.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_TEST_CHROME_PROCESS_UTIL_H_
+#define CHROME_TEST_CHROME_PROCESS_UTIL_H_
+
+#include <vector>
+
+#include "base/file_path.h"
+#include "base/process_util.h"
+
+typedef std::vector<base::ProcessId> ChromeProcessList;
+
+// Returns PID of browser process running with user data dir |data_dir|.
+// Returns -1 on error.
+base::ProcessId ChromeBrowserProcessId(const FilePath& data_dir);
+
+// Returns a vector of PIDs of chrome processes (main and renderers etc)
+// associated with user data dir |data_dir|. On error returns empty vector.
+ChromeProcessList GetRunningChromeProcesses(const FilePath& data_dir);
+
+// Attempts to terminate all chrome processes associated with |data_dir|.
+void TerminateAllChromeProcesses(const FilePath& data_dir);
+
+#endif // CHROME_TEST_CHROME_PROCESS_UTIL_H_
diff --git a/chrome/test/chrome_process_util_win.cc b/chrome/test/chrome_process_util_win.cc
new file mode 100644
index 0000000..b0e2e40
--- /dev/null
+++ b/chrome/test/chrome_process_util_win.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/test/chrome_process_util.h"
+
+#include <windows.h>
+
+#include <vector>
+
+#include "base/logging.h"
+#include "base/process_util.h"
+#include "chrome/common/chrome_constants.h"
+
+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
+
+base::ProcessId ChromeBrowserProcessId(const FilePath& data_dir) {
+ HWND message_window = FindWindowEx(HWND_MESSAGE, NULL,
+ chrome::kMessageWindowClass,
+ data_dir.value().c_str());
+ if (!message_window)
+ return -1;
+
+ DWORD browser_pid = -1;
+ GetWindowThreadProcessId(message_window, &browser_pid);
+
+ return browser_pid;
+}
+
+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())
+ result.push_back(process_entry->th32ProcessID);
+
+ return result;
+}
diff --git a/chrome/test/interactive_ui/interactive_ui.vcproj b/chrome/test/interactive_ui/interactive_ui.vcproj
index 5d2f9f0..ade66f2 100644
--- a/chrome/test/interactive_ui/interactive_ui.vcproj
+++ b/chrome/test/interactive_ui/interactive_ui.vcproj
@@ -192,6 +192,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_profile.cc"
>
</File>
diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc
index b437353..51be538 100644
--- a/chrome/test/memory_test/memory_test.cc
+++ b/chrome/test/memory_test/memory_test.cc
@@ -11,11 +11,11 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_process_filter.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
+#include "chrome/test/chrome_process_util.h"
#include "chrome/test/ui/ui_test.h"
#include "chrome/test/perf/mem_usage.h"
#include "googleurl/src/gurl.h"
@@ -269,31 +269,25 @@ class MemoryTest : public UITest {
void PrintIOPerfInfo(const char* test_name) {
printf("\n");
- BrowserProcessFilter chrome_filter(user_data_dir_);
- base::NamedProcessIterator
- chrome_process_itr(chrome::kBrowserProcessExecutableName,
- &chrome_filter);
-
- const PROCESSENTRY32* chrome_entry;
- while (chrome_entry = chrome_process_itr.NextProcessEntry()) {
- uint32 pid = chrome_entry->th32ProcessID;
- HANDLE process_handle = OpenProcess(PROCESS_QUERY_INFORMATION,
- false,
- pid);
- if (process_handle == NULL) {
- wprintf(L"Error opening process %d: %d\n", pid, GetLastError());
- continue;
- }
+ FilePath data_dir(FilePath::FromWStringHack(user_data_dir()));
+ int browser_process_pid = ChromeBrowserProcessId(data_dir);
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
+
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
scoped_ptr<base::ProcessMetrics> process_metrics;
IO_COUNTERS io_counters;
+ base::ProcessHandle process_handle;
+ if (!base::OpenProcessHandle(*it, &process_handle)) {
+ NOTREACHED();
+ }
process_metrics.reset(
base::ProcessMetrics::CreateProcessMetrics(process_handle));
ZeroMemory(&io_counters, sizeof(io_counters));
if (process_metrics.get()->GetIOCounters(&io_counters)) {
- std::string chrome_name =
- (pid == chrome_filter.browser_process_id()) ? "_b" : "_r";
+ std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
// Print out IO performance. We assume that the values can be
// converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
@@ -316,31 +310,32 @@ class MemoryTest : public UITest {
static_cast<size_t>(io_counters.OtherTransferCount / 1024),
"kb", false /* not important */);
}
+
+ base::CloseProcessHandle(process_handle);
}
}
void PrintMemoryUsageInfo(const char* test_name) {
printf("\n");
- BrowserProcessFilter chrome_filter(user_data_dir_);
- base::NamedProcessIterator
- chrome_process_itr(chrome::kBrowserProcessExecutableName,
- &chrome_filter);
+
+ FilePath data_dir(FilePath::FromWStringHack(user_data_dir()));
+ int browser_process_pid = ChromeBrowserProcessId(data_dir);
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
size_t browser_virtual_size = 0;
size_t browser_working_set_size = 0;
size_t virtual_size = 0;
size_t working_set_size = 0;
size_t num_chrome_processes = 0;
- const PROCESSENTRY32* chrome_entry;
- while (chrome_entry = chrome_process_itr.NextProcessEntry()) {
- uint32 pid = chrome_entry->th32ProcessID;
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
size_t peak_virtual_size;
size_t current_virtual_size;
size_t peak_working_set_size;
size_t current_working_set_size;
- if (GetMemoryInfo(pid, &peak_virtual_size, &current_virtual_size,
+ if (GetMemoryInfo(*it, &peak_virtual_size, &current_virtual_size,
&peak_working_set_size, &current_working_set_size)) {
- if (pid == chrome_filter.browser_process_id()) {
+ if (*it == browser_process_pid) {
browser_virtual_size = current_virtual_size;
browser_working_set_size = current_working_set_size;
}
diff --git a/chrome/test/memory_test/memory_test.vcproj b/chrome/test/memory_test/memory_test.vcproj
index 9de4326..d276fda 100644
--- a/chrome/test/memory_test/memory_test.vcproj
+++ b/chrome/test/memory_test/memory_test.vcproj
@@ -164,6 +164,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index 45a769c..91708cf 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -11,13 +11,10 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
-#if defined(OS_WIN)
-// TODO(port): Enable when chrome_process_filter.h is ported.
-#include "chrome/common/chrome_process_filter.h"
-#endif // defined(OS_WIN)
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
+#include "chrome/test/chrome_process_util.h"
#include "chrome/test/ui/ui_test.h"
#include "chrome/test/perf/mem_usage.h"
#include "googleurl/src/gurl.h"
@@ -88,19 +85,19 @@ class PageCyclerTest : public UITest {
}
#if defined(OS_WIN)
- // TODO(port): Code below depends on BrowserProcessFilter and has windowsisms.
+ // TODO(port): Port chrome_process_util and remove windowsisms.
void PrintIOPerfInfo(const char* test_name) {
- BrowserProcessFilter chrome_filter(L"");
- base::NamedProcessIterator
- chrome_process_itr(chrome::kBrowserProcessExecutableName,
- &chrome_filter);
-
- const PROCESSENTRY32* chrome_entry;
- while(chrome_entry = chrome_process_itr.NextProcessEntry()) {
- uint32 pid = chrome_entry->th32ProcessID;
- HANDLE process_handle = OpenProcess(PROCESS_QUERY_INFORMATION,
- false,
- pid);
+ FilePath data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &data_dir);
+ int browser_process_pid = ChromeBrowserProcessId(data_dir);
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
+
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
+ base::ProcessHandle process_handle;
+ if (!base::OpenProcessHandle(*it, &process_handle)) {
+ NOTREACHED();
+ }
scoped_ptr<base::ProcessMetrics> process_metrics;
IO_COUNTERS io_counters;
@@ -111,8 +108,7 @@ class PageCyclerTest : public UITest {
if (process_metrics.get()->GetIOCounters(&io_counters)) {
// Print out IO performance. We assume that the values can be
// converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
- std::string chrome_name =
- (pid == chrome_filter.browser_process_id()) ? "_b" : "_r";
+ std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
PrintResult("read_op", chrome_name,
"r_op" + chrome_name + test_name,
@@ -156,27 +152,27 @@ class PageCyclerTest : public UITest {
}
+
+ base::CloseProcessHandle(process_handle);
}
}
void PrintMemoryUsageInfo(const char* test_name) {
- BrowserProcessFilter chrome_filter(L"");
- base::NamedProcessIterator
- chrome_process_itr(chrome::kBrowserProcessExecutableName,
- &chrome_filter);
-
- const PROCESSENTRY32* chrome_entry;
- while(chrome_entry = chrome_process_itr.NextProcessEntry()) {
- uint32 pid = chrome_entry->th32ProcessID;
+ FilePath data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &data_dir);
+ int browser_process_pid = ChromeBrowserProcessId(data_dir);
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
+
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
size_t peak_virtual_size;
size_t current_virtual_size;
size_t peak_working_set_size;
size_t current_working_set_size;
- if (GetMemoryInfo(pid, &peak_virtual_size, &current_virtual_size,
+ if (GetMemoryInfo(*it, &peak_virtual_size, &current_virtual_size,
&peak_working_set_size, &current_working_set_size)) {
- std::string chrome_name =
- (pid == chrome_filter.browser_process_id()) ? "_b" : "_r";
+ std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
std::string trace_name(test_name);
PrintResult("vm_peak", chrome_name,
diff --git a/chrome/test/page_cycler/page_cycler_tests.vcproj b/chrome/test/page_cycler/page_cycler_tests.vcproj
index d3a7717..2f1a4d5 100644
--- a/chrome/test/page_cycler/page_cycler_tests.vcproj
+++ b/chrome/test/page_cycler/page_cycler_tests.vcproj
@@ -164,6 +164,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/perf/mem_usage.cc b/chrome/test/perf/mem_usage.cc
index 853bfac..f67e56a 100644
--- a/chrome/test/perf/mem_usage.cc
+++ b/chrome/test/perf/mem_usage.cc
@@ -6,9 +6,12 @@
#include <psapi.h>
#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "base/path_service.h"
#include "base/process_util.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_process_filter.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/test/chrome_process_util.h"
#include "chrome/test/perf/mem_usage.h"
bool GetMemoryInfo(uint32 process_id,
@@ -80,20 +83,21 @@ size_t GetSystemCommitCharge() {
void PrintChromeMemoryUsageInfo() {
printf("\n");
- BrowserProcessFilter chrome_filter(L"");
- base::NamedProcessIterator
- chrome_process_itr(chrome::kBrowserProcessExecutableName, &chrome_filter);
- const PROCESSENTRY32* chrome_entry;
- while (chrome_entry = chrome_process_itr.NextProcessEntry()) {
- uint32 pid = chrome_entry->th32ProcessID;
+ FilePath data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &data_dir);
+ int browser_process_pid = ChromeBrowserProcessId(data_dir);
+ ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
+
+ ChromeProcessList::const_iterator it;
+ for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
size_t peak_virtual_size;
size_t current_virtual_size;
size_t peak_working_set_size;
size_t current_working_set_size;
- if (GetMemoryInfo(pid, &peak_virtual_size, &current_virtual_size,
+ if (GetMemoryInfo(*it, &peak_virtual_size, &current_virtual_size,
&peak_working_set_size, &current_working_set_size)) {
- if (pid == chrome_filter.browser_process_id()) {
+ if (*it == browser_process_pid) {
wprintf(L"browser_vm_peak = %d\n", peak_virtual_size);
wprintf(L"browser_vm_current = %d\n", current_virtual_size);
wprintf(L"browser_ws_peak = %d\n", peak_working_set_size);
diff --git a/chrome/test/plugin/plugin_tests.vcproj b/chrome/test/plugin/plugin_tests.vcproj
index 0e43ea8..8898adc 100644
--- a/chrome/test/plugin/plugin_tests.vcproj
+++ b/chrome/test/plugin/plugin_tests.vcproj
@@ -165,6 +165,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/reliability/reliability_tests.vcproj b/chrome/test/reliability/reliability_tests.vcproj
index 1e443a7f..49a5600 100644
--- a/chrome/test/reliability/reliability_tests.vcproj
+++ b/chrome/test/reliability/reliability_tests.vcproj
@@ -168,6 +168,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/selenium/selenium_tests.vcproj b/chrome/test/selenium/selenium_tests.vcproj
index 727dfa0..42c95fc 100644
--- a/chrome/test/selenium/selenium_tests.vcproj
+++ b/chrome/test/selenium/selenium_tests.vcproj
@@ -164,6 +164,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/startup/startup_tests.vcproj b/chrome/test/startup/startup_tests.vcproj
index 1ebb980..6087ede3 100644
--- a/chrome/test/startup/startup_tests.vcproj
+++ b/chrome/test/startup/startup_tests.vcproj
@@ -164,6 +164,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/tab_switching/tab_switching.vcproj b/chrome/test/tab_switching/tab_switching.vcproj
index bdc2836..81e185f 100644
--- a/chrome/test/tab_switching/tab_switching.vcproj
+++ b/chrome/test/tab_switching/tab_switching.vcproj
@@ -164,6 +164,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index d273175..d30643b2 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/path_service.h"
#include "base/platform_thread.h"
#include "base/process_util.h"
#include "base/scoped_ptr.h"
@@ -28,12 +29,12 @@
#include "chrome/test/automation/automation_proxy.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/chrome_process_util.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
#if defined(OS_WIN)
-// TODO(port): these just need to be ported.
-#include "chrome/common/chrome_process_filter.h"
+// TODO(port): this just needs to be ported.
#include "chrome/test/automation/window_proxy.h"
#endif
@@ -448,30 +449,22 @@ void UITest::AssertAppNotRunning(const std::wstring& error_message) {
#if defined(OS_WIN)
ASSERT_EQ(0, GetBrowserProcessCount()) << error_message;
#else
- // TODO(port): Enable when chrome_process_filter is ported.
+ // TODO(port): Enable when chrome_process_util is ported.
NOTIMPLEMENTED();
#endif
}
void UITest::CleanupAppProcesses() {
#if defined(OS_WIN)
- BrowserProcessFilter filter(L"");
-
- // Make sure that no instances of the browser remain.
- const int kExitTimeoutMs = 5000;
- const int kExitCode = 1;
- base::CleanupProcesses(
- chrome::kBrowserProcessExecutableName, kExitTimeoutMs, kExitCode,
- &filter);
+ TerminateAllChromeProcesses(FilePath::FromWStringHack(user_data_dir()));
// Suppress spammy failures that seem to be occurring when running
// the UI tests in single-process mode.
// TODO(jhughes): figure out why this is necessary at all, and fix it
- if (!in_process_renderer_) {
+ if (!in_process_renderer_)
AssertAppNotRunning(L"Unable to quit all browser processes.");
- }
#else
- // TODO(port): depends on BrowserProcessFilter.
+ // TODO(port): depends on chrome_process_util.
NOTIMPLEMENTED();
#endif
}
@@ -593,13 +586,13 @@ bool UITest::CrashAwareSleep(int time_out_ms) {
}
#if defined(OS_WIN)
-// TODO(port): Port BrowserProcessFilter and sort out one wstring/string issue.
+// TODO(port): Port GetRunningChromeProcesses and sort out one w/string issue.
/*static*/
int UITest::GetBrowserProcessCount() {
- BrowserProcessFilter filter(L"");
- return base::GetProcessCount(chrome::kBrowserProcessExecutableName,
- &filter);
+ FilePath data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &data_dir);
+ return GetRunningChromeProcesses(data_dir).size();
}
static DictionaryValue* LoadDictionaryValueFromPath(const FilePath& path) {
diff --git a/chrome/test/ui/ui_tests.vcproj b/chrome/test/ui/ui_tests.vcproj
index 48df244..ea13ea6 100644
--- a/chrome/test/ui/ui_tests.vcproj
+++ b/chrome/test/ui/ui_tests.vcproj
@@ -174,6 +174,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>
diff --git a/chrome/test/url_fetch_test/url_fetch_test.vcproj b/chrome/test/url_fetch_test/url_fetch_test.vcproj
index a704ff0..61906f1 100644
--- a/chrome/test/url_fetch_test/url_fetch_test.vcproj
+++ b/chrome/test/url_fetch_test/url_fetch_test.vcproj
@@ -174,6 +174,18 @@
>
</File>
<File
+ RelativePath="..\chrome_process_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util.h"
+ >
+ </File>
+ <File
+ RelativePath="..\chrome_process_util_win.cc"
+ >
+ </File>
+ <File
RelativePath="..\testing_browser_process.h"
>
</File>