summaryrefslogtreecommitdiffstats
path: root/chrome/test/memory_test
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-09 22:44:57 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-09 22:44:57 +0000
commit6aa9349ef5c1110d9c096945840e6a105e8a8295 (patch)
tree8afce0e1f3aae77e05105cfbe0d24ea3bdae9106 /chrome/test/memory_test
parentb61236c6679615af0811d59d130c91397d8c6be7 (diff)
downloadchromium_src-6aa9349ef5c1110d9c096945840e6a105e8a8295.zip
chromium_src-6aa9349ef5c1110d9c096945840e6a105e8a8295.tar.gz
chromium_src-6aa9349ef5c1110d9c096945840e6a105e8a8295.tar.bz2
Replace chrome_process_filter with chrome_process_util.
- move code only used by tests to chrome/test - make a better, more portable abstraction For now, it still only works on Windows. But this is the first step to porting this part of code. Patch by phajdan.jr@chromium.org: <http://codereview.chromium.org/54003> Review URL: http://codereview.chromium.org/67004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/memory_test')
-rw-r--r--chrome/test/memory_test/memory_test.cc49
-rw-r--r--chrome/test/memory_test/memory_test.vcproj12
2 files changed, 34 insertions, 27 deletions
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>