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/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/extensions/extension_process_manager.h" | 13 #include "chrome/browser/extensions/extension_process_manager.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/chrome_view_type.h" | 16 #include "chrome/common/chrome_view_type.h" |
17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "content/browser/browser_child_process_host.h" | 19 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 20 #include "content/public/browser/child_process_data.h" |
20 #include "content/browser/renderer_host/backing_store_manager.h" | 21 #include "content/browser/renderer_host/backing_store_manager.h" |
21 #include "content/browser/renderer_host/render_view_host.h" | 22 #include "content/browser/renderer_host/render_view_host.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/render_view_host_delegate.h" | 26 #include "content/public/browser/render_view_host_delegate.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/bindings_policy.h" | 28 #include "content/public/common/bindings_policy.h" |
28 #include "content/public/common/process_type.h" | 29 #include "content/public/common/process_type.h" |
29 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
31 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
32 | 33 |
33 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 34 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
34 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 35 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
35 #include "content/browser/zygote_host_linux.h" | 36 #include "content/browser/zygote_host_linux.h" |
36 #endif | 37 #endif |
37 | 38 |
| 39 using content::BrowserChildProcessHostIterator; |
38 using content::BrowserThread; | 40 using content::BrowserThread; |
39 using content::NavigationEntry; | 41 using content::NavigationEntry; |
40 using content::WebContents; | 42 using content::WebContents; |
41 | 43 |
42 // static | 44 // static |
43 std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish( | 45 std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish( |
44 RendererProcessType type) { | 46 RendererProcessType type) { |
45 switch (type) { | 47 switch (type) { |
46 case RENDERER_NORMAL: | 48 case RENDERER_NORMAL: |
47 return "Tab"; | 49 return "Tab"; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 127 } |
126 | 128 |
127 MemoryDetails::~MemoryDetails() {} | 129 MemoryDetails::~MemoryDetails() {} |
128 | 130 |
129 void MemoryDetails::CollectChildInfoOnIOThread() { | 131 void MemoryDetails::CollectChildInfoOnIOThread() { |
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
131 | 133 |
132 std::vector<ProcessMemoryInformation> child_info; | 134 std::vector<ProcessMemoryInformation> child_info; |
133 | 135 |
134 // Collect the list of child processes. | 136 // Collect the list of child processes. |
135 for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { | 137 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
136 ProcessMemoryInformation info; | 138 ProcessMemoryInformation info; |
137 info.pid = base::GetProcId(iter->data().handle); | 139 info.pid = base::GetProcId(iter.GetData().handle); |
138 if (!info.pid) | 140 if (!info.pid) |
139 continue; | 141 continue; |
140 | 142 |
141 info.type = iter->data().type; | 143 info.type = iter.GetData().type; |
142 info.renderer_type = ProcessMemoryInformation::RENDERER_UNKNOWN; | 144 info.renderer_type = ProcessMemoryInformation::RENDERER_UNKNOWN; |
143 info.titles.push_back(iter->data().name); | 145 info.titles.push_back(iter.GetData().name); |
144 child_info.push_back(info); | 146 child_info.push_back(info); |
145 } | 147 } |
146 | 148 |
147 // Now go do expensive memory lookups from the file thread. | 149 // Now go do expensive memory lookups from the file thread. |
148 BrowserThread::PostTask( | 150 BrowserThread::PostTask( |
149 BrowserThread::FILE, FROM_HERE, | 151 BrowserThread::FILE, FROM_HERE, |
150 base::Bind(&MemoryDetails::CollectProcessData, this, child_info)); | 152 base::Bind(&MemoryDetails::CollectProcessData, this, child_info)); |
151 } | 153 } |
152 | 154 |
153 void MemoryDetails::CollectChildInfoOnUIThread() { | 155 void MemoryDetails::CollectChildInfoOnUIThread() { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", | 425 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", |
424 pepper_plugin_count); | 426 pepper_plugin_count); |
425 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); | 427 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
426 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 428 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
427 // TODO(viettrungluu): Do we want separate counts for the other | 429 // TODO(viettrungluu): Do we want separate counts for the other |
428 // (platform-specific) process types? | 430 // (platform-specific) process types? |
429 | 431 |
430 int total_sample = static_cast<int>(aggregate_memory / 1000); | 432 int total_sample = static_cast<int>(aggregate_memory / 1000); |
431 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 433 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
432 } | 434 } |
OLD | NEW |