OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_version_info.h" | 10 #include "base/file_version_info.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { | 101 for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { |
102 if (_wcsicmp(process_data_[index2].process_name.c_str(), | 102 if (_wcsicmp(process_data_[index2].process_name.c_str(), |
103 process_entry.szExeFile) != 0) | 103 process_entry.szExeFile) != 0) |
104 continue; | 104 continue; |
105 if (index2 == IE_BROWSER && is_64bit_process) | 105 if (index2 == IE_BROWSER && is_64bit_process) |
106 continue; // Should use IE_64BIT_BROWSER | 106 continue; // Should use IE_64BIT_BROWSER |
107 // Get Memory Information. | 107 // Get Memory Information. |
108 ProcessMemoryInformation info; | 108 ProcessMemoryInformation info; |
109 info.pid = pid; | 109 info.pid = pid; |
110 if (info.pid == GetCurrentProcessId()) | 110 if (info.pid == GetCurrentProcessId()) |
111 info.type = content::PROCESS_TYPE_BROWSER; | 111 info.process_type = content::PROCESS_TYPE_BROWSER; |
112 else | 112 else |
113 info.type = content::PROCESS_TYPE_UNKNOWN; | 113 info.process_type = content::PROCESS_TYPE_UNKNOWN; |
114 | 114 |
115 scoped_ptr<base::ProcessMetrics> metrics; | 115 scoped_ptr<base::ProcessMetrics> metrics; |
116 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(process_handle)); | 116 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(process_handle)); |
117 metrics->GetCommittedKBytes(&info.committed); | 117 metrics->GetCommittedKBytes(&info.committed); |
118 metrics->GetWorkingSetKBytes(&info.working_set); | 118 metrics->GetWorkingSetKBytes(&info.working_set); |
119 | 119 |
120 // Get Version Information. | 120 // Get Version Information. |
121 TCHAR name[MAX_PATH]; | 121 TCHAR name[MAX_PATH]; |
122 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { | 122 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { |
123 chrome::VersionInfo version_info; | 123 chrome::VersionInfo version_info; |
124 if (version_info.is_valid()) | 124 if (version_info.is_valid()) |
125 info.version = ASCIIToWide(version_info.Version()); | 125 info.version = ASCIIToWide(version_info.Version()); |
126 // Check if this is one of the child processes whose data we collected | 126 // Check if this is one of the child processes whose data we collected |
127 // on the IO thread, and if so copy over that data. | 127 // on the IO thread, and if so copy over that data. |
128 for (size_t child = 0; child < child_info.size(); child++) { | 128 for (size_t child = 0; child < child_info.size(); child++) { |
129 if (child_info[child].pid != info.pid) | 129 if (child_info[child].pid != info.pid) |
130 continue; | 130 continue; |
131 info.titles = child_info[child].titles; | 131 info.titles = child_info[child].titles; |
132 info.type = child_info[child].type; | 132 info.process_type = child_info[child].process_type; |
133 break; | 133 break; |
134 } | 134 } |
135 } else if (GetModuleFileNameEx(process_handle, NULL, name, | 135 } else if (GetModuleFileNameEx(process_handle, NULL, name, |
136 MAX_PATH - 1)) { | 136 MAX_PATH - 1)) { |
137 std::wstring str_name(name); | 137 std::wstring str_name(name); |
138 scoped_ptr<FileVersionInfo> version_info( | 138 scoped_ptr<FileVersionInfo> version_info( |
139 FileVersionInfo::CreateFileVersionInfo(base::FilePath(str_name))); | 139 FileVersionInfo::CreateFileVersionInfo(base::FilePath(str_name))); |
140 if (version_info != NULL) { | 140 if (version_info != NULL) { |
141 info.version = version_info->product_version(); | 141 info.version = version_info->product_version(); |
142 info.product_name = version_info->product_name(); | 142 info.product_name = version_info->product_name(); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 // Add the process info to our list. | 146 // Add the process info to our list. |
147 if (index2 == CHROME_NACL_PROCESS) { | 147 if (index2 == CHROME_NACL_PROCESS) { |
148 // Add NaCl processes to Chrome's list | 148 // Add NaCl processes to Chrome's list |
149 process_data_[CHROME_BROWSER].processes.push_back(info); | 149 process_data_[CHROME_BROWSER].processes.push_back(info); |
150 } else { | 150 } else { |
151 process_data_[index2].processes.push_back(info); | 151 process_data_[index2].processes.push_back(info); |
152 } | 152 } |
153 break; | 153 break; |
154 } | 154 } |
155 } while (::Process32Next(snapshot, &process_entry)); | 155 } while (::Process32Next(snapshot, &process_entry)); |
156 | 156 |
157 // Finally return to the browser thread. | 157 // Finally return to the browser thread. |
158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
159 BrowserThread::UI, FROM_HERE, | 159 BrowserThread::UI, FROM_HERE, |
160 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 160 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
161 } | 161 } |
OLD | NEW |