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

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

Issue 11013031: Check for NULL extension_service and extension_process_map for Android platform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 years, 2 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 | « no previous file | no next file » | 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Ignore processes that don't have a connection, such as crashed tabs. 220 // Ignore processes that don't have a connection, such as crashed tabs.
221 if (!render_process_host->HasConnection() || 221 if (!render_process_host->HasConnection() ||
222 process.pid != base::GetProcId(render_process_host->GetHandle())) { 222 process.pid != base::GetProcId(render_process_host->GetHandle())) {
223 continue; 223 continue;
224 } 224 }
225 process.type = content::PROCESS_TYPE_RENDERER; 225 process.type = content::PROCESS_TYPE_RENDERER;
226 Profile* profile = 226 Profile* profile =
227 Profile::FromBrowserContext( 227 Profile::FromBrowserContext(
228 render_process_host->GetBrowserContext()); 228 render_process_host->GetBrowserContext());
229 ExtensionService* extension_service = profile->GetExtensionService(); 229 ExtensionService* extension_service = profile->GetExtensionService();
230 extensions::ProcessMap* extension_process_map = 230 extensions::ProcessMap* extension_process_map = NULL;
231 extension_service->process_map(); 231 // No extensions on Android. So extension_service can be NULL.
232 if (extension_service)
233 extension_process_map = extension_service->process_map();
232 234
233 // The RenderProcessHost may host multiple WebContentses. Any 235 // The RenderProcessHost may host multiple WebContentses. Any
234 // of them which contain diagnostics information make the whole 236 // of them which contain diagnostics information make the whole
235 // process be considered a diagnostics process. 237 // process be considered a diagnostics process.
236 content::RenderProcessHost::RenderWidgetHostsIterator iter( 238 content::RenderProcessHost::RenderWidgetHostsIterator iter(
237 render_process_host->GetRenderWidgetHostsIterator()); 239 render_process_host->GetRenderWidgetHostsIterator());
238 for (; !iter.IsAtEnd(); iter.Advance()) { 240 for (; !iter.IsAtEnd(); iter.Advance()) {
239 const RenderWidgetHost* widget = iter.GetCurrentValue(); 241 const RenderWidgetHost* widget = iter.GetCurrentValue();
240 DCHECK(widget); 242 DCHECK(widget);
241 if (!widget || !widget->IsRenderView()) 243 if (!widget || !widget->IsRenderView())
242 continue; 244 continue;
243 245
244 RenderViewHost* host = 246 RenderViewHost* host =
245 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); 247 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
246 WebContents* contents = WebContents::FromRenderViewHost(host); 248 WebContents* contents = WebContents::FromRenderViewHost(host);
247 GURL url; 249 GURL url;
248 if (contents) 250 if (contents)
249 url = contents->GetURL(); 251 url = contents->GetURL();
250 chrome::ViewType type = chrome::GetViewType(contents); 252 chrome::ViewType type = chrome::GetViewType(contents);
251 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) { 253 if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) {
252 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; 254 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME;
253 } else if (extension_process_map->Contains( 255 } else if (extension_process_map &&
254 host->GetProcess()->GetID())) { 256 extension_process_map->Contains(host->GetProcess()->GetID())) {
255 // For our purposes, don't count processes containing only hosted apps 257 // For our purposes, don't count processes containing only hosted apps
256 // as extension processes. See also: crbug.com/102533. 258 // as extension processes. See also: crbug.com/102533.
257 std::set<std::string> extension_ids = 259 std::set<std::string> extension_ids =
258 extension_process_map->GetExtensionsInProcess( 260 extension_process_map->GetExtensionsInProcess(
259 host->GetProcess()->GetID()); 261 host->GetProcess()->GetID());
260 for (std::set<std::string>::iterator iter = extension_ids.begin(); 262 for (std::set<std::string>::iterator iter = extension_ids.begin();
261 iter != extension_ids.end(); ++iter) { 263 iter != extension_ids.end(); ++iter) {
262 const Extension* extension = 264 const Extension* extension =
263 extension_service->GetExtensionById(*iter, false); 265 extension_service->GetExtensionById(*iter, false);
264 if (extension && !extension->is_hosted_app()) { 266 if (extension && !extension->is_hosted_app()) {
265 process.renderer_type = 267 process.renderer_type =
266 ProcessMemoryInformation::RENDERER_EXTENSION; 268 ProcessMemoryInformation::RENDERER_EXTENSION;
267 break; 269 break;
268 } 270 }
269 } 271 }
270 } 272 }
271 if (extension_process_map->Contains(host->GetProcess()->GetID())) { 273 if (extension_process_map &&
274 extension_process_map->Contains(host->GetProcess()->GetID())) {
272 const Extension* extension = 275 const Extension* extension =
273 extension_service->extensions()->GetByID(url.host()); 276 extension_service->extensions()->GetByID(url.host());
274 if (extension) { 277 if (extension) {
275 string16 title = UTF8ToUTF16(extension->name()); 278 string16 title = UTF8ToUTF16(extension->name());
276 process.titles.push_back(title); 279 process.titles.push_back(title);
277 process.renderer_type = 280 process.renderer_type =
278 ProcessMemoryInformation::RENDERER_EXTENSION; 281 ProcessMemoryInformation::RENDERER_EXTENSION;
279 continue; 282 continue;
280 } 283 }
281 } 284 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", 461 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount",
459 pepper_plugin_count); 462 pepper_plugin_count);
460 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); 463 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count);
461 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); 464 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count);
462 // TODO(viettrungluu): Do we want separate counts for the other 465 // TODO(viettrungluu): Do we want separate counts for the other
463 // (platform-specific) process types? 466 // (platform-specific) process types?
464 467
465 int total_sample = static_cast<int>(aggregate_memory / 1000); 468 int total_sample = static_cast<int>(aggregate_memory / 1000);
466 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); 469 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample);
467 } 470 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698