| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/task_management/providers/web_contents/renderer_task.h" | 5 #include "chrome/browser/task_management/providers/web_contents/renderer_task.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/favicon/favicon_utils.h" | 11 #include "chrome/browser/favicon/favicon_utils.h" |
| 12 #include "chrome/browser/process_resource_usage.h" | 12 #include "chrome/browser/process_resource_usage.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_info_cache.h" | |
| 15 #include "chrome/browser/profiles/profile_manager.h" | |
| 16 #include "chrome/browser/task_management/task_manager_observer.h" | 14 #include "chrome/browser/task_management/task_manager_observer.h" |
| 17 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 18 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 21 #include "content/public/common/service_registry.h" | 19 #include "content/public/common/service_registry.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 23 | 21 |
| 24 namespace task_management { | 22 namespace task_management { |
| 25 | 23 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 service_registry->ConnectToRemoteService(mojo::GetProxy(&service)); | 35 service_registry->ConnectToRemoteService(mojo::GetProxy(&service)); |
| 38 return new ProcessResourceUsage(service.Pass()); | 36 return new ProcessResourceUsage(service.Pass()); |
| 39 } | 37 } |
| 40 | 38 |
| 41 // Gets the profile name associated with the browser context of the given | 39 // Gets the profile name associated with the browser context of the given |
| 42 // |render_process_host| from the profile info cache. | 40 // |render_process_host| from the profile info cache. |
| 43 base::string16 GetRendererProfileName( | 41 base::string16 GetRendererProfileName( |
| 44 const content::RenderProcessHost* render_process_host) { | 42 const content::RenderProcessHost* render_process_host) { |
| 45 Profile* profile = | 43 Profile* profile = |
| 46 Profile::FromBrowserContext(render_process_host->GetBrowserContext()); | 44 Profile::FromBrowserContext(render_process_host->GetBrowserContext()); |
| 47 DCHECK(profile); | 45 return Task::GetProfileNameFromProfile(profile); |
| 48 ProfileInfoCache& cache = | |
| 49 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
| 50 size_t index = | |
| 51 cache.GetIndexOfProfileWithPath(profile->GetOriginalProfile()->GetPath()); | |
| 52 if (index != std::string::npos) | |
| 53 return cache.GetNameOfProfileAtIndex(index); | |
| 54 | |
| 55 return base::string16(); | |
| 56 } | 46 } |
| 57 | 47 |
| 58 inline bool IsRendererResourceSamplingDisabled(int64 flags) { | 48 inline bool IsRendererResourceSamplingDisabled(int64 flags) { |
| 59 return (flags & (REFRESH_TYPE_V8_MEMORY | REFRESH_TYPE_WEBCACHE_STATS)) == 0; | 49 return (flags & (REFRESH_TYPE_V8_MEMORY | REFRESH_TYPE_WEBCACHE_STATS)) == 0; |
| 60 } | 50 } |
| 61 | 51 |
| 62 } // namespace | 52 } // namespace |
| 63 | 53 |
| 64 RendererTask::RendererTask(const base::string16& title, | 54 RendererTask::RendererTask(const base::string16& title, |
| 65 const gfx::ImageSkia* icon, | 55 const gfx::ImageSkia* icon, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 if (is_incognito) | 208 if (is_incognito) |
| 219 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; | 209 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; |
| 220 else | 210 else |
| 221 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; | 211 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; |
| 222 } | 212 } |
| 223 | 213 |
| 224 return l10n_util::GetStringFUTF16(message_id, title); | 214 return l10n_util::GetStringFUTF16(message_id, title); |
| 225 } | 215 } |
| 226 | 216 |
| 227 } // namespace task_management | 217 } // namespace task_management |
| OLD | NEW |