| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_manager.h" | 5 #include "chrome/browser/task_manager.h" |
| 6 | 6 |
| 7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
| 8 #include "base/stats_table.h" | 8 #include "base/stats_table.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/app/theme/theme_resources.h" | 10 #include "chrome/app/theme/theme_resources.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 case IDS_TASK_MANAGER_PAGE_COLUMN: // Process | 107 case IDS_TASK_MANAGER_PAGE_COLUMN: // Process |
| 108 return resource->GetTitle(); | 108 return resource->GetTitle(); |
| 109 | 109 |
| 110 // Only the first item from a group shows the process info. | 110 // Only the first item from a group shows the process info. |
| 111 case IDS_TASK_MANAGER_NET_COLUMN: { // Net | 111 case IDS_TASK_MANAGER_NET_COLUMN: { // Net |
| 112 int64 net_usage = GetNetworkUsage(resource); | 112 int64 net_usage = GetNetworkUsage(resource); |
| 113 if (net_usage == -1) | 113 if (net_usage == -1) |
| 114 return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); | 114 return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); |
| 115 if (net_usage == 0) | 115 if (net_usage == 0) |
| 116 return std::wstring(L"0"); | 116 return std::wstring(L"0"); |
| 117 return FormatSpeed(net_usage, GetByteDisplayUnits(net_usage), true); | 117 std::wstring net_byte = |
| 118 FormatSpeed(net_usage, GetByteDisplayUnits(net_usage), true); |
| 119 // Force number string to have LTR directionality. |
| 120 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
| 121 l10n_util::WrapStringWithLTRFormatting(&net_byte); |
| 122 return net_byte; |
| 118 } | 123 } |
| 119 | 124 |
| 120 case IDS_TASK_MANAGER_CPU_COLUMN: // CPU | 125 case IDS_TASK_MANAGER_CPU_COLUMN: // CPU |
| 121 if (!first_in_group) | 126 if (!first_in_group) |
| 122 return std::wstring(); | 127 return std::wstring(); |
| 123 return IntToWString(GetCPUUsage(resource)); | 128 return IntToWString(GetCPUUsage(resource)); |
| 124 | 129 |
| 125 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: // Memory | 130 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: { // Memory |
| 126 // We report committed (working set + paged) private usage. This is NOT | 131 // We report committed (working set + paged) private usage. This is NOT |
| 127 // going to match what Windows Task Manager shows (which is working set). | 132 // going to match what Windows Task Manager shows (which is working set). |
| 128 if (!first_in_group) | 133 if (!first_in_group) |
| 129 return std::wstring(); | 134 return std::wstring(); |
| 130 return l10n_util::GetStringF( | 135 std::wstring number = FormatNumber(GetPrivateMemory(process_metrics)); |
| 131 IDS_TASK_MANAGER_MEM_CELL_TEXT, | 136 return GetMemCellText(&number); |
| 132 FormatNumber(GetPrivateMemory(process_metrics))); | 137 } |
| 133 | 138 |
| 134 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: // Memory | 139 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: { // Memory |
| 135 if (!first_in_group) | 140 if (!first_in_group) |
| 136 return std::wstring(); | 141 return std::wstring(); |
| 137 return l10n_util::GetStringF( | 142 std::wstring number = FormatNumber(GetSharedMemory(process_metrics)); |
| 138 IDS_TASK_MANAGER_MEM_CELL_TEXT, | 143 return GetMemCellText(&number); |
| 139 FormatNumber(GetSharedMemory(process_metrics))); | 144 } |
| 140 | 145 |
| 141 case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN: // Memory | 146 case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN: { // Memory |
| 142 if (!first_in_group) | 147 if (!first_in_group) |
| 143 return std::wstring(); | 148 return std::wstring(); |
| 144 return l10n_util::GetStringF( | 149 std::wstring number = FormatNumber(GetPhysicalMemory(process_metrics)); |
| 145 IDS_TASK_MANAGER_MEM_CELL_TEXT, | 150 return GetMemCellText(&number); |
| 146 FormatNumber(GetPhysicalMemory(process_metrics))); | 151 } |
| 147 | 152 |
| 148 case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: | 153 case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: |
| 149 if (!first_in_group) | 154 if (!first_in_group) |
| 150 return std::wstring(); | 155 return std::wstring(); |
| 151 return IntToWString(base::GetProcId(resource->GetProcess())); | 156 return IntToWString(base::GetProcId(resource->GetProcess())); |
| 152 | 157 |
| 153 case kGoatsTeleportedColumn: // Goats Teleported. | 158 case kGoatsTeleportedColumn: // Goats Teleported. |
| 154 goats_teleported_ += rand(); | 159 goats_teleported_ += rand(); |
| 155 return FormatNumber(goats_teleported_); | 160 return FormatNumber(goats_teleported_); |
| 156 | 161 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if (counter != NULL && counter[0] != '\0') { | 210 if (counter != NULL && counter[0] != '\0') { |
| 206 return table->GetCounterValue(counter, | 211 return table->GetCounterValue(counter, |
| 207 base::GetProcId(resource->GetProcess())); | 212 base::GetProcId(resource->GetProcess())); |
| 208 } else { | 213 } else { |
| 209 NOTREACHED() << "Invalid column."; | 214 NOTREACHED() << "Invalid column."; |
| 210 } | 215 } |
| 211 } | 216 } |
| 212 return 0; | 217 return 0; |
| 213 } | 218 } |
| 214 | 219 |
| 220 std::wstring TaskManagerTableModel::GetMemCellText( |
| 221 std::wstring* number) const { |
| 222 // Adjust number string if necessary. |
| 223 l10n_util::AdjustStringForLocaleDirection(*number, number); |
| 224 return l10n_util::GetStringF(IDS_TASK_MANAGER_MEM_CELL_TEXT, *number); |
| 225 } |
| 226 |
| 215 SkBitmap TaskManagerTableModel::GetIcon(int row) { | 227 SkBitmap TaskManagerTableModel::GetIcon(int row) { |
| 216 DCHECK(row < RowCount()); | 228 DCHECK(row < RowCount()); |
| 217 SkBitmap icon = resources_[row]->GetIcon(); | 229 SkBitmap icon = resources_[row]->GetIcon(); |
| 218 if (!icon.isNull()) | 230 if (!icon.isNull()) |
| 219 return icon; | 231 return icon; |
| 220 | 232 |
| 221 static SkBitmap* default_icon = ResourceBundle::GetSharedInstance(). | 233 static SkBitmap* default_icon = ResourceBundle::GetSharedInstance(). |
| 222 GetBitmapNamed(IDR_DEFAULT_FAVICON); | 234 GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 223 return *default_icon; | 235 return *default_icon; |
| 224 } | 236 } |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 | 1095 |
| 1084 views::View* TaskManager::GetContentsView() { | 1096 views::View* TaskManager::GetContentsView() { |
| 1085 return contents_.get(); | 1097 return contents_.get(); |
| 1086 } | 1098 } |
| 1087 | 1099 |
| 1088 // static | 1100 // static |
| 1089 TaskManager* TaskManager::GetInstance() { | 1101 TaskManager* TaskManager::GetInstance() { |
| 1090 return Singleton<TaskManager>::get(); | 1102 return Singleton<TaskManager>::get(); |
| 1091 } | 1103 } |
| 1092 | 1104 |
| OLD | NEW |