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

Unified Diff: chrome/browser/task_manager/providers/task.cc

Issue 2905403002: plumb network upload into the task manager (Closed)
Patch Set: fixed comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/task_manager/providers/task.h ('k') | chrome/browser/task_manager/sampling/task_group.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1306017302c202c73479ee97896c65b93473218a 100644
--- a/chrome/browser/task_manager/providers/task.cc
+++ b/chrome/browser/task_manager/providers/task.cc
@@ -30,8 +30,12 @@ Task::Task(const base::string16& title,
base::ProcessHandle handle,
base::ProcessId process_id)
: task_id_(g_last_id++),
- network_usage_(-1),
- current_byte_count_(-1),
+ last_refresh_cumulative_bytes_sent_(0),
+ last_refresh_cumulative_bytes_read_(0),
+ cumulative_bytes_sent_(0),
+ cumulative_bytes_read_(0),
+ network_sent_rate_(0),
+ network_read_rate_(0),
title_(title),
rappor_sample_name_(rappor_sample),
icon_(icon ? *icon : gfx::ImageSkia()),
@@ -70,24 +74,32 @@ void Task::Kill() {
void Task::Refresh(const base::TimeDelta& update_interval,
int64_t refresh_flags) {
- if ((refresh_flags & REFRESH_TYPE_NETWORK_USAGE) == 0)
+ if ((refresh_flags & REFRESH_TYPE_NETWORK_USAGE) == 0 ||
+ update_interval == base::TimeDelta())
return;
- if (current_byte_count_ == -1)
- return;
+ int64_t current_cycle_read_byte_count =
+ cumulative_bytes_read_ - last_refresh_cumulative_bytes_read_;
+ network_read_rate_ =
+ (current_cycle_read_byte_count * base::TimeDelta::FromSeconds(1)) /
+ update_interval;
- network_usage_ =
- (current_byte_count_ * base::TimeDelta::FromSeconds(1)) / update_interval;
+ int64_t current_cycle_sent_byte_count =
+ cumulative_bytes_sent_ - last_refresh_cumulative_bytes_sent_;
+ network_sent_rate_ =
+ (current_cycle_sent_byte_count * base::TimeDelta::FromSeconds(1)) /
+ update_interval;
- // Reset the current byte count for this task.
- current_byte_count_ = 0;
+ last_refresh_cumulative_bytes_read_ = cumulative_bytes_read_;
+ last_refresh_cumulative_bytes_sent_ = cumulative_bytes_sent_;
}
void Task::OnNetworkBytesRead(int64_t bytes_read) {
- if (current_byte_count_ == -1)
- current_byte_count_ = 0;
+ cumulative_bytes_read_ += bytes_read;
+}
- current_byte_count_ += bytes_read;
+void Task::OnNetworkBytesSent(int64_t bytes_sent) {
+ cumulative_bytes_sent_ += bytes_sent;
}
void Task::GetTerminationStatus(base::TerminationStatus* out_status,
@@ -147,8 +159,4 @@ int Task::GetKeepaliveCount() const {
return -1;
}
-bool Task::ReportsNetworkUsage() const {
- return network_usage_ != -1;
-}
-
} // namespace task_manager
« no previous file with comments | « chrome/browser/task_manager/providers/task.h ('k') | chrome/browser/task_manager/sampling/task_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698