| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/favicon/favicon_utils.h" | 13 #include "chrome/browser/favicon/favicon_utils.h" |
| 14 #include "chrome/browser/process_resource_usage.h" | 14 #include "chrome/browser/process_resource_usage.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/sessions/session_tab_helper.h" |
| 16 #include "chrome/browser/task_management/task_manager_observer.h" | 17 #include "chrome/browser/task_management/task_manager_observer.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 18 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 21 #include "content/public/browser/web_contents_delegate.h" |
| 21 #include "content/public/common/service_registry.h" | 22 #include "content/public/common/service_registry.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 23 | 24 |
| 24 namespace task_management { | 25 namespace task_management { |
| 25 | 26 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 icon, | 67 icon, |
| 67 render_process_host->GetHandle()), | 68 render_process_host->GetHandle()), |
| 68 web_contents_(web_contents), | 69 web_contents_(web_contents), |
| 69 render_process_host_(render_process_host), | 70 render_process_host_(render_process_host), |
| 70 renderer_resources_sampler_( | 71 renderer_resources_sampler_( |
| 71 CreateRendererResourcesSampler(render_process_host_)), | 72 CreateRendererResourcesSampler(render_process_host_)), |
| 72 render_process_id_(render_process_host_->GetID()), | 73 render_process_id_(render_process_host_->GetID()), |
| 73 v8_memory_allocated_(0), | 74 v8_memory_allocated_(0), |
| 74 v8_memory_used_(0), | 75 v8_memory_used_(0), |
| 75 webcache_stats_(), | 76 webcache_stats_(), |
| 76 profile_name_(GetRendererProfileName(render_process_host_)) { | 77 profile_name_(GetRendererProfileName(render_process_host_)), |
| 78 termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 79 termination_error_code_(0) { |
| 77 // All renderer tasks are capable of reporting network usage, so the default | 80 // All renderer tasks are capable of reporting network usage, so the default |
| 78 // invalid value of -1 doesn't apply here. | 81 // invalid value of -1 doesn't apply here. |
| 79 OnNetworkBytesRead(0); | 82 OnNetworkBytesRead(0); |
| 80 | 83 |
| 81 // Tag the web_contents with a |ContentFaviconDriver| (if needed) so that | 84 // Tag the web_contents with a |ContentFaviconDriver| (if needed) so that |
| 82 // we can use it to observe favicons changes. | 85 // we can use it to observe favicons changes. |
| 83 favicon::CreateContentFaviconDriverForWebContents(web_contents); | 86 favicon::CreateContentFaviconDriverForWebContents(web_contents); |
| 84 favicon::ContentFaviconDriver::FromWebContents(web_contents)->AddObserver( | 87 favicon::ContentFaviconDriver::FromWebContents(web_contents)->AddObserver( |
| 85 this); | 88 this); |
| 86 } | 89 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 125 } |
| 123 | 126 |
| 124 Task::Type RendererTask::GetType() const { | 127 Task::Type RendererTask::GetType() const { |
| 125 return Task::RENDERER; | 128 return Task::RENDERER; |
| 126 } | 129 } |
| 127 | 130 |
| 128 int RendererTask::GetChildProcessUniqueID() const { | 131 int RendererTask::GetChildProcessUniqueID() const { |
| 129 return render_process_id_; | 132 return render_process_id_; |
| 130 } | 133 } |
| 131 | 134 |
| 135 void RendererTask::GetTerminationStatus(base::TerminationStatus* out_status, |
| 136 int* out_error_code) const { |
| 137 DCHECK(out_status); |
| 138 DCHECK(out_error_code); |
| 139 |
| 140 *out_status = termination_status_; |
| 141 *out_error_code = termination_error_code_; |
| 142 } |
| 143 |
| 132 base::string16 RendererTask::GetProfileName() const { | 144 base::string16 RendererTask::GetProfileName() const { |
| 133 return profile_name_; | 145 return profile_name_; |
| 134 } | 146 } |
| 135 | 147 |
| 148 int RendererTask::GetTabId() const { |
| 149 return SessionTabHelper::IdForTab(web_contents_); |
| 150 } |
| 151 |
| 136 int64_t RendererTask::GetV8MemoryAllocated() const { | 152 int64_t RendererTask::GetV8MemoryAllocated() const { |
| 137 return v8_memory_allocated_; | 153 return v8_memory_allocated_; |
| 138 } | 154 } |
| 139 | 155 |
| 140 int64_t RendererTask::GetV8MemoryUsed() const { | 156 int64_t RendererTask::GetV8MemoryUsed() const { |
| 141 return v8_memory_used_; | 157 return v8_memory_used_; |
| 142 } | 158 } |
| 143 | 159 |
| 144 bool RendererTask::ReportsWebCacheStats() const { | 160 bool RendererTask::ReportsWebCacheStats() const { |
| 145 return true; | 161 return true; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (is_incognito) | 238 if (is_incognito) |
| 223 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; | 239 message_id = IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX; |
| 224 else | 240 else |
| 225 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; | 241 message_id = IDS_TASK_MANAGER_EXTENSION_PREFIX; |
| 226 } | 242 } |
| 227 | 243 |
| 228 return l10n_util::GetStringFUTF16(message_id, title); | 244 return l10n_util::GetStringFUTF16(message_id, title); |
| 229 } | 245 } |
| 230 | 246 |
| 231 } // namespace task_management | 247 } // namespace task_management |
| OLD | NEW |