| 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/child_process_task.h" | 5 #include "chrome/browser/task_management/providers/child_process_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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 v8_memory_used_(-1), | 173 v8_memory_used_(-1), |
| 174 unique_child_process_id_(data.id), | 174 unique_child_process_id_(data.id), |
| 175 process_type_(data.process_type), | 175 process_type_(data.process_type), |
| 176 uses_v8_memory_(UsesV8Memory(process_type_)) { | 176 uses_v8_memory_(UsesV8Memory(process_type_)) { |
| 177 } | 177 } |
| 178 | 178 |
| 179 ChildProcessTask::~ChildProcessTask() { | 179 ChildProcessTask::~ChildProcessTask() { |
| 180 } | 180 } |
| 181 | 181 |
| 182 void ChildProcessTask::Refresh(const base::TimeDelta& update_interval, | 182 void ChildProcessTask::Refresh(const base::TimeDelta& update_interval, |
| 183 int64 refresh_flags) { | 183 int64_t refresh_flags) { |
| 184 Task::Refresh(update_interval, refresh_flags); | 184 Task::Refresh(update_interval, refresh_flags); |
| 185 | 185 |
| 186 if ((refresh_flags & REFRESH_TYPE_V8_MEMORY) == 0) | 186 if ((refresh_flags & REFRESH_TYPE_V8_MEMORY) == 0) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 if (!uses_v8_memory_) | 189 if (!uses_v8_memory_) |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 // The child process resources refresh is performed asynchronously, we will | 192 // The child process resources refresh is performed asynchronously, we will |
| 193 // invoke it and record the current values (which might be invalid at the | 193 // invoke it and record the current values (which might be invalid at the |
| 194 // moment. We can safely ignore that and count on future refresh cycles | 194 // moment. We can safely ignore that and count on future refresh cycles |
| 195 // potentially having valid values). | 195 // potentially having valid values). |
| 196 process_resources_sampler_->Refresh(base::Closure()); | 196 process_resources_sampler_->Refresh(base::Closure()); |
| 197 | 197 |
| 198 v8_memory_allocated_ = base::saturated_cast<int64>( | 198 v8_memory_allocated_ = base::saturated_cast<int64_t>( |
| 199 process_resources_sampler_->GetV8MemoryAllocated()); | 199 process_resources_sampler_->GetV8MemoryAllocated()); |
| 200 v8_memory_used_ = base::saturated_cast<int64>( | 200 v8_memory_used_ = base::saturated_cast<int64_t>( |
| 201 process_resources_sampler_->GetV8MemoryUsed()); | 201 process_resources_sampler_->GetV8MemoryUsed()); |
| 202 } | 202 } |
| 203 | 203 |
| 204 Task::Type ChildProcessTask::GetType() const { | 204 Task::Type ChildProcessTask::GetType() const { |
| 205 // Convert |content::ProcessType| to |task_management::Task::Type|. | 205 // Convert |content::ProcessType| to |task_management::Task::Type|. |
| 206 switch (process_type_) { | 206 switch (process_type_) { |
| 207 case content::PROCESS_TYPE_PLUGIN: | 207 case content::PROCESS_TYPE_PLUGIN: |
| 208 case content::PROCESS_TYPE_PPAPI_PLUGIN: | 208 case content::PROCESS_TYPE_PPAPI_PLUGIN: |
| 209 case content::PROCESS_TYPE_PPAPI_BROKER: | 209 case content::PROCESS_TYPE_PPAPI_BROKER: |
| 210 return Task::PLUGIN; | 210 return Task::PLUGIN; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 225 } | 225 } |
| 226 | 226 |
| 227 int ChildProcessTask::GetChildProcessUniqueID() const { | 227 int ChildProcessTask::GetChildProcessUniqueID() const { |
| 228 return unique_child_process_id_; | 228 return unique_child_process_id_; |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool ChildProcessTask::ReportsV8Memory() const { | 231 bool ChildProcessTask::ReportsV8Memory() const { |
| 232 return uses_v8_memory_ && process_resources_sampler_->ReportsV8MemoryStats(); | 232 return uses_v8_memory_ && process_resources_sampler_->ReportsV8MemoryStats(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 int64 ChildProcessTask::GetV8MemoryAllocated() const { | 235 int64_t ChildProcessTask::GetV8MemoryAllocated() const { |
| 236 return v8_memory_allocated_; | 236 return v8_memory_allocated_; |
| 237 } | 237 } |
| 238 | 238 |
| 239 int64 ChildProcessTask::GetV8MemoryUsed() const { | 239 int64_t ChildProcessTask::GetV8MemoryUsed() const { |
| 240 return v8_memory_used_; | 240 return v8_memory_used_; |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace task_management | 243 } // namespace task_management |
| OLD | NEW |