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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_version_info.h" | 11 #include "base/file_version_info.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
15 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
16 #include "chrome/common/chrome_version_info.h" | 16 #include "chrome/common/chrome_version_info.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "content/browser/browser_child_process_host.h" | 18 #include "content/browser/browser_child_process_host.h" |
19 #include "content/browser/renderer_host/backing_store_manager.h" | 19 #include "content/browser/renderer_host/backing_store_manager.h" |
20 #include "content/browser/tab_contents/navigation_entry.h" | 20 #include "content/browser/tab_contents/navigation_entry.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/common/process_type.h" |
22 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 | 25 |
25 using content::BrowserThread; | 26 using content::BrowserThread; |
26 | 27 |
27 // Known browsers which we collect details for. | 28 // Known browsers which we collect details for. |
28 enum { | 29 enum { |
29 CHROME_BROWSER = 0, | 30 CHROME_BROWSER = 0, |
30 CHROME_NACL_PROCESS, | 31 CHROME_NACL_PROCESS, |
31 IE_BROWSER, | 32 IE_BROWSER, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { | 103 for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { |
103 if (_wcsicmp(process_data_[index2].process_name.c_str(), | 104 if (_wcsicmp(process_data_[index2].process_name.c_str(), |
104 process_entry.szExeFile) != 0) | 105 process_entry.szExeFile) != 0) |
105 continue; | 106 continue; |
106 if (index2 == IE_BROWSER && is_64bit_process) | 107 if (index2 == IE_BROWSER && is_64bit_process) |
107 continue; // Should use IE_64BIT_BROWSER | 108 continue; // Should use IE_64BIT_BROWSER |
108 // Get Memory Information. | 109 // Get Memory Information. |
109 ProcessMemoryInformation info; | 110 ProcessMemoryInformation info; |
110 info.pid = pid; | 111 info.pid = pid; |
111 if (info.pid == GetCurrentProcessId()) | 112 if (info.pid == GetCurrentProcessId()) |
112 info.type = ChildProcessInfo::BROWSER_PROCESS; | 113 info.type = content::PROCESS_TYPE_BROWSER; |
113 else | 114 else |
114 info.type = ChildProcessInfo::UNKNOWN_PROCESS; | 115 info.type = content::PROCESS_TYPE_UNKNOWN; |
115 | 116 |
116 scoped_ptr<base::ProcessMetrics> metrics; | 117 scoped_ptr<base::ProcessMetrics> metrics; |
117 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(process_handle)); | 118 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(process_handle)); |
118 metrics->GetCommittedKBytes(&info.committed); | 119 metrics->GetCommittedKBytes(&info.committed); |
119 metrics->GetWorkingSetKBytes(&info.working_set); | 120 metrics->GetWorkingSetKBytes(&info.working_set); |
120 | 121 |
121 // Get Version Information. | 122 // Get Version Information. |
122 TCHAR name[MAX_PATH]; | 123 TCHAR name[MAX_PATH]; |
123 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { | 124 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { |
124 chrome::VersionInfo version_info; | 125 chrome::VersionInfo version_info; |
(...skipping 28 matching lines...) Expand all Loading... |
153 } | 154 } |
154 break; | 155 break; |
155 } | 156 } |
156 } while (::Process32Next(snapshot, &process_entry)); | 157 } while (::Process32Next(snapshot, &process_entry)); |
157 | 158 |
158 // Finally return to the browser thread. | 159 // Finally return to the browser thread. |
159 BrowserThread::PostTask( | 160 BrowserThread::PostTask( |
160 BrowserThread::UI, FROM_HERE, | 161 BrowserThread::UI, FROM_HERE, |
161 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 162 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
162 } | 163 } |
OLD | NEW |