Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/private/tasks_providers/task.h" | |
| 6 | |
| 7 namespace task_management { | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 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.
| |
| 12 | |
| 13 } // namespace | |
| 14 | |
| 15 | |
| 16 // ---------------------------------------------------------------------- | |
| 17 // Public Members: | |
| 18 // ---------------------------------------------------------------------- | |
| 19 | |
| 20 base::string16 Task::GetProfileName() const { | |
| 21 return base::string16(); | |
| 22 } | |
| 23 | |
| 24 int Task::GetRoutingID() const { | |
| 25 return 0; | |
| 26 } | |
| 27 | |
| 28 size_t Task::GetSqliteMemoryUsed() const { | |
| 29 return -1U; | |
| 30 } | |
| 31 | |
| 32 size_t Task::GetV8MemoryAllocated() const { | |
| 33 return -1U; | |
| 34 } | |
| 35 | |
| 36 size_t Task::GetV8MemoryUsed() const { | |
| 37 return -1U; | |
| 38 } | |
| 39 | |
| 40 bool Task::ReportsWebCacheStats() const { | |
| 41 return false; | |
| 42 } | |
| 43 | |
| 44 blink::WebCache::ResourceTypeStats Task::GetWebCacheStats() const { | |
| 45 return blink::WebCache::ResourceTypeStats(); | |
| 46 } | |
| 47 | |
| 48 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.
| |
| 49 // TODO(afakhry): Add code here to skip this when network usage refresh has | |
| 50 // never been requested. | |
| 51 | |
| 52 int64 update_time_secs = update_time.InSeconds(); | |
| 53 if (update_time_secs > one_second_time_delta) | |
| 54 network_usage_ = current_byte_count_ / update_time_secs; | |
| 55 else | |
| 56 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.
| |
| 57 | |
| 58 // Reset the current byte count for this resource. | |
| 59 current_byte_count_ = 0; | |
| 60 } | |
| 61 | |
| 62 void Task::OnBytesRead(int64 bytes_read) { | |
| 63 current_byte_count_ += bytes_read; | |
| 64 } | |
| 65 | |
| 66 // ---------------------------------------------------------------------- | |
| 67 // Protected Members: | |
| 68 // ---------------------------------------------------------------------- | |
|
ncarter (slow)
2015/03/27 18:16:21
Remove this comment.
| |
| 69 | |
| 70 Task::Task(const base::string16& title, | |
| 71 const gfx::ImageSkia& icon, | |
| 72 base::ProcessHandle handle) | |
| 73 : network_usage_(0), | |
| 74 current_byte_count_(0), | |
| 75 task_id_(last_id_++), | |
| 76 title_(title), | |
| 77 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
| |
| 78 process_handle_(handle), | |
| 79 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
| |
| 80 } | |
| 81 | |
| 82 Task::~Task() { | |
| 83 } | |
| 84 | |
| 85 // ---------------------------------------------------------------------- | |
| 86 // Private Members: | |
| 87 // ---------------------------------------------------------------------- | |
|
ncarter (slow)
2015/03/27 18:16:21
Remove this comment.
| |
| 88 | |
| 89 // static | |
| 90 size_t Task::last_id_ = 0; | |
| 91 | |
| 92 } // namespace task_management | |
| OLD | NEW |