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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 DCHECK(widget); | 245 DCHECK(widget); |
246 if (!widget || !widget->IsRenderView()) | 246 if (!widget || !widget->IsRenderView()) |
247 continue; | 247 continue; |
248 | 248 |
249 RenderViewHost* host = | 249 RenderViewHost* host = |
250 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); | 250 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
251 WebContents* contents = WebContents::FromRenderViewHost(host); | 251 WebContents* contents = WebContents::FromRenderViewHost(host); |
252 GURL url; | 252 GURL url; |
253 if (contents) | 253 if (contents) |
254 url = contents->GetURL(); | 254 url = contents->GetURL(); |
255 chrome::ViewType type = chrome::GetViewType(contents); | 255 extensions::ViewType type = chrome::GetViewType(contents); |
256 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { | 256 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { |
257 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; | 257 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
258 } else if (extension_process_map && | 258 } else if (extension_process_map && |
259 extension_process_map->Contains(host->GetProcess()->GetID())) { | 259 extension_process_map->Contains(host->GetProcess()->GetID())) { |
260 // For our purposes, don't count processes containing only hosted apps | 260 // For our purposes, don't count processes containing only hosted apps |
261 // as extension processes. See also: crbug.com/102533. | 261 // as extension processes. See also: crbug.com/102533. |
262 std::set<std::string> extension_ids = | 262 std::set<std::string> extension_ids = |
263 extension_process_map->GetExtensionsInProcess( | 263 extension_process_map->GetExtensionsInProcess( |
264 host->GetProcess()->GetID()); | 264 host->GetProcess()->GetID()); |
265 for (std::set<std::string>::iterator iter = extension_ids.begin(); | 265 for (std::set<std::string>::iterator iter = extension_ids.begin(); |
(...skipping 19 matching lines...) Expand all Loading... |
285 continue; | 285 continue; |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 if (!contents) { | 289 if (!contents) { |
290 process.renderer_type = | 290 process.renderer_type = |
291 ProcessMemoryInformation::RENDERER_INTERSTITIAL; | 291 ProcessMemoryInformation::RENDERER_INTERSTITIAL; |
292 continue; | 292 continue; |
293 } | 293 } |
294 | 294 |
295 if (type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { | 295 if (type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) { |
296 process.titles.push_back(UTF8ToUTF16(url.spec())); | 296 process.titles.push_back(UTF8ToUTF16(url.spec())); |
297 process.renderer_type = | 297 process.renderer_type = |
298 ProcessMemoryInformation::RENDERER_BACKGROUND_APP; | 298 ProcessMemoryInformation::RENDERER_BACKGROUND_APP; |
299 continue; | 299 continue; |
300 } | 300 } |
301 | 301 |
302 if (type == chrome::VIEW_TYPE_NOTIFICATION) { | 302 if (type == extensions::VIEW_TYPE_NOTIFICATION) { |
303 process.titles.push_back(UTF8ToUTF16(url.spec())); | 303 process.titles.push_back(UTF8ToUTF16(url.spec())); |
304 process.renderer_type = | 304 process.renderer_type = |
305 ProcessMemoryInformation::RENDERER_NOTIFICATION; | 305 ProcessMemoryInformation::RENDERER_NOTIFICATION; |
306 continue; | 306 continue; |
307 } | 307 } |
308 | 308 |
309 // Since we have a WebContents and and the renderer type hasn't been | 309 // Since we have a WebContents and and the renderer type hasn't been |
310 // set yet, it must be a normal tabbed renderer. | 310 // set yet, it must be a normal tabbed renderer. |
311 if (process.renderer_type == ProcessMemoryInformation::RENDERER_UNKNOWN) | 311 if (process.renderer_type == ProcessMemoryInformation::RENDERER_UNKNOWN) |
312 process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; | 312 process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", | 478 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", |
479 pepper_plugin_broker_count); | 479 pepper_plugin_broker_count); |
480 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); | 480 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
481 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 481 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
482 // TODO(viettrungluu): Do we want separate counts for the other | 482 // TODO(viettrungluu): Do we want separate counts for the other |
483 // (platform-specific) process types? | 483 // (platform-specific) process types? |
484 | 484 |
485 int total_sample = static_cast<int>(aggregate_memory / 1000); | 485 int total_sample = static_cast<int>(aggregate_memory / 1000); |
486 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 486 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
487 } | 487 } |
OLD | NEW |