| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 ProcessInfoSnapshot process_info; | 140 ProcessInfoSnapshot process_info; |
| 141 process_info.Sample(all_pids); | 141 process_info.Sample(all_pids); |
| 142 | 142 |
| 143 // Handle the other processes first. | 143 // Handle the other processes first. |
| 144 for (size_t index = CHROME_BROWSER + 1; index < MAX_BROWSERS; index++) { | 144 for (size_t index = CHROME_BROWSER + 1; index < MAX_BROWSERS; index++) { |
| 145 for (std::vector<base::ProcessId>::const_iterator it = | 145 for (std::vector<base::ProcessId>::const_iterator it = |
| 146 pids_by_browser[index].begin(); | 146 pids_by_browser[index].begin(); |
| 147 it != pids_by_browser[index].end(); ++it) { | 147 it != pids_by_browser[index].end(); ++it) { |
| 148 ProcessMemoryInformation info; | 148 ProcessMemoryInformation info; |
| 149 info.pid = *it; | 149 info.pid = *it; |
| 150 info.type = content::PROCESS_TYPE_UNKNOWN; | 150 info.process_type = content::PROCESS_TYPE_UNKNOWN; |
| 151 | 151 |
| 152 // Try to get version information. To do this, we need first to get the | 152 // Try to get version information. To do this, we need first to get the |
| 153 // executable's name (we can only believe |proc_info.command| if it looks | 153 // executable's name (we can only believe |proc_info.command| if it looks |
| 154 // like an absolute path). Then we need strip the executable's name back | 154 // like an absolute path). Then we need strip the executable's name back |
| 155 // to the bundle's name. And only then can we try to get the version. | 155 // to the bundle's name. And only then can we try to get the version. |
| 156 scoped_ptr<FileVersionInfo> version_info; | 156 scoped_ptr<FileVersionInfo> version_info; |
| 157 ProcessInfoSnapshot::ProcInfoEntry proc_info; | 157 ProcessInfoSnapshot::ProcInfoEntry proc_info; |
| 158 if (process_info.GetProcInfo(info.pid, &proc_info)) { | 158 if (process_info.GetProcInfo(info.pid, &proc_info)) { |
| 159 if (proc_info.command.length() > 1 && proc_info.command[0] == '/') { | 159 if (proc_info.command.length() > 1 && proc_info.command[0] == '/') { |
| 160 base::FilePath bundle_name = | 160 base::FilePath bundle_name = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 201 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void MemoryDetails::CollectProcessDataChrome( | 204 void MemoryDetails::CollectProcessDataChrome( |
| 205 const std::vector<ProcessMemoryInformation>& child_info, | 205 const std::vector<ProcessMemoryInformation>& child_info, |
| 206 base::ProcessId pid, | 206 base::ProcessId pid, |
| 207 const ProcessInfoSnapshot& process_info) { | 207 const ProcessInfoSnapshot& process_info) { |
| 208 ProcessMemoryInformation info; | 208 ProcessMemoryInformation info; |
| 209 info.pid = pid; | 209 info.pid = pid; |
| 210 if (info.pid == base::GetCurrentProcId()) | 210 if (info.pid == base::GetCurrentProcId()) |
| 211 info.type = content::PROCESS_TYPE_BROWSER; | 211 info.process_type = content::PROCESS_TYPE_BROWSER; |
| 212 else | 212 else |
| 213 info.type = content::PROCESS_TYPE_UNKNOWN; | 213 info.process_type = content::PROCESS_TYPE_UNKNOWN; |
| 214 | 214 |
| 215 chrome::VersionInfo version_info; | 215 chrome::VersionInfo version_info; |
| 216 if (version_info.is_valid()) { | 216 if (version_info.is_valid()) { |
| 217 info.product_name = ASCIIToUTF16(version_info.Name()); | 217 info.product_name = ASCIIToUTF16(version_info.Name()); |
| 218 info.version = ASCIIToUTF16(version_info.Version()); | 218 info.version = ASCIIToUTF16(version_info.Version()); |
| 219 } else { | 219 } else { |
| 220 info.product_name = process_data_[CHROME_BROWSER].name; | 220 info.product_name = process_data_[CHROME_BROWSER].name; |
| 221 info.version = string16(); | 221 info.version = string16(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Check if this is one of the child processes whose data we collected | 224 // Check if this is one of the child processes whose data we collected |
| 225 // on the IO thread, and if so copy over that data. | 225 // on the IO thread, and if so copy over that data. |
| 226 for (size_t child = 0; child < child_info.size(); child++) { | 226 for (size_t child = 0; child < child_info.size(); child++) { |
| 227 if (child_info[child].pid == info.pid) { | 227 if (child_info[child].pid == info.pid) { |
| 228 info.titles = child_info[child].titles; | 228 info.titles = child_info[child].titles; |
| 229 info.type = child_info[child].type; | 229 info.process_type = child_info[child].process_type; |
| 230 break; | 230 break; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 // Memory info. | 234 // Memory info. |
| 235 process_info.GetCommittedKBytesOfPID(info.pid, &info.committed); | 235 process_info.GetCommittedKBytesOfPID(info.pid, &info.committed); |
| 236 process_info.GetWorkingSetKBytesOfPID(info.pid, &info.working_set); | 236 process_info.GetWorkingSetKBytesOfPID(info.pid, &info.working_set); |
| 237 | 237 |
| 238 // Add the process info to our list. | 238 // Add the process info to our list. |
| 239 process_data_[CHROME_BROWSER].processes.push_back(info); | 239 process_data_[CHROME_BROWSER].processes.push_back(info); |
| 240 } | 240 } |
| OLD | NEW |