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 // |cummulative_read_bytes_|. |
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 // |cummulative_sent_bytes_| in this refresh cycle. | |
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 30 matching lines...) Expand all Loading... | |
131 virtual int64_t GetV8MemoryUsed() const; | 136 virtual int64_t GetV8MemoryUsed() const; |
132 | 137 |
133 // Checking if the task reports Webkit resource cache statistics and getting | 138 // Checking if the task reports Webkit resource cache statistics and getting |
134 // them if it does. | 139 // them if it does. |
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 int64_t task_id() const { return task_id_; } |
142 bool ReportsNetworkUsage() const; | |
143 | 147 |
144 int64_t task_id() const { return task_id_; } | 148 // Returns the instantaneous rate, in bytes per second, of network usage |
145 int64_t network_usage() const { return network_usage_; } | 149 // (sent and recieved), as measured over the last refresh cycle. |
ncarter (slow)
2017/06/16 22:28:30
recieved -> received
(I always get this wrong)
cburn
2017/06/19 22:07:08
Done.
| |
150 int64_t network_usage_rate() const { | |
151 // This needs the |&& ! ReportNetworkUsage()| because it should only report | |
152 // -1 When there hasnt been any traffic. This is only true when both rates | |
153 // are 0 and ReportsNetworkUsage is also false. | |
ncarter (slow)
2017/06/16 22:28:30
Delete these three comment lines.
cburn
2017/06/19 22:07:08
Done.
| |
154 return network_sent_rate_ + network_read_rate_; | |
155 } | |
156 | |
157 // Returns the cumulative number of bytes of network use (sent and recieved) | |
158 // over the tasks lifetime. It is calculated independantly of refreshes and | |
ncarter (slow)
2017/06/16 22:28:30
tasks -> task's
independantly -> independently
cburn
2017/06/19 22:07:08
Done. I also have sublime doing spell checking on
| |
159 // is based on the current |cumulative_bytes_read_| and | |
160 // |cumulative_bytes_sent_|. | |
161 int64_t cumulative_network_usage() const { | |
162 return cumulative_bytes_sent_ + cumulative_bytes_read_; | |
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 // The sum of all bytes that have been uploaded from this task calculated at |
164 // second. A value of -1 means this task doesn't report network usage data. | 183 // the last refresh. |
165 int64_t network_usage_; | 184 int64_t last_refresh_cumulative_bytes_sent_; |
166 | 185 |
167 // The current network bytes received by this task during the current refresh | 186 // The sum of all bytes that have been downloaded from this task calculated |
168 // cycle. A value of -1 means this task has never been notified of any network | 187 // at the last refresh. |
169 // usage. | 188 int64_t last_refresh_cumulative_bytes_read_; |
170 int64_t current_byte_count_; | 189 |
190 // A continuously updating sum of all bytes that have been uploaded from this | |
191 // task. It is assigned to |last_refresh_cumulative_bytes_sent_| at the end | |
192 // of a refresh. | |
193 int64_t cumulative_bytes_sent_; | |
194 | |
195 // A continuously updating sum of all bytes that have been downloaded from | |
196 // this task. It is assigned to |last_refresh_cumulative_bytes_sent_| at the | |
197 // end of a refresh. | |
198 int64_t cumulative_bytes_read_; | |
199 | |
200 // The upload rate (in bytes per second) for htis task during the latest | |
ncarter (slow)
2017/06/16 22:28:30
htis -> this
cburn
2017/06/19 22:07:08
Done.
| |
201 // refresh. | |
202 int64_t network_sent_rate_; | |
203 | |
204 // The download rate (in bytes per second) for this task during the latest | |
205 // refresh. | |
206 int64_t network_read_rate_; | |
171 | 207 |
172 // The title of the task. | 208 // The title of the task. |
173 base::string16 title_; | 209 base::string16 title_; |
174 | 210 |
175 // The name of the sample representing this task when a Rappor sample needs to | 211 // The name of the sample representing this task when a Rappor sample needs to |
176 // be recorded for it. | 212 // be recorded for it. |
177 std::string rappor_sample_name_; | 213 std::string rappor_sample_name_; |
178 | 214 |
179 // The favicon. | 215 // The favicon. |
180 gfx::ImageSkia icon_; | 216 gfx::ImageSkia icon_; |
181 | 217 |
182 // The handle of the process on which this task is running. | 218 // The handle of the process on which this task is running. |
183 const base::ProcessHandle process_handle_; | 219 const base::ProcessHandle process_handle_; |
184 | 220 |
185 // The PID of the process on which this task is running. | 221 // The PID of the process on which this task is running. |
186 const base::ProcessId process_id_; | 222 const base::ProcessId process_id_; |
187 | 223 |
188 DISALLOW_COPY_AND_ASSIGN(Task); | 224 DISALLOW_COPY_AND_ASSIGN(Task); |
189 }; | 225 }; |
190 | 226 |
191 } // namespace task_manager | 227 } // namespace task_manager |
192 | 228 |
193 #endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ | 229 #endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ |
OLD | NEW |