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 #include "chrome/browser/task_management/task_manager_observer.h"
9 namespace task_management
{
13 // The last ID given to the previously created task.
19 Task::Task(const base::string16
& title
,
20 const gfx::ImageSkia
* icon
,
21 base::ProcessHandle handle
)
22 : task_id_(g_last_id
++),
24 current_byte_count_(-1),
26 icon_(icon
? *icon
: gfx::ImageSkia()),
27 process_handle_(handle
),
28 process_id_(base::GetProcId(handle
)) {
34 void Task::Activate() {
37 void Task::Refresh(const base::TimeDelta
& update_interval
,
38 int64 refresh_flags
) {
39 if ((refresh_flags
& REFRESH_TYPE_NETWORK_USAGE
) == 0)
42 if (current_byte_count_
== -1)
46 (current_byte_count_
* base::TimeDelta::FromSeconds(1)) / update_interval
;
48 // Reset the current byte count for this task.
49 current_byte_count_
= 0;
52 void Task::OnNetworkBytesRead(int64 bytes_read
) {
53 if (current_byte_count_
== -1)
54 current_byte_count_
= 0;
56 current_byte_count_
+= bytes_read
;
59 base::string16
Task::GetProfileName() const {
60 return base::string16();
63 bool Task::ReportsSqliteMemory() const {
64 return GetSqliteMemoryUsed() != -1;
67 int64
Task::GetSqliteMemoryUsed() const {
71 bool Task::ReportsV8Memory() const {
72 return GetV8MemoryAllocated() != -1;
75 int64
Task::GetV8MemoryAllocated() const {
79 int64
Task::GetV8MemoryUsed() const {
83 bool Task::ReportsWebCacheStats() const {
87 blink::WebCache::ResourceTypeStats
Task::GetWebCacheStats() const {
88 return blink::WebCache::ResourceTypeStats();
91 bool Task::ReportsNetworkUsage() const {
92 return network_usage_
!= -1;
95 } // namespace task_management