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 20 matching lines...) Expand all Loading... |
31 OPERA_BROWSER, | 31 OPERA_BROWSER, |
32 SAFARI_BROWSER, | 32 SAFARI_BROWSER, |
33 IE_64BIT_BROWSER, | 33 IE_64BIT_BROWSER, |
34 KONQUEROR_BROWSER, | 34 KONQUEROR_BROWSER, |
35 MAX_BROWSERS | 35 MAX_BROWSERS |
36 } BrowserProcess; | 36 } BrowserProcess; |
37 | 37 |
38 MemoryDetails::MemoryDetails() | 38 MemoryDetails::MemoryDetails() |
39 : user_metrics_mode_(UPDATE_USER_METRICS) { | 39 : user_metrics_mode_(UPDATE_USER_METRICS) { |
40 static const std::wstring google_browser_name = | 40 static const std::wstring google_browser_name = |
41 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 41 base::UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
42 struct { | 42 struct { |
43 const wchar_t* name; | 43 const wchar_t* name; |
44 const wchar_t* process_name; | 44 const wchar_t* process_name; |
45 } process_template[MAX_BROWSERS] = { | 45 } process_template[MAX_BROWSERS] = { |
46 { google_browser_name.c_str(), L"chrome.exe", }, | 46 { google_browser_name.c_str(), L"chrome.exe", }, |
47 { google_browser_name.c_str(), L"nacl64.exe", }, | 47 { google_browser_name.c_str(), L"nacl64.exe", }, |
48 { L"IE", L"iexplore.exe", }, | 48 { L"IE", L"iexplore.exe", }, |
49 { L"Firefox", L"firefox.exe", }, | 49 { L"Firefox", L"firefox.exe", }, |
50 { L"Opera", L"opera.exe", }, | 50 { L"Opera", L"opera.exe", }, |
51 { L"Safari", L"safari.exe", }, | 51 { L"Safari", L"safari.exe", }, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = base::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.type = child_info[child].type; |
133 break; | 133 break; |
134 } | 134 } |
135 } else if (GetModuleFileNameEx(process_handle, NULL, name, | 135 } else if (GetModuleFileNameEx(process_handle, NULL, name, |
(...skipping 16 matching lines...) Expand all Loading... |
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 |