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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/task_management/providers/task.h"
6
7 namespace task_management {
8
9 namespace {
10
11 // The last ID given to the previously created task.
12 int64 g_last_id = 0;
13
14 } // namespace
15
16
17 Task::Task(const base::string16& title,
18 const gfx::ImageSkia& icon,
19 base::ProcessHandle handle)
20 : task_id_(g_last_id++),
21 network_usage_(-1),
22 current_byte_count_(-1),
23 title_(title),
24 icon_(icon),
25 process_handle_(handle) {
26 }
27
28 Task::~Task() {
29 }
30
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.
34
35 if (current_byte_count_ == -1)
36 return;
37
38 network_usage_ =
39 (current_byte_count_ * base::TimeDelta::FromSeconds(1)) / update_interval;
40
41 // Reset the current byte count for this task.
42 current_byte_count_ = 0;
43 }
44
45 void Task::OnNetworkBytesRead(int64 bytes_read) {
46 if (current_byte_count_ == -1)
47 current_byte_count_ = 0;
48
49 current_byte_count_ += bytes_read;
50 }
51
52 base::string16 Task::GetProfileName() const {
53 return base::string16();
54 }
55
56 int Task::GetRoutingID() const {
57 return 0;
58 }
59
60 bool Task::ReportsSqliteMemory() const {
61 return GetSqliteMemoryUsed() != -1;
62 }
63
64 int64 Task::GetSqliteMemoryUsed() const {
65 return -1;
66 }
67
68 bool Task::ReportsV8Memory() const {
69 return GetV8MemoryAllocated() != -1;
70 }
71
72 int64 Task::GetV8MemoryAllocated() const {
73 return -1;
74 }
75
76 int64 Task::GetV8MemoryUsed() const {
77 return -1;
78 }
79
80 bool Task::ReportsWebCacheStats() const {
81 return false;
82 }
83
84 blink::WebCache::ResourceTypeStats Task::GetWebCacheStats() const {
85 return blink::WebCache::ResourceTypeStats();
86 }
87
88 bool Task::ReportsNetworkUsage() const {
89 return network_usage_ != -1;
90 }
91
92 } // namespace task_management
OLDNEW
« 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