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 "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "chrome/browser/child_process_host.h" | 11 #include "chrome/browser/child_process_host.h" |
12 #include "chrome/browser/chrome_thread.h" | 12 #include "chrome/browser/chrome_thread.h" |
13 #include "chrome/browser/renderer_host/backing_store_manager.h" | 13 #include "chrome/browser/renderer_host/backing_store_manager.h" |
14 #include "chrome/browser/renderer_host/render_process_host.h" | 14 #include "chrome/browser/renderer_host/render_process_host.h" |
15 #include "chrome/browser/tab_contents/navigation_entry.h" | 15 #include "chrome/browser/tab_contents/navigation_entry.h" |
16 #include "chrome/browser/tab_contents/tab_contents.h" | 16 #include "chrome/browser/tab_contents/tab_contents.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
19 | 19 |
20 // Known browsers which we collect details for. | 20 // Known browsers which we collect details for. |
21 enum { | 21 enum { |
22 CHROME_BROWSER = 0, | 22 CHROME_BROWSER = 0, |
| 23 CHROME_NACL_PROCESS, |
23 IE_BROWSER, | 24 IE_BROWSER, |
24 FIREFOX_BROWSER, | 25 FIREFOX_BROWSER, |
25 OPERA_BROWSER, | 26 OPERA_BROWSER, |
26 SAFARI_BROWSER, | 27 SAFARI_BROWSER, |
27 IE_64BIT_BROWSER, | 28 IE_64BIT_BROWSER, |
28 KONQUEROR_BROWSER, | 29 KONQUEROR_BROWSER, |
29 MAX_BROWSERS | 30 MAX_BROWSERS |
30 } BrowserProcess; | 31 } BrowserProcess; |
31 | 32 |
32 // Template of static data we use for finding browser process information. | 33 // Template of static data we use for finding browser process information. |
33 // These entries must match the ordering for MemoryDetails::BrowserProcess. | 34 // These entries must match the ordering for MemoryDetails::BrowserProcess. |
34 static ProcessData g_process_template[MAX_BROWSERS]; | 35 static ProcessData g_process_template[MAX_BROWSERS]; |
35 | 36 |
36 MemoryDetails::MemoryDetails() { | 37 MemoryDetails::MemoryDetails() { |
37 static const std::wstring google_browser_name = | 38 static const std::wstring google_browser_name = |
38 l10n_util::GetString(IDS_PRODUCT_NAME); | 39 l10n_util::GetString(IDS_PRODUCT_NAME); |
39 ProcessData g_process_template[MAX_BROWSERS] = { | 40 ProcessData g_process_template[MAX_BROWSERS] = { |
40 { google_browser_name.c_str(), L"chrome.exe", }, | 41 { google_browser_name.c_str(), L"chrome.exe", }, |
| 42 { google_browser_name.c_str(), L"nacl64.exe", }, |
41 { L"IE", L"iexplore.exe", }, | 43 { L"IE", L"iexplore.exe", }, |
42 { L"Firefox", L"firefox.exe", }, | 44 { L"Firefox", L"firefox.exe", }, |
43 { L"Opera", L"opera.exe", }, | 45 { L"Opera", L"opera.exe", }, |
44 { L"Safari", L"safari.exe", }, | 46 { L"Safari", L"safari.exe", }, |
45 { L"IE (64bit)", L"iexplore.exe", }, | 47 { L"IE (64bit)", L"iexplore.exe", }, |
46 { L"Konqueror", L"konqueror.exe", }, | 48 { L"Konqueror", L"konqueror.exe", }, |
47 }; | 49 }; |
48 | 50 |
49 for (int index = 0; index < arraysize(g_process_template); ++index) { | 51 for (int index = 0; index < arraysize(g_process_template); ++index) { |
50 ProcessData process; | 52 ProcessData process; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 else | 112 else |
111 info.type = ChildProcessInfo::UNKNOWN_PROCESS; | 113 info.type = ChildProcessInfo::UNKNOWN_PROCESS; |
112 | 114 |
113 scoped_ptr<base::ProcessMetrics> metrics; | 115 scoped_ptr<base::ProcessMetrics> metrics; |
114 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(handle)); | 116 metrics.reset(base::ProcessMetrics::CreateProcessMetrics(handle)); |
115 metrics->GetCommittedKBytes(&info.committed); | 117 metrics->GetCommittedKBytes(&info.committed); |
116 metrics->GetWorkingSetKBytes(&info.working_set); | 118 metrics->GetWorkingSetKBytes(&info.working_set); |
117 | 119 |
118 // Get Version Information. | 120 // Get Version Information. |
119 TCHAR name[MAX_PATH]; | 121 TCHAR name[MAX_PATH]; |
120 if (index2 == CHROME_BROWSER) { | 122 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { |
121 scoped_ptr<FileVersionInfo> version_info( | 123 scoped_ptr<FileVersionInfo> version_info( |
122 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 124 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
123 if (version_info != NULL) | 125 if (version_info != NULL) |
124 info.version = version_info->file_version(); | 126 info.version = version_info->file_version(); |
125 // Check if this is one of the child processes whose data we collected | 127 // Check if this is one of the child processes whose data we collected |
126 // on the IO thread, and if so copy over that data. | 128 // on the IO thread, and if so copy over that data. |
127 for (size_t child = 0; child < child_info.size(); child++) { | 129 for (size_t child = 0; child < child_info.size(); child++) { |
128 if (child_info[child].pid != info.pid) | 130 if (child_info[child].pid != info.pid) |
129 continue; | 131 continue; |
130 info.titles = child_info[child].titles; | 132 info.titles = child_info[child].titles; |
131 info.type = child_info[child].type; | 133 info.type = child_info[child].type; |
132 break; | 134 break; |
133 } | 135 } |
134 } else if (GetModuleFileNameEx(handle, NULL, name, MAX_PATH - 1)) { | 136 } else if (GetModuleFileNameEx(handle, NULL, name, MAX_PATH - 1)) { |
135 std::wstring str_name(name); | 137 std::wstring str_name(name); |
136 scoped_ptr<FileVersionInfo> version_info( | 138 scoped_ptr<FileVersionInfo> version_info( |
137 FileVersionInfo::CreateFileVersionInfo(str_name)); | 139 FileVersionInfo::CreateFileVersionInfo(str_name)); |
138 if (version_info != NULL) { | 140 if (version_info != NULL) { |
139 info.version = version_info->product_version(); | 141 info.version = version_info->product_version(); |
140 info.product_name = version_info->product_name(); | 142 info.product_name = version_info->product_name(); |
141 } | 143 } |
142 } | 144 } |
143 | 145 |
144 // Add the process info to our list. | 146 // Add the process info to our list. |
145 process_data_[index2].processes.push_back(info); | 147 if (index2 == CHROME_NACL_PROCESS) { |
| 148 // Add NaCl processes to Chrome's list |
| 149 process_data_[CHROME_BROWSER].processes.push_back(info); |
| 150 } else { |
| 151 process_data_[index2].processes.push_back(info); |
| 152 } |
146 break; | 153 break; |
147 } | 154 } |
148 } while (::Process32Next(snapshot, &process_entry)); | 155 } while (::Process32Next(snapshot, &process_entry)); |
149 | 156 |
150 // Finally return to the browser thread. | 157 // Finally return to the browser thread. |
151 ChromeThread::PostTask( | 158 ChromeThread::PostTask( |
152 ChromeThread::UI, FROM_HERE, | 159 ChromeThread::UI, FROM_HERE, |
153 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); | 160 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); |
154 } | 161 } |
OLD | NEW |