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_manager/sampling/task_manager_impl.h" | 5 #include "chrome/browser/task_manager/sampling/task_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return GetTaskByTaskId(task_id)->GetChildProcessUniqueID(); | 226 return GetTaskByTaskId(task_id)->GetChildProcessUniqueID(); |
227 } | 227 } |
228 | 228 |
229 void TaskManagerImpl::GetTerminationStatus(TaskId task_id, | 229 void TaskManagerImpl::GetTerminationStatus(TaskId task_id, |
230 base::TerminationStatus* out_status, | 230 base::TerminationStatus* out_status, |
231 int* out_error_code) const { | 231 int* out_error_code) const { |
232 GetTaskByTaskId(task_id)->GetTerminationStatus(out_status, out_error_code); | 232 GetTaskByTaskId(task_id)->GetTerminationStatus(out_status, out_error_code); |
233 } | 233 } |
234 | 234 |
235 int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { | 235 int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { |
236 return GetTaskByTaskId(task_id)->network_usage(); | 236 return GetTaskByTaskId(task_id)->network_usage_rate(); |
| 237 } |
| 238 |
| 239 int64_t TaskManagerImpl::GetCumulativeNetworkUsage(TaskId task_id) const { |
| 240 return GetTaskByTaskId(task_id)->cumulative_network_usage(); |
237 } | 241 } |
238 | 242 |
239 int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { | 243 int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { |
240 return GetTaskGroupByTaskId(task_id)->per_process_network_usage(); | 244 return GetTaskGroupByTaskId(task_id)->per_process_network_usage_rate(); |
| 245 } |
| 246 |
| 247 int64_t TaskManagerImpl::GetCumulativeProcessTotalNetworkUsage( |
| 248 TaskId task_id) const { |
| 249 return GetTaskGroupByTaskId(task_id)->cumulative_per_process_network_usage(); |
241 } | 250 } |
242 | 251 |
243 int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { | 252 int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { |
244 return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); | 253 return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); |
245 } | 254 } |
246 | 255 |
247 bool TaskManagerImpl::GetV8Memory(TaskId task_id, | 256 bool TaskManagerImpl::GetV8Memory(TaskId task_id, |
248 int64_t* allocated, | 257 int64_t* allocated, |
249 int64_t* used) const { | 258 int64_t* used) const { |
250 const Task* task = GetTaskByTaskId(task_id); | 259 const Task* task = GetTaskByTaskId(task_id); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 // Invalidate the cached sorted IDs by clearing the list. | 453 // Invalidate the cached sorted IDs by clearing the list. |
445 sorted_task_ids_.clear(); | 454 sorted_task_ids_.clear(); |
446 } | 455 } |
447 | 456 |
448 void TaskManagerImpl::TaskUnresponsive(Task* task) { | 457 void TaskManagerImpl::TaskUnresponsive(Task* task) { |
449 DCHECK(task); | 458 DCHECK(task); |
450 NotifyObserversOnTaskUnresponsive(task->task_id()); | 459 NotifyObserversOnTaskUnresponsive(task->task_id()); |
451 } | 460 } |
452 | 461 |
453 // static | 462 // static |
454 void TaskManagerImpl::OnMultipleBytesReadUI( | 463 void TaskManagerImpl::OnMultipleBytesTransferedUI( |
455 std::vector<BytesReadParam>* params) { | 464 std::vector<BytesTransferedParam>* params) { |
456 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 465 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
457 DCHECK(params); | 466 DCHECK(params); |
458 | 467 |
459 for (BytesReadParam& param : *params) { | 468 for (BytesTransferedParam& param : *params) { |
460 if (!GetInstance()->UpdateTasksWithBytesRead(param)) { | 469 if (!GetInstance()->UpdateTasksWithBytesTransfered(param)) { |
461 // We can't match a task to the notification. That might mean the | 470 // We can't match a task to the notification. That might mean the |
462 // tab that started a download was closed, or the request may have had | 471 // tab that started a download was closed, or the request may have had |
463 // no originating task associated with it in the first place. | 472 // no originating task associated with it in the first place. |
464 // We attribute orphaned/unaccounted activity to the Browser process. | 473 // We attribute orphaned/unaccounted activity to the Browser process. |
465 DCHECK(param.origin_pid || (param.child_id != -1)); | 474 DCHECK(param.origin_pid || (param.child_id != -1)); |
466 | 475 |
467 param.origin_pid = 0; | 476 param.origin_pid = 0; |
468 param.child_id = param.route_id = -1; | 477 param.child_id = param.route_id = -1; |
469 | 478 GetInstance()->UpdateTasksWithBytesTransfered(param); |
470 GetInstance()->UpdateTasksWithBytesRead(param); | |
471 } | 479 } |
472 } | 480 } |
473 } | 481 } |
474 | 482 |
475 void TaskManagerImpl::OnVideoMemoryUsageStatsUpdate( | 483 void TaskManagerImpl::OnVideoMemoryUsageStatsUpdate( |
476 const gpu::VideoMemoryUsageStats& gpu_memory_stats) { | 484 const gpu::VideoMemoryUsageStats& gpu_memory_stats) { |
477 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 485 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
478 | 486 |
479 gpu_memory_stats_ = gpu_memory_stats; | 487 gpu_memory_stats_ = gpu_memory_stats; |
480 } | 488 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 int route_id) const { | 536 int route_id) const { |
529 for (const auto& task_provider : task_providers_) { | 537 for (const auto& task_provider : task_providers_) { |
530 Task* task = | 538 Task* task = |
531 task_provider->GetTaskOfUrlRequest(origin_pid, child_id, route_id); | 539 task_provider->GetTaskOfUrlRequest(origin_pid, child_id, route_id); |
532 if (task) | 540 if (task) |
533 return task; | 541 return task; |
534 } | 542 } |
535 return nullptr; | 543 return nullptr; |
536 } | 544 } |
537 | 545 |
538 bool TaskManagerImpl::UpdateTasksWithBytesRead(const BytesReadParam& param) { | 546 bool TaskManagerImpl::UpdateTasksWithBytesTransfered( |
| 547 const BytesTransferedParam& param) { |
539 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 548 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
540 | 549 |
541 Task* task = | 550 Task* task = |
542 GetTaskByPidOrRoute(param.origin_pid, param.child_id, param.route_id); | 551 GetTaskByPidOrRoute(param.origin_pid, param.child_id, param.route_id); |
543 if (task) { | 552 if (task) { |
544 task->OnNetworkBytesRead(param.byte_count); | 553 task->OnNetworkBytesRead(param.byte_read_count); |
| 554 task->OnNetworkBytesSent(param.byte_sent_count); |
545 return true; | 555 return true; |
546 } | 556 } |
547 | 557 |
548 // Couldn't match the bytes to any existing task. | 558 // Couldn't match the bytes to any existing task. |
549 return false; | 559 return false; |
550 } | 560 } |
551 | 561 |
552 TaskGroup* TaskManagerImpl::GetTaskGroupByTaskId(TaskId task_id) const { | 562 TaskGroup* TaskManagerImpl::GetTaskGroupByTaskId(TaskId task_id) const { |
553 auto it = task_groups_by_task_id_.find(task_id); | 563 auto it = task_groups_by_task_id_.find(task_id); |
554 DCHECK(it != task_groups_by_task_id_.end()); | 564 DCHECK(it != task_groups_by_task_id_.end()); |
(...skipping 12 matching lines...) Expand all Loading... |
567 groups_itr.second->AreBackgroundCalculationsDone(); | 577 groups_itr.second->AreBackgroundCalculationsDone(); |
568 } | 578 } |
569 if (are_all_processes_data_ready) { | 579 if (are_all_processes_data_ready) { |
570 NotifyObserversOnRefreshWithBackgroundCalculations(GetTaskIdsList()); | 580 NotifyObserversOnRefreshWithBackgroundCalculations(GetTaskIdsList()); |
571 for (const auto& groups_itr : task_groups_by_proc_id_) | 581 for (const auto& groups_itr : task_groups_by_proc_id_) |
572 groups_itr.second->ClearCurrentBackgroundCalculationsFlags(); | 582 groups_itr.second->ClearCurrentBackgroundCalculationsFlags(); |
573 } | 583 } |
574 } | 584 } |
575 | 585 |
576 } // namespace task_manager | 586 } // namespace task_manager |
OLD | NEW |