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

Unified Diff: chrome/browser/task_management/private/tasks_providers/task.cc

Issue 1038033002: New Task Manager - Phase 1.1: Implement Browser Process Task Providing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
Index: chrome/browser/task_management/private/tasks_providers/task.cc
diff --git a/chrome/browser/task_management/private/tasks_providers/task.cc b/chrome/browser/task_management/private/tasks_providers/task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a42864cf1483a6560391039f15c95fc1d2ce7e2c
--- /dev/null
+++ b/chrome/browser/task_management/private/tasks_providers/task.cc
@@ -0,0 +1,92 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/task_management/private/tasks_providers/task.h"
+
+namespace task_management {
+
+namespace {
+
+int64 one_second_time_delta = base::TimeDelta::FromSeconds(1).InSeconds();
ncarter (slow) 2015/03/27 18:16:21 This is a pretty fancy way of saying "int64 var =
afakhry 2015/03/31 00:19:20 Removed.
+
+} // namespace
+
+
+// ----------------------------------------------------------------------
+// Public Members:
+// ----------------------------------------------------------------------
+
+base::string16 Task::GetProfileName() const {
+ return base::string16();
+}
+
+int Task::GetRoutingID() const {
+ return 0;
+}
+
+size_t Task::GetSqliteMemoryUsed() const {
+ return -1U;
+}
+
+size_t Task::GetV8MemoryAllocated() const {
+ return -1U;
+}
+
+size_t Task::GetV8MemoryUsed() const {
+ return -1U;
+}
+
+bool Task::ReportsWebCacheStats() const {
+ return false;
+}
+
+blink::WebCache::ResourceTypeStats Task::GetWebCacheStats() const {
+ return blink::WebCache::ResourceTypeStats();
+}
+
+void Task::Refresh(const base::TimeDelta& update_time) {
ncarter (slow) 2015/03/27 18:16:21 I'd probably call this variable sampling_interval
afakhry 2015/03/31 00:19:20 Done.
+ // TODO(afakhry): Add code here to skip this when network usage refresh has
+ // never been requested.
+
+ int64 update_time_secs = update_time.InSeconds();
+ if (update_time_secs > one_second_time_delta)
+ network_usage_ = current_byte_count_ / update_time_secs;
+ else
+ network_usage_ = current_byte_count_ * (1 / update_time_secs);
ncarter (slow) 2015/03/27 18:16:21 This math seems buggy. The else branch is executed
afakhry 2015/03/31 00:19:20 Fixed.
+
+ // Reset the current byte count for this resource.
+ current_byte_count_ = 0;
+}
+
+void Task::OnBytesRead(int64 bytes_read) {
+ current_byte_count_ += bytes_read;
+}
+
+// ----------------------------------------------------------------------
+// Protected Members:
+// ----------------------------------------------------------------------
ncarter (slow) 2015/03/27 18:16:21 Remove this comment.
+
+Task::Task(const base::string16& title,
+ const gfx::ImageSkia& icon,
+ base::ProcessHandle handle)
+ : network_usage_(0),
+ current_byte_count_(0),
+ task_id_(last_id_++),
+ title_(title),
+ icon_(icon),
ncarter (slow) 2015/03/27 18:16:21 Just mentioning it in case you didn't know: copyin
afakhry 2015/03/31 00:19:19 Yep, I already know that, but thanks a lot for mak
+ process_handle_(handle),
+ is_first_in_group_(true) {
ncarter (slow) 2015/03/27 18:16:21 "is_first_in_group_" doesn't make sense to me as a
afakhry 2015/03/31 00:19:20 This is the responsibility of the TaskGroup in the
+}
+
+Task::~Task() {
+}
+
+// ----------------------------------------------------------------------
+// Private Members:
+// ----------------------------------------------------------------------
ncarter (slow) 2015/03/27 18:16:21 Remove this comment.
+
+// static
+size_t Task::last_id_ = 0;
+
+} // namespace task_management

Powered by Google App Engine
This is Rietveld 408576698