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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 // have to be. | 199 // have to be. |
200 content::RenderProcessHost::listeners_iterator iter( | 200 content::RenderProcessHost::listeners_iterator iter( |
201 render_process_host->ListenersIterator()); | 201 render_process_host->ListenersIterator()); |
202 for (; !iter.IsAtEnd(); iter.Advance()) { | 202 for (; !iter.IsAtEnd(); iter.Advance()) { |
203 const RenderWidgetHost* widget = | 203 const RenderWidgetHost* widget = |
204 RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue()); | 204 RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue()); |
205 DCHECK(widget); | 205 DCHECK(widget); |
206 if (!widget || !widget->IsRenderView()) | 206 if (!widget || !widget->IsRenderView()) |
207 continue; | 207 continue; |
208 | 208 |
209 const RenderViewHost* host = static_cast<const RenderViewHost*>(widget); | 209 const RenderViewHost* host = static_cast<const RenderViewHostImpl*>( |
210 content::RenderViewHostDelegate* host_delegate = host->delegate(); | 210 const_cast<RenderWidgetHost*>(widget)->AsRWHImpl()); |
jam
2012/02/29 01:40:47
nit: i guess this (and other usage in chrome) is a
Jói
2012/03/02 10:40:36
Ah, this was an oversight. Once I move RenderWidg
| |
211 content::RenderViewHostDelegate* host_delegate = host->GetDelegate(); | |
211 DCHECK(host_delegate); | 212 DCHECK(host_delegate); |
212 GURL url = host_delegate->GetURL(); | 213 GURL url = host_delegate->GetURL(); |
213 content::ViewType type = host_delegate->GetRenderViewType(); | 214 content::ViewType type = host_delegate->GetRenderViewType(); |
214 if (host->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI) { | 215 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { |
215 // TODO(erikkay) the type for devtools doesn't actually appear to | 216 // TODO(erikkay) the type for devtools doesn't actually appear to |
216 // be set. | 217 // be set. |
217 if (type == content::VIEW_TYPE_DEV_TOOLS_UI) | 218 if (type == content::VIEW_TYPE_DEV_TOOLS_UI) |
218 process.renderer_type = ProcessMemoryInformation::RENDERER_DEVTOOLS; | 219 process.renderer_type = ProcessMemoryInformation::RENDERER_DEVTOOLS; |
219 else | 220 else |
220 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; | 221 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
221 } else if (extension_process_map->Contains(host->process()->GetID())) { | 222 } else if (extension_process_map->Contains( |
223 host->GetProcess()->GetID())) { | |
222 // For our purposes, don't count processes containing only hosted apps | 224 // For our purposes, don't count processes containing only hosted apps |
223 // as extension processes. See also: crbug.com/102533. | 225 // as extension processes. See also: crbug.com/102533. |
224 std::set<std::string> extension_ids = | 226 std::set<std::string> extension_ids = |
225 extension_process_map->GetExtensionsInProcess( | 227 extension_process_map->GetExtensionsInProcess( |
226 host->process()->GetID()); | 228 host->GetProcess()->GetID()); |
227 for (std::set<std::string>::iterator iter = extension_ids.begin(); | 229 for (std::set<std::string>::iterator iter = extension_ids.begin(); |
228 iter != extension_ids.end(); ++iter) { | 230 iter != extension_ids.end(); ++iter) { |
229 const Extension* extension = | 231 const Extension* extension = |
230 extension_service->GetExtensionById(*iter, false); | 232 extension_service->GetExtensionById(*iter, false); |
231 if (extension && !extension->is_hosted_app()) { | 233 if (extension && !extension->is_hosted_app()) { |
232 process.renderer_type = | 234 process.renderer_type = |
233 ProcessMemoryInformation::RENDERER_EXTENSION; | 235 ProcessMemoryInformation::RENDERER_EXTENSION; |
234 break; | 236 break; |
235 } | 237 } |
236 } | 238 } |
237 } | 239 } |
238 WebContents* contents = host_delegate->GetAsWebContents(); | 240 WebContents* contents = host_delegate->GetAsWebContents(); |
239 if (!contents) { | 241 if (!contents) { |
240 if (extension_process_map->Contains(host->process()->GetID())) { | 242 if (extension_process_map->Contains(host->GetProcess()->GetID())) { |
241 const Extension* extension = | 243 const Extension* extension = |
242 extension_service->extensions()->GetByID(url.host()); | 244 extension_service->extensions()->GetByID(url.host()); |
243 if (extension) { | 245 if (extension) { |
244 string16 title = UTF8ToUTF16(extension->name()); | 246 string16 title = UTF8ToUTF16(extension->name()); |
245 process.titles.push_back(title); | 247 process.titles.push_back(title); |
246 } | 248 } |
247 } else if (process.renderer_type == | 249 } else if (process.renderer_type == |
248 ProcessMemoryInformation::RENDERER_UNKNOWN) { | 250 ProcessMemoryInformation::RENDERER_UNKNOWN) { |
249 process.titles.push_back(UTF8ToUTF16(url.spec())); | 251 process.titles.push_back(UTF8ToUTF16(url.spec())); |
250 switch (type) { | 252 switch (type) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", | 428 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", |
427 pepper_plugin_count); | 429 pepper_plugin_count); |
428 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); | 430 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
429 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 431 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
430 // TODO(viettrungluu): Do we want separate counts for the other | 432 // TODO(viettrungluu): Do we want separate counts for the other |
431 // (platform-specific) process types? | 433 // (platform-specific) process types? |
432 | 434 |
433 int total_sample = static_cast<int>(aggregate_memory / 1000); | 435 int total_sample = static_cast<int>(aggregate_memory / 1000); |
434 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 436 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
435 } | 437 } |
OLD | NEW |