Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: chrome/browser/task_management/sampling/task_group.h

Issue 1584473004: Migrate ProcessesEventRouter to the new task manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix edge case in detecting background calculations completion Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ 6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 11 matching lines...) Expand all
22 22
23 namespace task_management { 23 namespace task_management {
24 24
25 // Defines a group of tasks tracked by the task manager which belong to the same 25 // Defines a group of tasks tracked by the task manager which belong to the same
26 // process. This class lives on the UI thread. 26 // process. This class lives on the UI thread.
27 class TaskGroup { 27 class TaskGroup {
28 public: 28 public:
29 TaskGroup( 29 TaskGroup(
30 base::ProcessHandle proc_handle, 30 base::ProcessHandle proc_handle,
31 base::ProcessId proc_id, 31 base::ProcessId proc_id,
32 const base::Closure& on_background_calculations_done,
32 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); 33 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner);
33 ~TaskGroup(); 34 ~TaskGroup();
34 35
35 // Adds and removes the given |task| to this group. |task| must be running on 36 // Adds and removes the given |task| to this group. |task| must be running on
36 // the same process represented by this group. 37 // the same process represented by this group.
37 void AddTask(Task* task); 38 void AddTask(Task* task);
38 void RemoveTask(Task* task); 39 void RemoveTask(Task* task);
39 40
40 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats, 41 void Refresh(const content::GPUVideoMemoryUsageStats& gpu_memory_stats,
41 base::TimeDelta update_interval, 42 base::TimeDelta update_interval,
42 int64_t refresh_flags); 43 int64_t refresh_flags);
43 44
44 // Appends the sorted IDs of the tasks that belong to this group to 45 // Appends the sorted IDs of the tasks that belong to this group to
45 // |out_list|. 46 // |out_list|.
46 void AppendSortedTaskIds(TaskIdList* out_list) const; 47 void AppendSortedTaskIds(TaskIdList* out_list) const;
47 48
48 Task* GetTaskById(TaskId task_id) const; 49 Task* GetTaskById(TaskId task_id) const;
49 50
51 // This is to be called after the task manager had informed its observers with
52 // OnTasksRefreshedWithBackgroundCalculations() to begin another cycle for
53 // this notification type.
54 void ClearCurrentBackgroundCalculationsFlags();
55
56 // True if all enabled background operations calculating resource usage of the
57 // process represented by this TaskGroup have completed.
58 bool AreBackgroundCalculationsDone() const;
59
50 const base::ProcessHandle& process_handle() const { return process_handle_; } 60 const base::ProcessHandle& process_handle() const { return process_handle_; }
51 const base::ProcessId& process_id() const { return process_id_; } 61 const base::ProcessId& process_id() const { return process_id_; }
52 62
53 size_t num_tasks() const { return tasks_.size(); } 63 size_t num_tasks() const { return tasks_.size(); }
54 bool empty() const { return tasks_.empty(); } 64 bool empty() const { return tasks_.empty(); }
55 65
56 double cpu_usage() const { return cpu_usage_; } 66 double cpu_usage() const { return cpu_usage_; }
57 int64_t private_bytes() const { return memory_usage_.private_bytes; } 67 int64_t private_bytes() const { return memory_usage_.private_bytes; }
58 int64_t shared_bytes() const { return memory_usage_.shared_bytes; } 68 int64_t shared_bytes() const { return memory_usage_.shared_bytes; }
59 int64_t physical_bytes() const { return memory_usage_.physical_bytes; } 69 int64_t physical_bytes() const { return memory_usage_.physical_bytes; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage); 105 void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage);
96 106
97 void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second); 107 void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second);
98 108
99 #if defined(OS_LINUX) 109 #if defined(OS_LINUX)
100 void OnOpenFdCountRefreshDone(int open_fd_count); 110 void OnOpenFdCountRefreshDone(int open_fd_count);
101 #endif // defined(OS_LINUX) 111 #endif // defined(OS_LINUX)
102 112
103 void OnProcessPriorityDone(bool is_backgrounded); 113 void OnProcessPriorityDone(bool is_backgrounded);
104 114
115 void OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type);
116
105 // The process' handle and ID. 117 // The process' handle and ID.
106 base::ProcessHandle process_handle_; 118 base::ProcessHandle process_handle_;
107 base::ProcessId process_id_; 119 base::ProcessId process_id_;
108 120
121 // This is a callback into the TaskManagerImpl to inform it that the
122 // background calculations for this TaskGroup has finished.
123 const base::Closure on_background_calculations_done_;
124
109 scoped_refptr<TaskGroupSampler> worker_thread_sampler_; 125 scoped_refptr<TaskGroupSampler> worker_thread_sampler_;
110 126
111 // Maps the Tasks by their IDs. 127 // Maps the Tasks by their IDs.
112 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders. 128 // Tasks are not owned by the TaskGroup. They're owned by the TaskProviders.
113 std::map<TaskId, Task*> tasks_; 129 std::map<TaskId, Task*> tasks_;
114 130
131 // Flags will be used to determine when the background calculations has
132 // completed for the enabled refresh types for this TaskGroup.
133 int64_t expected_on_bg_done_flags_;
134 int64_t current_on_bg_done_flags_;
135
115 // The per process resources usages. 136 // The per process resources usages.
116 double cpu_usage_; 137 double cpu_usage_;
117 MemoryUsageStats memory_usage_; 138 MemoryUsageStats memory_usage_;
118 int64_t gpu_memory_; 139 int64_t gpu_memory_;
119 // The network usage in bytes per second as the sum of all network usages of 140 // The network usage in bytes per second as the sum of all network usages of
120 // the individual tasks sharing the same process. 141 // the individual tasks sharing the same process.
121 int64_t per_process_network_usage_; 142 int64_t per_process_network_usage_;
122 #if defined(OS_WIN) 143 #if defined(OS_WIN)
123 // Windows GDI and USER Handles. 144 // Windows GDI and USER Handles.
124 int64_t gdi_current_handles_; 145 int64_t gdi_current_handles_;
(...skipping 16 matching lines...) Expand all
141 // destroyed. 162 // destroyed.
142 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_; 163 base::WeakPtrFactory<TaskGroup> weak_ptr_factory_;
143 164
144 DISALLOW_COPY_AND_ASSIGN(TaskGroup); 165 DISALLOW_COPY_AND_ASSIGN(TaskGroup);
145 }; 166 };
146 167
147 } // namespace task_management 168 } // namespace task_management
148 169
149 170
150 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_ 171 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698