Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: chrome/browser/memory_details.cc

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/instant/instant_loader.cc ('k') | chrome/browser/oom_priority_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // have to be. 198 // have to be.
199 content::RenderProcessHost::listeners_iterator iter( 199 content::RenderProcessHost::listeners_iterator iter(
200 render_process_host->ListenersIterator()); 200 render_process_host->ListenersIterator());
201 for (; !iter.IsAtEnd(); iter.Advance()) { 201 for (; !iter.IsAtEnd(); iter.Advance()) {
202 const RenderWidgetHost* widget = 202 const RenderWidgetHost* widget =
203 RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue()); 203 RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue());
204 DCHECK(widget); 204 DCHECK(widget);
205 if (!widget || !widget->IsRenderView()) 205 if (!widget || !widget->IsRenderView())
206 continue; 206 continue;
207 207
208 const RenderViewHost* host = static_cast<const RenderViewHost*>(widget); 208 const RenderViewHost* host = static_cast<const RenderViewHostImpl*>(
209 content::RenderViewHostDelegate* host_delegate = host->delegate(); 209 RenderWidgetHostImpl::From(const_cast<RenderWidgetHost*>(widget)));
210 content::RenderViewHostDelegate* host_delegate = host->GetDelegate();
210 DCHECK(host_delegate); 211 DCHECK(host_delegate);
211 GURL url = host_delegate->GetURL(); 212 GURL url = host_delegate->GetURL();
212 content::ViewType type = host_delegate->GetRenderViewType(); 213 content::ViewType type = host_delegate->GetRenderViewType();
213 if (host->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI) { 214 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) {
214 // TODO(erikkay) the type for devtools doesn't actually appear to 215 // TODO(erikkay) the type for devtools doesn't actually appear to
215 // be set. 216 // be set.
216 if (type == content::VIEW_TYPE_DEV_TOOLS_UI) 217 if (type == content::VIEW_TYPE_DEV_TOOLS_UI)
217 process.renderer_type = ProcessMemoryInformation::RENDERER_DEVTOOLS; 218 process.renderer_type = ProcessMemoryInformation::RENDERER_DEVTOOLS;
218 else 219 else
219 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; 220 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME;
220 } else if (extension_process_map->Contains(host->process()->GetID())) { 221 } else if (extension_process_map->Contains(
222 host->GetProcess()->GetID())) {
221 // For our purposes, don't count processes containing only hosted apps 223 // For our purposes, don't count processes containing only hosted apps
222 // as extension processes. See also: crbug.com/102533. 224 // as extension processes. See also: crbug.com/102533.
223 std::set<std::string> extension_ids = 225 std::set<std::string> extension_ids =
224 extension_process_map->GetExtensionsInProcess( 226 extension_process_map->GetExtensionsInProcess(
225 host->process()->GetID()); 227 host->GetProcess()->GetID());
226 for (std::set<std::string>::iterator iter = extension_ids.begin(); 228 for (std::set<std::string>::iterator iter = extension_ids.begin();
227 iter != extension_ids.end(); ++iter) { 229 iter != extension_ids.end(); ++iter) {
228 const Extension* extension = 230 const Extension* extension =
229 extension_service->GetExtensionById(*iter, false); 231 extension_service->GetExtensionById(*iter, false);
230 if (extension && !extension->is_hosted_app()) { 232 if (extension && !extension->is_hosted_app()) {
231 process.renderer_type = 233 process.renderer_type =
232 ProcessMemoryInformation::RENDERER_EXTENSION; 234 ProcessMemoryInformation::RENDERER_EXTENSION;
233 break; 235 break;
234 } 236 }
235 } 237 }
236 } 238 }
237 WebContents* contents = host_delegate->GetAsWebContents(); 239 WebContents* contents = host_delegate->GetAsWebContents();
238 if (!contents) { 240 if (!contents) {
239 if (extension_process_map->Contains(host->process()->GetID())) { 241 if (extension_process_map->Contains(host->GetProcess()->GetID())) {
240 const Extension* extension = 242 const Extension* extension =
241 extension_service->extensions()->GetByID(url.host()); 243 extension_service->extensions()->GetByID(url.host());
242 if (extension) { 244 if (extension) {
243 string16 title = UTF8ToUTF16(extension->name()); 245 string16 title = UTF8ToUTF16(extension->name());
244 process.titles.push_back(title); 246 process.titles.push_back(title);
245 } 247 }
246 } else if (process.renderer_type == 248 } else if (process.renderer_type ==
247 ProcessMemoryInformation::RENDERER_UNKNOWN) { 249 ProcessMemoryInformation::RENDERER_UNKNOWN) {
248 process.titles.push_back(UTF8ToUTF16(url.spec())); 250 process.titles.push_back(UTF8ToUTF16(url.spec()));
249 switch (type) { 251 switch (type) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", 427 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount",
426 pepper_plugin_count); 428 pepper_plugin_count);
427 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); 429 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count);
428 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); 430 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count);
429 // TODO(viettrungluu): Do we want separate counts for the other 431 // TODO(viettrungluu): Do we want separate counts for the other
430 // (platform-specific) process types? 432 // (platform-specific) process types?
431 433
432 int total_sample = static_cast<int>(aggregate_memory / 1000); 434 int total_sample = static_cast<int>(aggregate_memory / 1000);
433 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); 435 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample);
434 } 436 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader.cc ('k') | chrome/browser/oom_priority_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698