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

Unified Diff: chrome/browser/task_management/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: Converting size_t's to int64's Created 5 years, 8 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/providers/task.cc
diff --git a/chrome/browser/task_management/providers/task.cc b/chrome/browser/task_management/providers/task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2f3a1b982177f93391d5acdf43e5b9d190624982
--- /dev/null
+++ b/chrome/browser/task_management/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/providers/task.h"
+
+namespace task_management {
+
+namespace {
+
+// The last ID given to the previously created task.
+int64 g_last_id = 0;
+
+} // namespace
+
+
+Task::Task(const base::string16& title,
+ const gfx::ImageSkia& icon,
+ base::ProcessHandle handle)
+ : task_id_(g_last_id++),
+ network_usage_(-1),
+ current_byte_count_(-1),
+ title_(title),
+ icon_(icon),
+ process_handle_(handle) {
+}
+
+Task::~Task() {
+}
+
+void Task::Refresh(const base::TimeDelta& update_interval) {
+ // TODO(afakhry): Add code here to skip this when network usage refresh has
+ // never been requested.
+
+ if (current_byte_count_ == -1)
+ return;
+
+ network_usage_ =
+ (current_byte_count_ * base::TimeDelta::FromSeconds(1)) / update_interval;
+
+ // Reset the current byte count for this task.
+ current_byte_count_ = 0;
+}
+
+void Task::OnNetworkBytesRead(int64 bytes_read) {
+ if (current_byte_count_ == -1)
+ current_byte_count_ = 0;
+
+ current_byte_count_ += bytes_read;
+}
+
+base::string16 Task::GetProfileName() const {
+ return base::string16();
+}
+
+int Task::GetRoutingID() const {
+ return 0;
+}
+
+bool Task::ReportsSqliteMemory() const {
+ return GetSqliteMemoryUsed() != -1;
+}
+
+int64 Task::GetSqliteMemoryUsed() const {
+ return -1;
+}
+
+bool Task::ReportsV8Memory() const {
+ return GetV8MemoryAllocated() != -1;
+}
+
+int64 Task::GetV8MemoryAllocated() const {
+ return -1;
+}
+
+int64 Task::GetV8MemoryUsed() const {
+ return -1;
+}
+
+bool Task::ReportsWebCacheStats() const {
+ return false;
+}
+
+blink::WebCache::ResourceTypeStats Task::GetWebCacheStats() const {
+ return blink::WebCache::ResourceTypeStats();
+}
+
+bool Task::ReportsNetworkUsage() const {
+ return network_usage_ != -1;
+}
+
+} // namespace task_management
« no previous file with comments | « chrome/browser/task_management/providers/task.h ('k') | chrome/browser/task_management/providers/task_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698