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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/public/browser/child_process_data.h" | 23 #include "content/public/browser/child_process_data.h" |
24 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
28 #include "content/public/browser/render_widget_host.h" | 28 #include "content/public/browser/render_widget_host.h" |
29 #include "content/public/browser/render_widget_host_iterator.h" | 29 #include "content/public/browser/render_widget_host_iterator.h" |
30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
31 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
32 #include "content/public/common/content_constants.h" | 32 #include "content/public/common/content_constants.h" |
| 33 #include "extensions/features/features.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 | 35 |
35 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 36 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
36 #include "content/public/browser/zygote_host_linux.h" | 37 #include "content/public/browser/zygote_host_linux.h" |
37 #endif | 38 #endif |
38 | 39 |
39 #if defined(ENABLE_EXTENSIONS) | 40 #if BUILDFLAG(ENABLE_EXTENSIONS) |
40 #include "extensions/browser/extension_registry.h" | 41 #include "extensions/browser/extension_registry.h" |
41 #include "extensions/browser/process_manager.h" | 42 #include "extensions/browser/process_manager.h" |
42 #include "extensions/browser/process_map.h" | 43 #include "extensions/browser/process_map.h" |
43 #include "extensions/browser/view_type_utils.h" | 44 #include "extensions/browser/view_type_utils.h" |
44 #include "extensions/common/extension.h" | 45 #include "extensions/common/extension.h" |
45 #endif | 46 #endif |
46 | 47 |
47 using base::StringPrintf; | 48 using base::StringPrintf; |
48 using content::BrowserChildProcessHostIterator; | 49 using content::BrowserChildProcessHostIterator; |
49 using content::BrowserThread; | 50 using content::BrowserThread; |
50 using content::NavigationEntry; | 51 using content::NavigationEntry; |
51 using content::RenderViewHost; | 52 using content::RenderViewHost; |
52 using content::RenderWidgetHost; | 53 using content::RenderWidgetHost; |
53 using content::WebContents; | 54 using content::WebContents; |
54 #if defined(ENABLE_EXTENSIONS) | 55 #if BUILDFLAG(ENABLE_EXTENSIONS) |
55 using extensions::Extension; | 56 using extensions::Extension; |
56 #endif | 57 #endif |
57 | 58 |
58 // static | 59 // static |
59 std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish( | 60 std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish( |
60 RendererProcessType type) { | 61 RendererProcessType type) { |
61 switch (type) { | 62 switch (type) { |
62 case RENDERER_NORMAL: | 63 case RENDERER_NORMAL: |
63 return "Tab"; | 64 return "Tab"; |
64 case RENDERER_CHROME: | 65 case RENDERER_CHROME: |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // a RenderProcessHost. | 235 // a RenderProcessHost. |
235 content::RenderProcessHost* render_process_host = nullptr; | 236 content::RenderProcessHost* render_process_host = nullptr; |
236 if (!widgets_by_pid[process.pid].empty()) { | 237 if (!widgets_by_pid[process.pid].empty()) { |
237 // Mark it as a normal renderer process, if we don't refine it to some | 238 // Mark it as a normal renderer process, if we don't refine it to some |
238 // other |renderer_type| later. | 239 // other |renderer_type| later. |
239 process.process_type = content::PROCESS_TYPE_RENDERER; | 240 process.process_type = content::PROCESS_TYPE_RENDERER; |
240 process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; | 241 process.renderer_type = ProcessMemoryInformation::RENDERER_NORMAL; |
241 render_process_host = widgets_by_pid[process.pid].front()->GetProcess(); | 242 render_process_host = widgets_by_pid[process.pid].front()->GetProcess(); |
242 } | 243 } |
243 | 244 |
244 #if defined(ENABLE_EXTENSIONS) | 245 #if BUILDFLAG(ENABLE_EXTENSIONS) |
245 // Determine if this is an extension process. | 246 // Determine if this is an extension process. |
246 bool process_is_for_extensions = false; | 247 bool process_is_for_extensions = false; |
247 if (render_process_host) { | 248 if (render_process_host) { |
248 content::BrowserContext* context = | 249 content::BrowserContext* context = |
249 render_process_host->GetBrowserContext(); | 250 render_process_host->GetBrowserContext(); |
250 extensions::ExtensionRegistry* extension_registry = | 251 extensions::ExtensionRegistry* extension_registry = |
251 extensions::ExtensionRegistry::Get(context); | 252 extensions::ExtensionRegistry::Get(context); |
252 extensions::ProcessMap* process_map = | 253 extensions::ProcessMap* process_map = |
253 extensions::ProcessMap::Get(context); | 254 extensions::ProcessMap::Get(context); |
254 int rph_id = render_process_host->GetID(); | 255 int rph_id = render_process_host->GetID(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 chrome_browser->site_data[contents->GetBrowserContext()]; | 297 chrome_browser->site_data[contents->GetBrowserContext()]; |
297 SiteDetails::CollectSiteInfo(contents, &site_data); | 298 SiteDetails::CollectSiteInfo(contents, &site_data); |
298 | 299 |
299 bool is_webui = | 300 bool is_webui = |
300 rvh->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI; | 301 rvh->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI; |
301 | 302 |
302 if (is_webui) { | 303 if (is_webui) { |
303 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; | 304 process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME; |
304 } | 305 } |
305 | 306 |
306 #if defined(ENABLE_EXTENSIONS) | 307 #if BUILDFLAG(ENABLE_EXTENSIONS) |
307 if (!is_webui && process_is_for_extensions) { | 308 if (!is_webui && process_is_for_extensions) { |
308 const Extension* extension = | 309 const Extension* extension = |
309 extensions::ExtensionRegistry::Get( | 310 extensions::ExtensionRegistry::Get( |
310 render_process_host->GetBrowserContext()) | 311 render_process_host->GetBrowserContext()) |
311 ->enabled_extensions() | 312 ->enabled_extensions() |
312 .GetByID(page_url.host()); | 313 .GetByID(page_url.host()); |
313 if (extension) { | 314 if (extension) { |
314 base::string16 title = base::UTF8ToUTF16(extension->name()); | 315 base::string16 title = base::UTF8ToUTF16(extension->name()); |
315 process.titles.push_back(title); | 316 process.titles.push_back(title); |
316 process.renderer_type = | 317 process.renderer_type = |
(...skipping 27 matching lines...) Expand all Loading... |
344 // Get rid of other Chrome processes that are from a different profile. | 345 // Get rid of other Chrome processes that are from a different profile. |
345 auto is_unknown = [](ProcessMemoryInformation& process) { | 346 auto is_unknown = [](ProcessMemoryInformation& process) { |
346 return process.process_type == content::PROCESS_TYPE_UNKNOWN; | 347 return process.process_type == content::PROCESS_TYPE_UNKNOWN; |
347 }; | 348 }; |
348 auto& vector = chrome_browser->processes; | 349 auto& vector = chrome_browser->processes; |
349 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), | 350 vector.erase(std::remove_if(vector.begin(), vector.end(), is_unknown), |
350 vector.end()); | 351 vector.end()); |
351 | 352 |
352 OnDetailsAvailable(); | 353 OnDetailsAvailable(); |
353 } | 354 } |
OLD | NEW |