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
3 // found in the LICENSE file.
5 #include "chrome/browser/task_management/providers/task.h"
7 namespace task_management
{
11 // The last ID given to the previously created task.
17 Task::Task(const base::string16
& title
,
18 const gfx::ImageSkia
& icon
,
19 base::ProcessHandle handle
)
20 : task_id_(g_last_id
++),
22 current_byte_count_(-1),
25 process_handle_(handle
) {
31 void Task::Refresh(const base::TimeDelta
& update_interval
) {
32 // TODO(afakhry): Add code here to skip this when network usage refresh has
33 // never been requested.
35 if (current_byte_count_
== -1)
39 (current_byte_count_
* base::TimeDelta::FromSeconds(1)) / update_interval
;
41 // Reset the current byte count for this task.
42 current_byte_count_
= 0;
45 void Task::OnNetworkBytesRead(int64 bytes_read
) {
46 if (current_byte_count_
== -1)
47 current_byte_count_
= 0;
49 current_byte_count_
+= bytes_read
;
52 base::string16
Task::GetProfileName() const {
53 return base::string16();
56 int Task::GetRoutingID() const {
60 bool Task::ReportsSqliteMemory() const {
61 return GetSqliteMemoryUsed() != -1;
64 int64
Task::GetSqliteMemoryUsed() const {
68 bool Task::ReportsV8Memory() const {
69 return GetV8MemoryAllocated() != -1;
72 int64
Task::GetV8MemoryAllocated() const {
76 int64
Task::GetV8MemoryUsed() const {
80 bool Task::ReportsWebCacheStats() const {
84 blink::WebCache::ResourceTypeStats
Task::GetWebCacheStats() const {
85 return blink::WebCache::ResourceTypeStats();
88 bool Task::ReportsNetworkUsage() const {
89 return network_usage_
!= -1;
92 } // namespace task_management