| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <psapi.h> | 6 #include <psapi.h> |
| 7 | 7 |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/image_util.h" | 10 #include "base/image_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // Collect the list of plugins. | 73 // Collect the list of plugins. |
| 74 for (PluginProcessHostIterator plugin_iter; | 74 for (PluginProcessHostIterator plugin_iter; |
| 75 !plugin_iter.Done(); ++plugin_iter) { | 75 !plugin_iter.Done(); ++plugin_iter) { |
| 76 PluginProcessHost* plugin = const_cast<PluginProcessHost*>(*plugin_iter); | 76 PluginProcessHost* plugin = const_cast<PluginProcessHost*>(*plugin_iter); |
| 77 DCHECK(plugin); | 77 DCHECK(plugin); |
| 78 if (!plugin || !plugin->process()) | 78 if (!plugin || !plugin->process()) |
| 79 continue; | 79 continue; |
| 80 | 80 |
| 81 PluginProcessInformation info; | 81 PluginProcessInformation info; |
| 82 info.pid = process_util::GetProcId(plugin->process()); | 82 info.pid = base::GetProcId(plugin->process()); |
| 83 if (info.pid != 0) { | 83 if (info.pid != 0) { |
| 84 info.dll_path = plugin->dll_path(); | 84 info.dll_path = plugin->dll_path(); |
| 85 plugins_.push_back(info); | 85 plugins_.push_back(info); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Now go do expensive memory lookups from the file thread. | 89 // Now go do expensive memory lookups from the file thread. |
| 90 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE, | 90 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE, |
| 91 NewRunnableMethod(this, &MemoryDetails::CollectProcessData)); | 91 NewRunnableMethod(this, &MemoryDetails::CollectProcessData)); |
| 92 } | 92 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 122 HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, | 122 HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, |
| 123 FALSE, process_list[index]); | 123 FALSE, process_list[index]); |
| 124 if (handle) { | 124 if (handle) { |
| 125 TCHAR name[MAX_PATH]; | 125 TCHAR name[MAX_PATH]; |
| 126 if (GetModuleBaseName(handle, NULL, name, MAX_PATH-1)) { | 126 if (GetModuleBaseName(handle, NULL, name, MAX_PATH-1)) { |
| 127 for (int index2 = 0; index2 < arraysize(g_process_template); index2++) { | 127 for (int index2 = 0; index2 < arraysize(g_process_template); index2++) { |
| 128 if (_wcsicmp(process_data_[index2].process_name, name) == 0) { | 128 if (_wcsicmp(process_data_[index2].process_name, name) == 0) { |
| 129 // Get Memory Information. | 129 // Get Memory Information. |
| 130 ProcessMemoryInformation info; | 130 ProcessMemoryInformation info; |
| 131 info.pid = process_list[index]; | 131 info.pid = process_list[index]; |
| 132 scoped_ptr<process_util::ProcessMetrics> metrics; | 132 scoped_ptr<base::ProcessMetrics> metrics; |
| 133 metrics.reset( | 133 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(handle)); |
| 134 process_util::ProcessMetrics::CreateProcessMetrics(handle)); | |
| 135 metrics->GetCommittedKBytes(&info.committed); | 134 metrics->GetCommittedKBytes(&info.committed); |
| 136 metrics->GetWorkingSetKBytes(&info.working_set); | 135 metrics->GetWorkingSetKBytes(&info.working_set); |
| 137 | 136 |
| 138 // Get Version Information. | 137 // Get Version Information. |
| 139 if (index2 == 0) { // Chrome | 138 if (index2 == 0) { // Chrome |
| 140 scoped_ptr<FileVersionInfo> version_info( | 139 scoped_ptr<FileVersionInfo> version_info( |
| 141 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 140 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
| 142 if (version_info != NULL) | 141 if (version_info != NULL) |
| 143 info.version = version_info->file_version(); | 142 info.version = version_info->file_version(); |
| 144 } else if (GetModuleFileNameEx(handle, NULL, name, MAX_PATH-1)) { | 143 } else if (GetModuleFileNameEx(handle, NULL, name, MAX_PATH-1)) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 if (trial.get()) { | 272 if (trial.get()) { |
| 274 if (trial->boolean_value()) | 273 if (trial->boolean_value()) |
| 275 UMA_HISTOGRAM_MEMORY_MB(L"Memory.Total_trial_high_memory", total_sample); | 274 UMA_HISTOGRAM_MEMORY_MB(L"Memory.Total_trial_high_memory", total_sample); |
| 276 else | 275 else |
| 277 UMA_HISTOGRAM_MEMORY_MB(L"Memory.Total_trial_med_memory", total_sample); | 276 UMA_HISTOGRAM_MEMORY_MB(L"Memory.Total_trial_med_memory", total_sample); |
| 278 } else { | 277 } else { |
| 279 UMA_HISTOGRAM_MEMORY_MB(L"Memory.Total", total_sample); | 278 UMA_HISTOGRAM_MEMORY_MB(L"Memory.Total", total_sample); |
| 280 } | 279 } |
| 281 } | 280 } |
| 282 | 281 |
| OLD | NEW |