| Index: chrome/test/memory_test/memory_test.cc
|
| diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc
|
| index b43735378ab7712989fb15080ce473afc3b05459..51be538427c8da02ecbff23559d9922f96d3fd63 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, ¤t_virtual_size,
|
| + if (GetMemoryInfo(*it, &peak_virtual_size, ¤t_virtual_size,
|
| &peak_working_set_size, ¤t_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;
|
| }
|
|
|