OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/memory_details.h" | 5 #include "chrome/browser/memory_details.h" |
6 | 6 |
7 #include <psapi.h> | 7 #include <psapi.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/win/scoped_handle.h" | 13 #include "base/win/scoped_handle.h" |
| 14 #include "base/win/windows_version.h" |
14 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
16 #include "content/browser/browser_child_process_host.h" | 17 #include "content/browser/browser_child_process_host.h" |
17 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
18 #include "content/browser/renderer_host/backing_store_manager.h" | 19 #include "content/browser/renderer_host/backing_store_manager.h" |
19 #include "content/browser/renderer_host/render_process_host.h" | 20 #include "content/browser/renderer_host/render_process_host.h" |
20 #include "content/browser/tab_contents/navigation_entry.h" | 21 #include "content/browser/tab_contents/navigation_entry.h" |
21 #include "grit/chromium_strings.h" | 22 #include "grit/chromium_strings.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 | 24 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (!::Process32First(snapshot, &process_entry)) { | 87 if (!::Process32First(snapshot, &process_entry)) { |
87 LOG(ERROR) << "Process32First failed: " << GetLastError(); | 88 LOG(ERROR) << "Process32First failed: " << GetLastError(); |
88 return; | 89 return; |
89 } | 90 } |
90 do { | 91 do { |
91 base::ProcessId pid = process_entry.th32ProcessID; | 92 base::ProcessId pid = process_entry.th32ProcessID; |
92 base::win::ScopedHandle handle(::OpenProcess( | 93 base::win::ScopedHandle handle(::OpenProcess( |
93 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); | 94 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); |
94 if (!handle.Get()) | 95 if (!handle.Get()) |
95 continue; | 96 continue; |
96 bool is_64bit_process = false; | 97 bool is_64bit_process = is_64bit_os && |
97 // IsWow64Process() returns FALSE for a 32bit process on a 32bit OS. | 98 (base::win::GetWOW64StatusForHandle(handle) == |
98 // We need to check if the real OS is 64bit. | 99 base::win::WOW64_DISABLED); |
99 if (is_64bit_os) { | |
100 BOOL is_wow64 = FALSE; | |
101 // IsWow64Process() is supported by Windows XP SP2 or later. | |
102 IsWow64Process(handle, &is_wow64); | |
103 is_64bit_process = !is_wow64; | |
104 } | |
105 for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { | 100 for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { |
106 if (_wcsicmp(process_data_[index2].process_name.c_str(), | 101 if (_wcsicmp(process_data_[index2].process_name.c_str(), |
107 process_entry.szExeFile) != 0) | 102 process_entry.szExeFile) != 0) |
108 continue; | 103 continue; |
109 if (index2 == IE_BROWSER && is_64bit_process) | 104 if (index2 == IE_BROWSER && is_64bit_process) |
110 continue; // Should use IE_64BIT_BROWSER | 105 continue; // Should use IE_64BIT_BROWSER |
111 // Get Memory Information. | 106 // Get Memory Information. |
112 ProcessMemoryInformation info; | 107 ProcessMemoryInformation info; |
113 info.pid = pid; | 108 info.pid = pid; |
114 if (info.pid == GetCurrentProcessId()) | 109 if (info.pid == GetCurrentProcessId()) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 150 } |
156 break; | 151 break; |
157 } | 152 } |
158 } while (::Process32Next(snapshot, &process_entry)); | 153 } while (::Process32Next(snapshot, &process_entry)); |
159 | 154 |
160 // Finally return to the browser thread. | 155 // Finally return to the browser thread. |
161 BrowserThread::PostTask( | 156 BrowserThread::PostTask( |
162 BrowserThread::UI, FROM_HERE, | 157 BrowserThread::UI, FROM_HERE, |
163 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); | 158 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); |
164 } | 159 } |
OLD | NEW |