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 #include <TlHelp32.h> | 8 #include <TlHelp32.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/file_version_info.h" | 11 #include "base/file_version_info.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/win/scoped_handle.h" | 16 #include "base/win/scoped_handle.h" |
17 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
18 #include "chrome/common/chrome_version_info.h" | |
19 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
20 #include "chrome/grit/chromium_strings.h" | 19 #include "chrome/grit/chromium_strings.h" |
| 20 #include "components/version_info/version_info.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/common/process_type.h" | 22 #include "content/public/common/process_type.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 | 26 |
27 // Known browsers which we collect details for. | 27 // Known browsers which we collect details for. |
28 enum BrowserProcess { | 28 enum BrowserProcess { |
29 CHROME_BROWSER = 0, | 29 CHROME_BROWSER = 0, |
30 CHROME_NACL_PROCESS, | 30 CHROME_NACL_PROCESS, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 scoped_ptr<base::ProcessMetrics> metrics; | 124 scoped_ptr<base::ProcessMetrics> metrics; |
125 metrics.reset(base::ProcessMetrics::CreateProcessMetrics( | 125 metrics.reset(base::ProcessMetrics::CreateProcessMetrics( |
126 process_handle.Get())); | 126 process_handle.Get())); |
127 metrics->GetCommittedKBytes(&info.committed); | 127 metrics->GetCommittedKBytes(&info.committed); |
128 metrics->GetWorkingSetKBytes(&info.working_set); | 128 metrics->GetWorkingSetKBytes(&info.working_set); |
129 | 129 |
130 // Get Version Information. | 130 // Get Version Information. |
131 TCHAR name[MAX_PATH]; | 131 TCHAR name[MAX_PATH]; |
132 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { | 132 if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { |
133 chrome::VersionInfo version_info; | 133 info.version = base::ASCIIToUTF16(version_info::GetVersionNumber()); |
134 info.version = base::ASCIIToUTF16(version_info.Version()); | |
135 // Check if this is one of the child processes whose data we collected | 134 // Check if this is one of the child processes whose data we collected |
136 // on the IO thread, and if so copy over that data. | 135 // on the IO thread, and if so copy over that data. |
137 for (size_t child = 0; child < child_info.size(); child++) { | 136 for (size_t child = 0; child < child_info.size(); child++) { |
138 if (child_info[child].pid != info.pid) | 137 if (child_info[child].pid != info.pid) |
139 continue; | 138 continue; |
140 info.titles = child_info[child].titles; | 139 info.titles = child_info[child].titles; |
141 info.process_type = child_info[child].process_type; | 140 info.process_type = child_info[child].process_type; |
142 break; | 141 break; |
143 } | 142 } |
144 } else if (GetModuleFileNameEx(process_handle.Get(), NULL, name, | 143 } else if (GetModuleFileNameEx(process_handle.Get(), NULL, name, |
(...skipping 16 matching lines...) Expand all Loading... |
161 } | 160 } |
162 break; | 161 break; |
163 } | 162 } |
164 } while (::Process32Next(snapshot.Get(), &process_entry)); | 163 } while (::Process32Next(snapshot.Get(), &process_entry)); |
165 | 164 |
166 // Finally return to the browser thread. | 165 // Finally return to the browser thread. |
167 BrowserThread::PostTask( | 166 BrowserThread::PostTask( |
168 BrowserThread::UI, FROM_HERE, | 167 BrowserThread::UI, FROM_HERE, |
169 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 168 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
170 } | 169 } |
OLD | NEW |