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

Side by Side Diff: chrome/browser/task_manager/providers/task.h

Issue 2905403002: plumb network upload into the task manager (Closed)
Patch Set: js formatting, fixing spelling, modifying browser tests Created 3 years, 6 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_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
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
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/20 19:52:27 received is still typo
cburn 2017/06/20 21:34:55 Done.
150 int64_t network_usage_rate() const {
151 return network_sent_rate_ + network_read_rate_;
152 }
153
154 // Returns the cumulative number of bytes of network use (sent and received)
155 // over the tasks lifetime. It is calculated independently of refreshes and
156 // is based on the current |cumulative_bytes_read_| and
157 // |cumulative_bytes_sent_|.
158 int64_t cumulative_network_usage() const {
159 return cumulative_bytes_sent_ + cumulative_bytes_read_;
160 }
161
146 const base::string16& title() const { return title_; } 162 const base::string16& title() const { return title_; }
147 const std::string& rappor_sample_name() const { return rappor_sample_name_; } 163 const std::string& rappor_sample_name() const { return rappor_sample_name_; }
148 const gfx::ImageSkia& icon() const { return icon_; } 164 const gfx::ImageSkia& icon() const { return icon_; }
149 const base::ProcessHandle& process_handle() const { return process_handle_; } 165 const base::ProcessHandle& process_handle() const { return process_handle_; }
150 const base::ProcessId& process_id() const { return process_id_; } 166 const base::ProcessId& process_id() const { return process_id_; }
151 167
152 protected: 168 protected:
153 void set_title(const base::string16& new_title) { title_ = new_title; } 169 void set_title(const base::string16& new_title) { title_ = new_title; }
154 void set_rappor_sample_name(const std::string& sample) { 170 void set_rappor_sample_name(const std::string& sample) {
155 rappor_sample_name_ = sample; 171 rappor_sample_name_ = sample;
156 } 172 }
157 void set_icon(const gfx::ImageSkia& new_icon) { icon_ = new_icon; } 173 void set_icon(const gfx::ImageSkia& new_icon) { icon_ = new_icon; }
158 174
159 private: 175 private:
160 // The unique ID of this task. 176 // The unique ID of this task.
161 const int64_t task_id_; 177 const int64_t task_id_;
162 178
163 // The task's network usage in the current refresh cycle measured in bytes per 179 // 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. 180 // the last refresh.
165 int64_t network_usage_; 181 int64_t last_refresh_cumulative_bytes_sent_;
166 182
167 // The current network bytes received by this task during the current refresh 183 // 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 184 // at the last refresh.
169 // usage. 185 int64_t last_refresh_cumulative_bytes_read_;
170 int64_t current_byte_count_; 186
187 // A continuously updating sum of all bytes that have been uploaded from this
188 // task. It is assigned to |last_refresh_cumulative_bytes_sent_| at the end
189 // of a refresh.
190 int64_t cumulative_bytes_sent_;
191
192 // A continuously updating sum of all bytes that have been downloaded from
193 // this task. It is assigned to |last_refresh_cumulative_bytes_sent_| at the
194 // end of a refresh.
195 int64_t cumulative_bytes_read_;
196
197 // The upload rate (in bytes per second) for this task during the latest
198 // refresh.
199 int64_t network_sent_rate_;
200
201 // The download rate (in bytes per second) for this task during the latest
202 // refresh.
203 int64_t network_read_rate_;
171 204
172 // The title of the task. 205 // The title of the task.
173 base::string16 title_; 206 base::string16 title_;
174 207
175 // The name of the sample representing this task when a Rappor sample needs to 208 // The name of the sample representing this task when a Rappor sample needs to
176 // be recorded for it. 209 // be recorded for it.
177 std::string rappor_sample_name_; 210 std::string rappor_sample_name_;
178 211
179 // The favicon. 212 // The favicon.
180 gfx::ImageSkia icon_; 213 gfx::ImageSkia icon_;
181 214
182 // The handle of the process on which this task is running. 215 // The handle of the process on which this task is running.
183 const base::ProcessHandle process_handle_; 216 const base::ProcessHandle process_handle_;
184 217
185 // The PID of the process on which this task is running. 218 // The PID of the process on which this task is running.
186 const base::ProcessId process_id_; 219 const base::ProcessId process_id_;
187 220
188 DISALLOW_COPY_AND_ASSIGN(Task); 221 DISALLOW_COPY_AND_ASSIGN(Task);
189 }; 222 };
190 223
191 } // namespace task_manager 224 } // namespace task_manager
192 225
193 #endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_ 226 #endif // CHROME_BROWSER_TASK_MANAGER_PROVIDERS_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698