| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // 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 |
| 40 // |render_process_host| from the profile info cache. | 40 // |render_process_host| from the profile info cache. |
| 41 base::string16 GetRendererProfileName( | 41 base::string16 GetRendererProfileName( |
| 42 const content::RenderProcessHost* render_process_host) { | 42 const content::RenderProcessHost* render_process_host) { |
| 43 Profile* profile = | 43 Profile* profile = |
| 44 Profile::FromBrowserContext(render_process_host->GetBrowserContext()); | 44 Profile::FromBrowserContext(render_process_host->GetBrowserContext()); |
| 45 return Task::GetProfileNameFromProfile(profile); | 45 return Task::GetProfileNameFromProfile(profile); |
| 46 } | 46 } |
| 47 | 47 |
| 48 inline bool IsRendererResourceSamplingDisabled(int64 flags) { | 48 inline bool IsRendererResourceSamplingDisabled(int64_t flags) { |
| 49 return (flags & (REFRESH_TYPE_V8_MEMORY | REFRESH_TYPE_WEBCACHE_STATS)) == 0; | 49 return (flags & (REFRESH_TYPE_V8_MEMORY | REFRESH_TYPE_WEBCACHE_STATS)) == 0; |
| 50 } | 50 } |
| 51 | 51 |
| 52 std::string GetRapporSampleName(content::WebContents* web_contents) { | 52 std::string GetRapporSampleName(content::WebContents* web_contents) { |
| 53 return web_contents->GetVisibleURL().GetOrigin().spec(); | 53 return web_contents->GetVisibleURL().GetOrigin().spec(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 RendererTask::RendererTask(const base::string16& title, | 58 RendererTask::RendererTask(const base::string16& title, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 void RendererTask::Activate() { | 95 void RendererTask::Activate() { |
| 96 if (!web_contents_->GetDelegate()) | 96 if (!web_contents_->GetDelegate()) |
| 97 return; | 97 return; |
| 98 | 98 |
| 99 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 99 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void RendererTask::Refresh(const base::TimeDelta& update_interval, | 102 void RendererTask::Refresh(const base::TimeDelta& update_interval, |
| 103 int64 refresh_flags) { | 103 int64_t refresh_flags) { |
| 104 Task::Refresh(update_interval, refresh_flags); | 104 Task::Refresh(update_interval, refresh_flags); |
| 105 | 105 |
| 106 if (IsRendererResourceSamplingDisabled(refresh_flags)) | 106 if (IsRendererResourceSamplingDisabled(refresh_flags)) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 // The renderer resources refresh is performed asynchronously, we will invoke | 109 // The renderer resources refresh is performed asynchronously, we will invoke |
| 110 // it and record the current values (which might be invalid at the moment. We | 110 // it and record the current values (which might be invalid at the moment. We |
| 111 // can safely ignore that and count on future refresh cycles potentially | 111 // can safely ignore that and count on future refresh cycles potentially |
| 112 // having valid values). | 112 // having valid values). |
| 113 renderer_resources_sampler_->Refresh(base::Closure()); | 113 renderer_resources_sampler_->Refresh(base::Closure()); |
| 114 | 114 |
| 115 v8_memory_allocated_ = base::saturated_cast<int64>( | 115 v8_memory_allocated_ = base::saturated_cast<int64_t>( |
| 116 renderer_resources_sampler_->GetV8MemoryAllocated()); | 116 renderer_resources_sampler_->GetV8MemoryAllocated()); |
| 117 v8_memory_used_ = base::saturated_cast<int64>( | 117 v8_memory_used_ = base::saturated_cast<int64_t>( |
| 118 renderer_resources_sampler_->GetV8MemoryUsed()); | 118 renderer_resources_sampler_->GetV8MemoryUsed()); |
| 119 webcache_stats_ = renderer_resources_sampler_->GetWebCoreCacheStats(); | 119 webcache_stats_ = renderer_resources_sampler_->GetWebCoreCacheStats(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 Task::Type RendererTask::GetType() const { | 122 Task::Type RendererTask::GetType() const { |
| 123 return Task::RENDERER; | 123 return Task::RENDERER; |
| 124 } | 124 } |
| 125 | 125 |
| 126 int RendererTask::GetChildProcessUniqueID() const { | 126 int RendererTask::GetChildProcessUniqueID() const { |
| 127 return render_process_id_; | 127 return render_process_id_; |
| 128 } | 128 } |
| 129 | 129 |
| 130 base::string16 RendererTask::GetProfileName() const { | 130 base::string16 RendererTask::GetProfileName() const { |
| 131 return profile_name_; | 131 return profile_name_; |
| 132 } | 132 } |
| 133 | 133 |
| 134 int64 RendererTask::GetV8MemoryAllocated() const { | 134 int64_t RendererTask::GetV8MemoryAllocated() const { |
| 135 return v8_memory_allocated_; | 135 return v8_memory_allocated_; |
| 136 } | 136 } |
| 137 | 137 |
| 138 int64 RendererTask::GetV8MemoryUsed() const { | 138 int64_t RendererTask::GetV8MemoryUsed() const { |
| 139 return v8_memory_used_; | 139 return v8_memory_used_; |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool RendererTask::ReportsWebCacheStats() const { | 142 bool RendererTask::ReportsWebCacheStats() const { |
| 143 return true; | 143 return true; |
| 144 } | 144 } |
| 145 | 145 |
| 146 blink::WebCache::ResourceTypeStats RendererTask::GetWebCacheStats() const { | 146 blink::WebCache::ResourceTypeStats RendererTask::GetWebCacheStats() const { |
| 147 return webcache_stats_; | 147 return webcache_stats_; |
| 148 } | 148 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 if (is_incognito) | 220 if (is_incognito) |
| 221 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; | 221 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; |
| 222 else | 222 else |
| 223 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; | 223 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; |
| 224 } | 224 } |
| 225 | 225 |
| 226 return l10n_util::GetStringFUTF16(message_id, title); | 226 return l10n_util::GetStringFUTF16(message_id, title); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace task_management | 229 } // namespace task_management |
| OLD | NEW |