OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" |
7 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
9 #include "base/process_util.h" | 10 #include "base/process_util.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/browser_child_process_host.h" | 13 #include "chrome/browser/browser_child_process_host.h" |
13 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/renderer_host/backing_store_manager.h" | 15 #include "chrome/browser/renderer_host/backing_store_manager.h" |
15 #include "chrome/browser/renderer_host/render_process_host.h" | 16 #include "chrome/browser/renderer_host/render_process_host.h" |
16 #include "chrome/browser/renderer_host/render_view_host.h" | 17 #include "chrome/browser/renderer_host/render_view_host.h" |
17 #include "chrome/browser/tab_contents/navigation_entry.h" | 18 #include "chrome/browser/tab_contents/navigation_entry.h" |
18 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
20 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
| 22 #include "grit/generated_resources.h" |
21 | 23 |
22 #if defined(OS_LINUX) | 24 #if defined(OS_LINUX) |
23 #include "chrome/browser/zygote_host_linux.h" | 25 #include "chrome/browser/zygote_host_linux.h" |
24 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" | 26 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |
25 #endif | 27 #endif |
26 | 28 |
27 ProcessMemoryInformation::ProcessMemoryInformation() | 29 ProcessMemoryInformation::ProcessMemoryInformation() |
28 : pid(0), | 30 : pid(0), |
29 num_processes(0), | 31 num_processes(0), |
30 is_diagnostics(false), | 32 is_diagnostics(false), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 std::vector<ProcessMemoryInformation> child_info; | 83 std::vector<ProcessMemoryInformation> child_info; |
82 | 84 |
83 // Collect the list of child processes. | 85 // Collect the list of child processes. |
84 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { | 86 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { |
85 ProcessMemoryInformation info; | 87 ProcessMemoryInformation info; |
86 info.pid = base::GetProcId(iter->handle()); | 88 info.pid = base::GetProcId(iter->handle()); |
87 if (!info.pid) | 89 if (!info.pid) |
88 continue; | 90 continue; |
89 | 91 |
90 info.type = iter->type(); | 92 info.type = iter->type(); |
91 info.titles.push_back(iter->name()); | 93 info.titles.push_back(WideToUTF16Hack(iter->name())); |
92 child_info.push_back(info); | 94 child_info.push_back(info); |
93 } | 95 } |
94 | 96 |
95 // Now go do expensive memory lookups from the file thread. | 97 // Now go do expensive memory lookups from the file thread. |
96 BrowserThread::PostTask( | 98 BrowserThread::PostTask( |
97 BrowserThread::FILE, FROM_HERE, | 99 BrowserThread::FILE, FROM_HERE, |
98 NewRunnableMethod(this, &MemoryDetails::CollectProcessData, child_info)); | 100 NewRunnableMethod(this, &MemoryDetails::CollectProcessData, child_info)); |
99 } | 101 } |
100 | 102 |
101 void MemoryDetails::CollectChildInfoOnUIThread() { | 103 void MemoryDetails::CollectChildInfoOnUIThread() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 DCHECK(widget); | 144 DCHECK(widget); |
143 if (!widget || !widget->IsRenderView()) | 145 if (!widget || !widget->IsRenderView()) |
144 continue; | 146 continue; |
145 | 147 |
146 const RenderViewHost* host = static_cast<const RenderViewHost*>(widget); | 148 const RenderViewHost* host = static_cast<const RenderViewHost*>(widget); |
147 TabContents* contents = NULL; | 149 TabContents* contents = NULL; |
148 if (host->delegate()) | 150 if (host->delegate()) |
149 contents = host->delegate()->GetAsTabContents(); | 151 contents = host->delegate()->GetAsTabContents(); |
150 if (!contents) | 152 if (!contents) |
151 continue; | 153 continue; |
152 std::wstring title = UTF16ToWideHack(contents->GetTitle()); | 154 string16 title = contents->GetTitle(); |
153 if (!title.length()) | 155 if (!title.length()) |
154 title = L"Untitled"; | 156 title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); |
155 process.titles.push_back(title); | 157 process.titles.push_back(title); |
156 | 158 |
157 // We need to check the pending entry as well as the virtual_url to | 159 // We need to check the pending entry as well as the virtual_url to |
158 // see if it's an about:memory URL (we don't want to count these in the | 160 // see if it's an about:memory URL (we don't want to count these in the |
159 // total memory usage of the browser). | 161 // total memory usage of the browser). |
160 // | 162 // |
161 // When we reach here, about:memory will be the pending entry since we | 163 // When we reach here, about:memory will be the pending entry since we |
162 // haven't responded with any data such that it would be committed. If | 164 // haven't responded with any data such that it would be committed. If |
163 // you have another about:memory tab open (which would be committed), | 165 // you have another about:memory tab open (which would be committed), |
164 // we don't want to count it either, so we also check the last committed | 166 // we don't want to count it either, so we also check the last committed |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", | 260 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", |
259 static_cast<int>(browser.processes.size())); | 261 static_cast<int>(browser.processes.size())); |
260 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); | 262 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); |
261 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 263 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
262 // TODO(viettrungluu): Do we want separate counts for the other | 264 // TODO(viettrungluu): Do we want separate counts for the other |
263 // (platform-specific) process types? | 265 // (platform-specific) process types? |
264 | 266 |
265 int total_sample = static_cast<int>(aggregate_memory / 1000); | 267 int total_sample = static_cast<int>(aggregate_memory / 1000); |
266 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 268 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
267 } | 269 } |
OLD | NEW |