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" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/extensions/extension_process_manager.h" | 14 #include "chrome/browser/extensions/extension_process_manager.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/view_type_utils.h" | |
18 #include "chrome/common/chrome_process_type.h" | 17 #include "chrome/common/chrome_process_type.h" |
19 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
21 #include "content/public/browser/browser_child_process_host_iterator.h" | 20 #include "content/public/browser/browser_child_process_host_iterator.h" |
22 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/child_process_data.h" | 22 #include "content/public/browser/child_process_data.h" |
24 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
27 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
28 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
29 #include "content/public/common/bindings_policy.h" | 28 #include "content/public/common/bindings_policy.h" |
| 29 #include "extensions/browser/view_type_utils.h" |
30 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 | 33 |
34 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 34 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
35 #include "content/public/browser/zygote_host_linux.h" | 35 #include "content/public/browser/zygote_host_linux.h" |
36 #endif | 36 #endif |
37 | 37 |
38 using base::StringPrintf; | 38 using base::StringPrintf; |
39 using content::BrowserChildProcessHostIterator; | 39 using content::BrowserChildProcessHostIterator; |
(...skipping 205 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 = extensions::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 |