summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Fakhry <afakhry@google.com>2015-09-04 10:00:18 -0700
committerAhmed Fakhry <afakhry@google.com>2015-09-04 17:01:20 +0000
commita0fd3504cff46661a4848eafc01c5d1dd5ff430f (patch)
tree821a3f2760ce0e11d290207dedd9054fff6c08ad
parentb12296f0a1c2aca8a8770a42cfdae62deab9483c (diff)
downloadchromium_src-a0fd3504cff46661a4848eafc01c5d1dd5ff430f.zip
chromium_src-a0fd3504cff46661a4848eafc01c5d1dd5ff430f.tar.gz
chromium_src-a0fd3504cff46661a4848eafc01c5d1dd5ff430f.tar.bz2
TaskManager table's default sort should show the browser process at the top.
We have to ensure that the task manager by default (without any sorting) shows the browser process task at the top of the list. This CL also makes the RendererTasks match the old task manager behavior by showing zeros for their network usage instead of N/As even when no network bytes have been reported for them. TBR=nick@chromium.org BUG=523992 Review URL: https://codereview.chromium.org/1322043003 Cr-Commit-Position: refs/heads/master@{#346950} (cherry picked from commit 5a3948d1382d4c90b96d867e64255e59a1502759) Review URL: https://codereview.chromium.org/1310363005 . Cr-Commit-Position: refs/branch-heads/2490@{#166} Cr-Branched-From: 7790a3535f2a81a03685eca31a32cf69ae0c114f-refs/heads/master@{#344925}
-rw-r--r--chrome/browser/task_management/providers/web_contents/printing_task.cc4
-rw-r--r--chrome/browser/task_management/providers/web_contents/renderer_task.cc3
-rw-r--r--chrome/browser/task_management/providers/web_contents/tab_contents_task.cc4
-rw-r--r--chrome/browser/task_management/sampling/task_group_sampler.h3
-rw-r--r--chrome/browser/task_management/sampling/task_manager_impl.cc16
-rw-r--r--chrome/browser/task_management/task_manager_interface.h5
-rw-r--r--chrome/browser/task_management/task_manager_observer.h6
7 files changed, 30 insertions, 11 deletions
diff --git a/chrome/browser/task_management/providers/web_contents/printing_task.cc b/chrome/browser/task_management/providers/web_contents/printing_task.cc
index fef4efc..808fc63 100644
--- a/chrome/browser/task_management/providers/web_contents/printing_task.cc
+++ b/chrome/browser/task_management/providers/web_contents/printing_task.cc
@@ -34,7 +34,9 @@ void PrintingTask::OnTitleChanged(content::NavigationEntry* entry) {
}
void PrintingTask::OnFaviconChanged() {
- set_icon(*RendererTask::GetFaviconFromWebContents(web_contents()));
+ const gfx::ImageSkia* icon =
+ RendererTask::GetFaviconFromWebContents(web_contents());
+ set_icon(icon ? *icon : gfx::ImageSkia());
}
} // namespace task_management
diff --git a/chrome/browser/task_management/providers/web_contents/renderer_task.cc b/chrome/browser/task_management/providers/web_contents/renderer_task.cc
index 6b5acad..371a7cb 100644
--- a/chrome/browser/task_management/providers/web_contents/renderer_task.cc
+++ b/chrome/browser/task_management/providers/web_contents/renderer_task.cc
@@ -75,6 +75,9 @@ RendererTask::RendererTask(const base::string16& title,
v8_memory_used_(0),
webcache_stats_(),
profile_name_(GetRendererProfileName(render_process_host_)) {
+ // All renderer tasks are capable of reporting network usage, so the default
+ // invalid value of -1 doesn't apply here.
+ OnNetworkBytesRead(0);
}
RendererTask::~RendererTask() {
diff --git a/chrome/browser/task_management/providers/web_contents/tab_contents_task.cc b/chrome/browser/task_management/providers/web_contents/tab_contents_task.cc
index 20ebbe7..9e36039 100644
--- a/chrome/browser/task_management/providers/web_contents/tab_contents_task.cc
+++ b/chrome/browser/task_management/providers/web_contents/tab_contents_task.cc
@@ -39,7 +39,9 @@ void TabContentsTask::OnTitleChanged(content::NavigationEntry* entry) {
}
void TabContentsTask::OnFaviconChanged() {
- set_icon(*RendererTask::GetFaviconFromWebContents(web_contents()));
+ const gfx::ImageSkia* icon =
+ RendererTask::GetFaviconFromWebContents(web_contents());
+ set_icon(icon ? *icon : gfx::ImageSkia());
}
Task::Type TabContentsTask::GetType() const {
diff --git a/chrome/browser/task_management/sampling/task_group_sampler.h b/chrome/browser/task_management/sampling/task_group_sampler.h
index 1284c25..6521fe4 100644
--- a/chrome/browser/task_management/sampling/task_group_sampler.h
+++ b/chrome/browser/task_management/sampling/task_group_sampler.h
@@ -48,8 +48,7 @@ class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> {
const OnIdleWakeupsCallback& on_idle_wakeups);
// Refreshes the expensive process' stats (CPU usage, memory usage, and idle
- // wakeups per second) on the worker thread. It will crash if
- // SetOnRefreshCallbacks() hasn't been called yet.
+ // wakeups per second) on the worker thread.
void Refresh(int64 refresh_flags);
private:
diff --git a/chrome/browser/task_management/sampling/task_manager_impl.cc b/chrome/browser/task_management/sampling/task_manager_impl.cc
index 32fc31a..9779343 100644
--- a/chrome/browser/task_management/sampling/task_manager_impl.cc
+++ b/chrome/browser/task_management/sampling/task_manager_impl.cc
@@ -186,8 +186,19 @@ const TaskIdList& TaskManagerImpl::GetTaskIdsList() const {
if (sorted_task_ids_.empty()) {
sorted_task_ids_.reserve(task_groups_by_task_id_.size());
- for (const auto& groups_pair : task_groups_by_proc_id_)
+
+ // Ensure browser process group of task IDs are at the beginning of the
+ // list.
+ const TaskGroup* browser_group =
+ task_groups_by_proc_id_.at(base::GetCurrentProcId());
+ browser_group->AppendSortedTaskIds(&sorted_task_ids_);
+
+ for (const auto& groups_pair : task_groups_by_proc_id_) {
+ if (groups_pair.second == browser_group)
+ continue;
+
groups_pair.second->AppendSortedTaskIds(&sorted_task_ids_);
+ }
}
return sorted_task_ids_;
@@ -290,8 +301,7 @@ void TaskManagerImpl::Refresh() {
enabled_resources_flags());
}
- TaskIdList task_ids(GetTaskIdsList());
- NotifyObserversOnRefresh(task_ids);
+ NotifyObserversOnRefresh(GetTaskIdsList());
}
void TaskManagerImpl::StartUpdating() {
diff --git a/chrome/browser/task_management/task_manager_interface.h b/chrome/browser/task_management/task_manager_interface.h
index 5ea482e..716e449 100644
--- a/chrome/browser/task_management/task_manager_interface.h
+++ b/chrome/browser/task_management/task_manager_interface.h
@@ -119,8 +119,9 @@ class TaskManagerInterface {
blink::WebCache::ResourceTypeStats* stats) const = 0;
// Gets the list of task IDs currently tracked by the task manager. The list
- // will be sorted by the process IDs on which the tasks are running, then by
- // the task IDs themselves.
+ // will be sorted such that the task representing the browser process is at
+ // the top of the list and the rest of the IDs will be sorted by the process
+ // IDs on which the tasks are running, then by the task IDs themselves.
virtual const TaskIdList& GetTaskIdsList() const = 0;
// Gets the number of task-manager tasks running on the same process on which
diff --git a/chrome/browser/task_management/task_manager_observer.h b/chrome/browser/task_management/task_manager_observer.h
index ba7d988..49b80da 100644
--- a/chrome/browser/task_management/task_manager_observer.h
+++ b/chrome/browser/task_management/task_manager_observer.h
@@ -66,8 +66,10 @@ class TaskManagerObserver {
// Notifies the observer that the task manager has just finished a refresh
// cycle to calculate the resources usage of all tasks whose IDs are given in
- // |task_ids|. |task_ids| will be sorted by process IDs first, then by task
- // IDs.
+ // |task_ids|. |task_ids| will be sorted such that the task representing the
+ // browser process is at the top of the list and the rest of the IDs will be
+ // sorted by the process IDs on which the tasks are running, then by the task
+ // IDs themselves.
virtual void OnTasksRefreshed(const TaskIdList& task_ids) = 0;
const base::TimeDelta& desired_refresh_time() const {