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 #ifndef CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ |
6 #define CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 78 |
79 // Will be called to let the task refresh itself between refresh cycles. | 79 // Will be called to let the task refresh itself between refresh cycles. |
80 // |update_interval| is the time since the last task manager refresh. | 80 // |update_interval| is the time since the last task manager refresh. |
81 // the |refresh_flags| indicate which resources should be calculated on each | 81 // the |refresh_flags| indicate which resources should be calculated on each |
82 // refresh. | 82 // refresh. |
83 virtual void Refresh(const base::TimeDelta& update_interval, | 83 virtual void Refresh(const base::TimeDelta& update_interval, |
84 int64_t refresh_flags); | 84 int64_t refresh_flags); |
85 | 85 |
86 // Will receive this notification through the task manager from | 86 // Will receive this notification through the task manager from |
87 // |ChromeNetworkDelegate::OnNetworkBytesReceived()|. The task will add to the | 87 // |ChromeNetworkDelegate::OnNetworkBytesReceived()|. The task will add to the |
88 // |current_byte_count_| in this refresh cycle. | 88 // |current_read_byte_count_| in this refresh cycle. |
ncarter (slow)
2017/06/14 20:20:59
|current_read_byte_count_| no longer exists.
cburn
2017/06/16 21:52:27
Done. Changed to |cumulative_read_bytes_| as is do
| |
89 void OnNetworkBytesRead(int64_t bytes_read); | 89 void OnNetworkBytesRead(int64_t bytes_read); |
90 | 90 |
91 // Will receive this notification through the task manager from | |
92 // |ChromeNetworkDelegate::OnNetworkBytesSent()|. The task will add to the | |
93 // |current_sent_byte_count_| in this refresh cycle. | |
ncarter (slow)
2017/06/14 20:20:59
|current_sent_byte_count_| no longer exists.
cburn
2017/06/16 21:52:27
Done. Changed to |cumulative_sent_bytes_| as is do
| |
94 void OnNetworkBytesSent(int64_t bytes_sent); | |
95 | |
91 // Returns the task type. | 96 // Returns the task type. |
92 virtual Type GetType() const = 0; | 97 virtual Type GetType() const = 0; |
93 | 98 |
94 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It | 99 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It |
95 // is not the PID nor the handle of the process. | 100 // is not the PID nor the handle of the process. |
96 // For a task that represents the browser process, the return value is 0. For | 101 // For a task that represents the browser process, the return value is 0. For |
97 // other tasks that represent renderers and other child processes, the return | 102 // other tasks that represent renderers and other child processes, the return |
98 // value is whatever unique IDs of their hosts in the browser process. | 103 // value is whatever unique IDs of their hosts in the browser process. |
99 virtual int GetChildProcessUniqueID() const = 0; | 104 virtual int GetChildProcessUniqueID() const = 0; |
100 | 105 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 virtual bool ReportsWebCacheStats() const; | 140 virtual bool ReportsWebCacheStats() const; |
136 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; | 141 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; |
137 | 142 |
138 // Returns the keep-alive counter if the Task is an event page, -1 otherwise. | 143 // Returns the keep-alive counter if the Task is an event page, -1 otherwise. |
139 virtual int GetKeepaliveCount() const; | 144 virtual int GetKeepaliveCount() const; |
140 | 145 |
141 // Checking whether the task reports network usage. | 146 // Checking whether the task reports network usage. |
142 bool ReportsNetworkUsage() const; | 147 bool ReportsNetworkUsage() const; |
143 | 148 |
144 int64_t task_id() const { return task_id_; } | 149 int64_t task_id() const { return task_id_; } |
145 int64_t network_usage() const { return network_usage_; } | 150 |
ncarter (slow)
2017/06/14 20:20:59
// Returns the instantaneous rate, in bytes per se
cburn
2017/06/16 21:52:27
Agreed and added.
| |
151 int64_t network_usage_rate() const { | |
152 if (cumulative_bytes_sent_ == -1 && cumulative_bytes_read_ == -1) | |
153 return -1; | |
154 return network_sent_rate_ + network_read_rate_; | |
155 } | |
ncarter (slow)
2017/06/14 20:20:59
These methods aren't quite trivial, so they should
cburn
2017/06/16 21:52:27
I agree with the later suggestion and simplified t
| |
156 | |
ncarter (slow)
2017/06/14 20:20:59
// Returns the cumulative number of bytes of netwo
cburn
2017/06/16 21:52:26
I have kept it to be as up to date as possible. I
| |
157 int64_t cumulative_network_usage() const { | |
158 int64_t cumulative_bytes_read = | |
159 cumulative_bytes_read_ == -1 ? 0 : cumulative_bytes_read_; | |
160 int64_t cumulative_bytes_sent = | |
161 cumulative_bytes_sent_ == -1 ? 0 : cumulative_bytes_sent_; | |
162 return cumulative_bytes_sent + cumulative_bytes_read; | |
ncarter (slow)
2017/06/14 20:20:59
Should these be based on cumulative_bytes_read_ or
cburn
2017/06/16 21:52:27
I think it should be the most up to date informati
| |
163 } | |
164 | |
146 const base::string16& title() const { return title_; } | 165 const base::string16& title() const { return title_; } |
147 const std::string& rappor_sample_name() const { return rappor_sample_name_; } | 166 const std::string& rappor_sample_name() const { return rappor_sample_name_; } |
148 const gfx::ImageSkia& icon() const { return icon_; } | 167 const gfx::ImageSkia& icon() const { return icon_; } |
149 const base::ProcessHandle& process_handle() const { return process_handle_; } | 168 const base::ProcessHandle& process_handle() const { return process_handle_; } |
150 const base::ProcessId& process_id() const { return process_id_; } | 169 const base::ProcessId& process_id() const { return process_id_; } |
151 | 170 |
152 protected: | 171 protected: |
153 void set_title(const base::string16& new_title) { title_ = new_title; } | 172 void set_title(const base::string16& new_title) { title_ = new_title; } |
154 void set_rappor_sample_name(const std::string& sample) { | 173 void set_rappor_sample_name(const std::string& sample) { |
155 rappor_sample_name_ = sample; | 174 rappor_sample_name_ = sample; |
156 } | 175 } |
157 void set_icon(const gfx::ImageSkia& new_icon) { icon_ = new_icon; } | 176 void set_icon(const gfx::ImageSkia& new_icon) { icon_ = new_icon; } |
158 | 177 |
159 private: | 178 private: |
160 // The unique ID of this task. | 179 // The unique ID of this task. |
161 const int64_t task_id_; | 180 const int64_t task_id_; |
162 | 181 |
163 // The task's network usage in the current refresh cycle measured in bytes per | 182 // Keeps track of previous number of bytes sent on a refresh |
164 // second. A value of -1 means this task doesn't report network usage data. | 183 int64_t last_refresh_cumulative_bytes_sent_; |
165 int64_t network_usage_; | |
166 | 184 |
167 // The current network bytes received by this task during the current refresh | 185 // Keeps track of previous number of bytes read on a refresh |
168 // cycle. A value of -1 means this task has never been notified of any network | 186 int64_t last_refresh_cumulative_bytes_read_; |
169 // usage. | 187 |
170 int64_t current_byte_count_; | 188 // Keeps track of current number of bytes sent on a refresh |
ncarter (slow)
2017/06/14 20:20:58
After you finalize the code comment for cumulative
cburn
2017/06/16 21:52:27
Updated the language.
| |
189 int64_t cumulative_bytes_sent_; | |
190 | |
191 // Keeps track of current number of bytes read on a refresh | |
192 int64_t cumulative_bytes_read_; | |
193 | |
194 // Keeps track of the current network reading rate | |
195 int64_t network_sent_rate_; | |
196 | |
197 // Keeps track of the current network sending rate | |
ncarter (slow)
2017/06/14 20:20:59
In all of these comments, the "Keeps track of" can
cburn
2017/06/16 21:52:27
Updated the comments to have more signals to the p
| |
198 int64_t network_read_rate_; | |
171 | 199 |
172 // The title of the task. | 200 // The title of the task. |
173 base::string16 title_; | 201 base::string16 title_; |
174 | 202 |
175 // The name of the sample representing this task when a Rappor sample needs to | 203 // The name of the sample representing this task when a Rappor sample needs to |
176 // be recorded for it. | 204 // be recorded for it. |
177 std::string rappor_sample_name_; | 205 std::string rappor_sample_name_; |
178 | 206 |
179 // The favicon. | 207 // The favicon. |
180 gfx::ImageSkia icon_; | 208 gfx::ImageSkia icon_; |
181 | 209 |
182 // The handle of the process on which this task is running. | 210 // The handle of the process on which this task is running. |
183 const base::ProcessHandle process_handle_; | 211 const base::ProcessHandle process_handle_; |
184 | 212 |
185 // The PID of the process on which this task is running. | 213 // The PID of the process on which this task is running. |
186 const base::ProcessId process_id_; | 214 const base::ProcessId process_id_; |
187 | 215 |
188 DISALLOW_COPY_AND_ASSIGN(Task); | 216 DISALLOW_COPY_AND_ASSIGN(Task); |
189 }; | 217 }; |
190 | 218 |
191 } // namespace task_manager | 219 } // namespace task_manager |
192 | 220 |
193 #endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ | 221 #endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ |
OLD | NEW |