Index: chrome/browser/task_manager/sampling/task_manager_impl.cc |
diff --git a/chrome/browser/task_manager/sampling/task_manager_impl.cc b/chrome/browser/task_manager/sampling/task_manager_impl.cc |
index aab3f46770eaf7fd4be07856bc040329d76adf91..d1a5bef94b49ae1e2ecf4265fd821d37368e48f1 100644 |
--- a/chrome/browser/task_manager/sampling/task_manager_impl.cc |
+++ b/chrome/browser/task_manager/sampling/task_manager_impl.cc |
@@ -236,10 +236,19 @@ int64_t TaskManagerImpl::GetNetworkUsage(TaskId task_id) const { |
return GetTaskByTaskId(task_id)->network_usage(); |
} |
+int64_t TaskManagerImpl::GetTotalNetworkUsage(TaskId task_id) const { |
+ return GetTaskByTaskId(task_id)->total_network_usage(); |
+} |
+ |
int64_t TaskManagerImpl::GetProcessTotalNetworkUsage(TaskId task_id) const { |
return GetTaskGroupByTaskId(task_id)->per_process_network_usage(); |
} |
+int64_t TaskManagerImpl::GetTotalProcessTotalNetworkUsage( |
+ TaskId task_id) const { |
+ return GetTaskGroupByTaskId(task_id)->total_per_process_network_usage(); |
+} |
+ |
int64_t TaskManagerImpl::GetSqliteMemoryUsed(TaskId task_id) const { |
return GetTaskByTaskId(task_id)->GetSqliteMemoryUsed(); |
} |
@@ -452,11 +461,11 @@ void TaskManagerImpl::TaskUnresponsive(Task* task) { |
// static |
void TaskManagerImpl::OnMultipleBytesReadUI( |
- std::vector<BytesReadParam>* params) { |
+ std::vector<BytesTransferedParam>* params) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
DCHECK(params); |
- for (BytesReadParam& param : *params) { |
+ for (BytesTransferedParam& param : *params) { |
if (!GetInstance()->UpdateTasksWithBytesRead(param)) { |
// We can't match a task to the notification. That might mean the |
// tab that started a download was closed, or the request may have had |
@@ -472,6 +481,28 @@ void TaskManagerImpl::OnMultipleBytesReadUI( |
} |
} |
+// static |
+void TaskManagerImpl::OnMultipleBytesSentUI( |
ncarter (slow)
2017/06/08 23:37:18
Once BytesTransferedParam holds both send and read
cburn
2017/06/14 18:04:37
Done. Named it OnMultipleBytesTransfered to try to
|
+ std::vector<BytesTransferedParam>* params) { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ DCHECK(params); |
+ |
+ for (BytesTransferedParam& param : *params) { |
+ if (!GetInstance()->UpdateTasksWithBytesSent(param)) { |
+ // We can't match a task to the notification. That might mean the |
+ // tab that started a download was closed, or the request may have had |
+ // no originating task associated with it in the first place. |
+ // We attribute orphaned/unaccounted activity to the Browser process. |
+ DCHECK(param.origin_pid || (param.child_id != -1)); |
+ |
+ param.origin_pid = 0; |
+ param.child_id = param.route_id = -1; |
+ |
+ GetInstance()->UpdateTasksWithBytesSent(param); |
+ } |
+ } |
+} |
+ |
void TaskManagerImpl::OnVideoMemoryUsageStatsUpdate( |
const gpu::VideoMemoryUsageStats& gpu_memory_stats) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
@@ -535,7 +566,8 @@ Task* TaskManagerImpl::GetTaskByPidOrRoute(int origin_pid, |
return nullptr; |
} |
-bool TaskManagerImpl::UpdateTasksWithBytesRead(const BytesReadParam& param) { |
+bool TaskManagerImpl::UpdateTasksWithBytesRead( |
ncarter (slow)
2017/06/08 23:37:18
Merge this function with TaskManagerImpl::UpdateTa
cburn
2017/06/14 18:04:38
Done. I went with UpdateTasksWithBytesTransfered t
|
+ const BytesTransferedParam& param) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
Task* task = |
@@ -549,6 +581,21 @@ bool TaskManagerImpl::UpdateTasksWithBytesRead(const BytesReadParam& param) { |
return false; |
} |
+bool TaskManagerImpl::UpdateTasksWithBytesSent( |
+ const BytesTransferedParam& param) { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ |
+ Task* task = |
+ GetTaskByPidOrRoute(param.origin_pid, param.child_id, param.route_id); |
+ if (task) { |
+ task->OnNetworkBytesSent(param.byte_count); |
+ return true; |
+ } |
+ |
+ // Couldn't match the bytes to any existing task. |
+ return false; |
+} |
+ |
TaskGroup* TaskManagerImpl::GetTaskGroupByTaskId(TaskId task_id) const { |
auto it = task_groups_by_task_id_.find(task_id); |
DCHECK(it != task_groups_by_task_id_.end()); |