OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_types.h" | 16 #include "chrome/common/chrome_view_types.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/browser/browser_child_process_host.h" |
20 #include "content/browser/renderer_host/backing_store_manager.h" | 20 #include "content/browser/renderer_host/backing_store_manager.h" |
21 #include "content/browser/renderer_host/render_process_host.h" | |
22 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
23 #include "content/browser/tab_contents/navigation_entry.h" | 22 #include "content/browser/tab_contents/navigation_entry.h" |
24 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/common/bindings_policy.h" | 26 #include "content/public/common/bindings_policy.h" |
27 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 | 30 |
31 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 31 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
32 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 32 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
33 #include "content/browser/zygote_host_linux.h" | 33 #include "content/browser/zygote_host_linux.h" |
34 #endif | 34 #endif |
35 | 35 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 renderer_iter.Advance()) { | 135 renderer_iter.Advance()) { |
136 RenderProcessHost* render_process_host = renderer_iter.GetCurrentValue(); | 136 RenderProcessHost* render_process_host = renderer_iter.GetCurrentValue(); |
137 DCHECK(render_process_host); | 137 DCHECK(render_process_host); |
138 // Ignore processes that don't have a connection, such as crashed tabs. | 138 // Ignore processes that don't have a connection, such as crashed tabs. |
139 if (!render_process_host->HasConnection() || | 139 if (!render_process_host->HasConnection() || |
140 process.pid != base::GetProcId(render_process_host->GetHandle())) { | 140 process.pid != base::GetProcId(render_process_host->GetHandle())) { |
141 continue; | 141 continue; |
142 } | 142 } |
143 process.type = ChildProcessInfo::RENDER_PROCESS; | 143 process.type = ChildProcessInfo::RENDER_PROCESS; |
144 Profile* profile = | 144 Profile* profile = |
145 Profile::FromBrowserContext(render_process_host->browser_context()); | 145 Profile::FromBrowserContext( |
| 146 render_process_host->GetBrowserContext()); |
146 ExtensionService* extension_service = profile->GetExtensionService(); | 147 ExtensionService* extension_service = profile->GetExtensionService(); |
147 extensions::ProcessMap* extension_process_map = | 148 extensions::ProcessMap* extension_process_map = |
148 extension_service->process_map(); | 149 extension_service->process_map(); |
149 | 150 |
150 // The RenderProcessHost may host multiple TabContents. Any | 151 // The RenderProcessHost may host multiple TabContents. Any |
151 // of them which contain diagnostics information make the whole | 152 // of them which contain diagnostics information make the whole |
152 // process be considered a diagnostics process. | 153 // process be considered a diagnostics process. |
153 // | 154 // |
154 // NOTE: This is a bit dangerous. We know that for now, listeners | 155 // NOTE: This is a bit dangerous. We know that for now, listeners |
155 // are always RenderWidgetHosts. But in theory, they don't | 156 // are always RenderWidgetHosts. But in theory, they don't |
(...skipping 12 matching lines...) Expand all Loading... |
168 DCHECK(host_delegate); | 169 DCHECK(host_delegate); |
169 GURL url = host_delegate->GetURL(); | 170 GURL url = host_delegate->GetURL(); |
170 content::ViewType type = host_delegate->GetRenderViewType(); | 171 content::ViewType type = host_delegate->GetRenderViewType(); |
171 if (host->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI) { | 172 if (host->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI) { |
172 // TODO(erikkay) the type for devtools doesn't actually appear to | 173 // TODO(erikkay) the type for devtools doesn't actually appear to |
173 // be set. | 174 // be set. |
174 if (type == content::VIEW_TYPE_DEV_TOOLS_UI) | 175 if (type == content::VIEW_TYPE_DEV_TOOLS_UI) |
175 process.renderer_type = ChildProcessInfo::RENDERER_DEVTOOLS; | 176 process.renderer_type = ChildProcessInfo::RENDERER_DEVTOOLS; |
176 else | 177 else |
177 process.renderer_type = ChildProcessInfo::RENDERER_CHROME; | 178 process.renderer_type = ChildProcessInfo::RENDERER_CHROME; |
178 } else if (extension_process_map->Contains(host->process()->id())) { | 179 } else if (extension_process_map->Contains(host->process()->GetID())) { |
179 // For our purposes, don't count processes containing only hosted apps | 180 // For our purposes, don't count processes containing only hosted apps |
180 // as extension processes. See also: crbug.com/102533. | 181 // as extension processes. See also: crbug.com/102533. |
181 std::set<std::string> extension_ids = | 182 std::set<std::string> extension_ids = |
182 extension_process_map->GetExtensionsInProcess( | 183 extension_process_map->GetExtensionsInProcess( |
183 host->process()->id()); | 184 host->process()->GetID()); |
184 for (std::set<std::string>::iterator iter = extension_ids.begin(); | 185 for (std::set<std::string>::iterator iter = extension_ids.begin(); |
185 iter != extension_ids.end(); ++iter) { | 186 iter != extension_ids.end(); ++iter) { |
186 const Extension* extension = | 187 const Extension* extension = |
187 extension_service->GetExtensionById(*iter, false); | 188 extension_service->GetExtensionById(*iter, false); |
188 if (extension && !extension->is_hosted_app()) { | 189 if (extension && !extension->is_hosted_app()) { |
189 process.renderer_type = ChildProcessInfo::RENDERER_EXTENSION; | 190 process.renderer_type = ChildProcessInfo::RENDERER_EXTENSION; |
190 break; | 191 break; |
191 } | 192 } |
192 } | 193 } |
193 } | 194 } |
194 TabContents* contents = host_delegate->GetAsTabContents(); | 195 TabContents* contents = host_delegate->GetAsTabContents(); |
195 if (!contents) { | 196 if (!contents) { |
196 if (extension_process_map->Contains(host->process()->id())) { | 197 if (extension_process_map->Contains(host->process()->GetID())) { |
197 const Extension* extension = | 198 const Extension* extension = |
198 extension_service->GetExtensionByURL(url); | 199 extension_service->GetExtensionByURL(url); |
199 if (extension) { | 200 if (extension) { |
200 string16 title = UTF8ToUTF16(extension->name()); | 201 string16 title = UTF8ToUTF16(extension->name()); |
201 process.titles.push_back(title); | 202 process.titles.push_back(title); |
202 } | 203 } |
203 } else if (process.renderer_type == | 204 } else if (process.renderer_type == |
204 ChildProcessInfo::RENDERER_UNKNOWN) { | 205 ChildProcessInfo::RENDERER_UNKNOWN) { |
205 process.titles.push_back(UTF8ToUTF16(url.spec())); | 206 process.titles.push_back(UTF8ToUTF16(url.spec())); |
206 switch (type) { | 207 switch (type) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", | 380 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", |
380 pepper_plugin_count); | 381 pepper_plugin_count); |
381 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); | 382 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
382 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 383 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
383 // TODO(viettrungluu): Do we want separate counts for the other | 384 // TODO(viettrungluu): Do we want separate counts for the other |
384 // (platform-specific) process types? | 385 // (platform-specific) process types? |
385 | 386 |
386 int total_sample = static_cast<int>(aggregate_memory / 1000); | 387 int total_sample = static_cast<int>(aggregate_memory / 1000); |
387 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 388 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
388 } | 389 } |
OLD | NEW |