| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/task_management/providers/task.h" | 5 #include "chrome/browser/task_management/providers/task.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_info_cache.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" |
| 7 #include "chrome/browser/task_management/task_manager_observer.h" | 11 #include "chrome/browser/task_management/task_manager_observer.h" |
| 8 | 12 |
| 9 namespace task_management { | 13 namespace task_management { |
| 10 | 14 |
| 11 namespace { | 15 namespace { |
| 12 | 16 |
| 13 // The last ID given to the previously created task. | 17 // The last ID given to the previously created task. |
| 14 int64 g_last_id = 0; | 18 int64 g_last_id = 0; |
| 15 | 19 |
| 16 } // namespace | 20 } // namespace |
| 17 | 21 |
| 18 | 22 |
| 19 Task::Task(const base::string16& title, | 23 Task::Task(const base::string16& title, |
| 20 const gfx::ImageSkia* icon, | 24 const gfx::ImageSkia* icon, |
| 21 base::ProcessHandle handle) | 25 base::ProcessHandle handle) |
| 22 : task_id_(g_last_id++), | 26 : task_id_(g_last_id++), |
| 23 network_usage_(-1), | 27 network_usage_(-1), |
| 24 current_byte_count_(-1), | 28 current_byte_count_(-1), |
| 25 title_(title), | 29 title_(title), |
| 26 icon_(icon ? *icon : gfx::ImageSkia()), | 30 icon_(icon ? *icon : gfx::ImageSkia()), |
| 27 process_handle_(handle), | 31 process_handle_(handle), |
| 28 process_id_(base::GetProcId(handle)) { | 32 process_id_(base::GetProcId(handle)) { |
| 29 } | 33 } |
| 30 | 34 |
| 31 Task::~Task() { | 35 Task::~Task() { |
| 32 } | 36 } |
| 33 | 37 |
| 38 // static |
| 39 base::string16 Task::GetProfileNameFromProfile(Profile* profile) { |
| 40 DCHECK(profile); |
| 41 ProfileInfoCache& cache = |
| 42 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 43 size_t index = |
| 44 cache.GetIndexOfProfileWithPath(profile->GetOriginalProfile()->GetPath()); |
| 45 if (index != std::string::npos) |
| 46 return cache.GetNameOfProfileAtIndex(index); |
| 47 |
| 48 return base::string16(); |
| 49 } |
| 50 |
| 34 void Task::Activate() { | 51 void Task::Activate() { |
| 35 } | 52 } |
| 36 | 53 |
| 37 void Task::Refresh(const base::TimeDelta& update_interval, | 54 void Task::Refresh(const base::TimeDelta& update_interval, |
| 38 int64 refresh_flags) { | 55 int64 refresh_flags) { |
| 39 if ((refresh_flags & REFRESH_TYPE_NETWORK_USAGE) == 0) | 56 if ((refresh_flags & REFRESH_TYPE_NETWORK_USAGE) == 0) |
| 40 return; | 57 return; |
| 41 | 58 |
| 42 if (current_byte_count_ == -1) | 59 if (current_byte_count_ == -1) |
| 43 return; | 60 return; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 103 |
| 87 blink::WebCache::ResourceTypeStats Task::GetWebCacheStats() const { | 104 blink::WebCache::ResourceTypeStats Task::GetWebCacheStats() const { |
| 88 return blink::WebCache::ResourceTypeStats(); | 105 return blink::WebCache::ResourceTypeStats(); |
| 89 } | 106 } |
| 90 | 107 |
| 91 bool Task::ReportsNetworkUsage() const { | 108 bool Task::ReportsNetworkUsage() const { |
| 92 return network_usage_ != -1; | 109 return network_usage_ != -1; |
| 93 } | 110 } |
| 94 | 111 |
| 95 } // namespace task_management | 112 } // namespace task_management |
| OLD | NEW |