| Index: chrome/browser/task_manager/providers/task.cc
|
| diff --git a/chrome/browser/task_manager/providers/task.cc b/chrome/browser/task_manager/providers/task.cc
|
| index a49032f6875cd6612cc2777b5606b34ff56d9356..afe17dc29bc0cbf78d8605b166883c13917d9676 100644
|
| --- a/chrome/browser/task_manager/providers/task.cc
|
| +++ b/chrome/browser/task_manager/providers/task.cc
|
| @@ -31,7 +31,13 @@ Task::Task(const base::string16& title,
|
| base::ProcessId process_id)
|
| : task_id_(g_last_id++),
|
| network_usage_(-1),
|
| - current_byte_count_(-1),
|
| + total_network_usage_(0),
|
| + network_read_usage_(-1),
|
| + network_sent_usage_(-1),
|
| + current_read_byte_count_(-1),
|
| + current_sent_byte_count_(-1),
|
| + total_read_byte_count_(0),
|
| + total_sent_byte_count_(0),
|
| title_(title),
|
| rappor_sample_name_(rappor_sample),
|
| icon_(icon ? *icon : gfx::ImageSkia()),
|
| @@ -73,21 +79,56 @@ void Task::Refresh(const base::TimeDelta& update_interval,
|
| if ((refresh_flags & REFRESH_TYPE_NETWORK_USAGE) == 0)
|
| return;
|
|
|
| - if (current_byte_count_ == -1)
|
| + if (current_read_byte_count_ == -1 && current_sent_byte_count_ == -1)
|
| return;
|
|
|
| - network_usage_ =
|
| - (current_byte_count_ * base::TimeDelta::FromSeconds(1)) / update_interval;
|
| + if (current_read_byte_count_ == -1) {
|
| + network_read_usage_ = 0;
|
| + } else {
|
| + network_read_usage_ =
|
| + (current_read_byte_count_ * base::TimeDelta::FromSeconds(1)) /
|
| + update_interval;
|
| + }
|
| +
|
| + if (current_sent_byte_count_ == -1) {
|
| + network_sent_usage_ = 0;
|
| + } else {
|
| + network_sent_usage_ =
|
| + (current_sent_byte_count_ * base::TimeDelta::FromSeconds(1)) /
|
| + update_interval;
|
| + }
|
| +
|
| + network_usage_ = network_read_usage_ + network_sent_usage_;
|
| +
|
| + total_read_byte_count_ +=
|
| + current_read_byte_count_ == -1 ? 0 : current_read_byte_count_;
|
| + total_sent_byte_count_ +=
|
| + current_sent_byte_count_ == -1 ? 0 : current_sent_byte_count_;
|
|
|
| // Reset the current byte count for this task.
|
| - current_byte_count_ = 0;
|
| + current_read_byte_count_ = 0;
|
| + current_sent_byte_count_ = 0;
|
| +
|
| + // Since this isn't getting a rate and is just summing all network use
|
| + total_network_usage_ = total_read_byte_count_ + total_sent_byte_count_;
|
| }
|
|
|
| void Task::OnNetworkBytesRead(int64_t bytes_read) {
|
| - if (current_byte_count_ == -1)
|
| - current_byte_count_ = 0;
|
| + if (current_read_byte_count_ == -1) {
|
| + current_read_byte_count_ = 0;
|
| + total_read_byte_count_ = 0;
|
| + }
|
| +
|
| + current_read_byte_count_ += bytes_read;
|
| +}
|
| +
|
| +void Task::OnNetworkBytesSent(int64_t bytes_sent) {
|
| + if (current_sent_byte_count_ == -1) {
|
| + current_sent_byte_count_ = 0;
|
| + total_sent_byte_count_ = 0;
|
| + }
|
|
|
| - current_byte_count_ += bytes_read;
|
| + current_sent_byte_count_ += bytes_sent;
|
| }
|
|
|
| void Task::GetTerminationStatus(base::TerminationStatus* out_status,
|
|
|