| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
| 11 #include "base/i18n/rtl.h" |
| 11 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 12 #include "base/stats_table.h" | 13 #include "base/stats_table.h" |
| 13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 14 #include "base/thread.h" | 15 #include "base/thread.h" |
| 15 #include "chrome/browser/browser_list.h" | 16 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_window.h" | 18 #include "chrome/browser/browser_window.h" |
| 18 #include "chrome/browser/chrome_thread.h" | 19 #include "chrome/browser/chrome_thread.h" |
| 19 #include "chrome/browser/net/url_request_tracking.h" | 20 #include "chrome/browser/net/url_request_tracking.h" |
| 20 #include "chrome/browser/pref_service.h" | 21 #include "chrome/browser/pref_service.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 std::wstring TaskManagerModel::GetResourceNetworkUsage(int index) const { | 116 std::wstring TaskManagerModel::GetResourceNetworkUsage(int index) const { |
| 116 DCHECK(index < ResourceCount()); | 117 DCHECK(index < ResourceCount()); |
| 117 int64 net_usage = GetNetworkUsage(resources_[index]); | 118 int64 net_usage = GetNetworkUsage(resources_[index]); |
| 118 if (net_usage == -1) | 119 if (net_usage == -1) |
| 119 return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); | 120 return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); |
| 120 if (net_usage == 0) | 121 if (net_usage == 0) |
| 121 return std::wstring(L"0"); | 122 return std::wstring(L"0"); |
| 122 std::wstring net_byte = | 123 std::wstring net_byte = |
| 123 FormatSpeed(net_usage, GetByteDisplayUnits(net_usage), true); | 124 FormatSpeed(net_usage, GetByteDisplayUnits(net_usage), true); |
| 124 // Force number string to have LTR directionality. | 125 // Force number string to have LTR directionality. |
| 125 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 126 if (base::i18n::IsRTL()) |
| 126 l10n_util::WrapStringWithLTRFormatting(&net_byte); | 127 base::i18n::WrapStringWithLTRFormatting(&net_byte); |
| 127 return net_byte; | 128 return net_byte; |
| 128 } | 129 } |
| 129 | 130 |
| 130 std::wstring TaskManagerModel::GetResourceCPUUsage(int index) const { | 131 std::wstring TaskManagerModel::GetResourceCPUUsage(int index) const { |
| 131 DCHECK(index < ResourceCount()); | 132 DCHECK(index < ResourceCount()); |
| 132 return StringPrintf( | 133 return StringPrintf( |
| 133 #if defined(OS_MACOSX) | 134 #if defined(OS_MACOSX) |
| 134 // Activity Monitor shows %cpu with one decimal digit -- be | 135 // Activity Monitor shows %cpu with one decimal digit -- be |
| 135 // consistent with that. | 136 // consistent with that. |
| 136 L"%.1f", | 137 L"%.1f", |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 444 } |
| 444 } | 445 } |
| 445 return 0; | 446 return 0; |
| 446 } | 447 } |
| 447 | 448 |
| 448 std::wstring TaskManagerModel::GetMemCellText(int64 number) const { | 449 std::wstring TaskManagerModel::GetMemCellText(int64 number) const { |
| 449 #if !defined(OS_MACOSX) | 450 #if !defined(OS_MACOSX) |
| 450 std::wstring str = UTF16ToWide(base::FormatNumber(number / 1024)); | 451 std::wstring str = UTF16ToWide(base::FormatNumber(number / 1024)); |
| 451 | 452 |
| 452 // Adjust number string if necessary. | 453 // Adjust number string if necessary. |
| 453 l10n_util::AdjustStringForLocaleDirection(str, &str); | 454 base::i18n::AdjustStringForLocaleDirection(str, &str); |
| 454 return l10n_util::GetStringF(IDS_TASK_MANAGER_MEM_CELL_TEXT, str); | 455 return l10n_util::GetStringF(IDS_TASK_MANAGER_MEM_CELL_TEXT, str); |
| 455 #else | 456 #else |
| 456 // System expectation is to show "100 KB", "200 MB", etc. | 457 // System expectation is to show "100 KB", "200 MB", etc. |
| 457 // TODO(thakis): Switch to metric units (as opposed to powers of two). | 458 // TODO(thakis): Switch to metric units (as opposed to powers of two). |
| 458 return FormatBytes( | 459 return FormatBytes( |
| 459 number, GetByteDisplayUnits(number), /* show_units=*/true); | 460 number, GetByteDisplayUnits(number), /* show_units=*/true); |
| 460 #endif | 461 #endif |
| 461 } | 462 } |
| 462 | 463 |
| 463 void TaskManagerModel::StartUpdating() { | 464 void TaskManagerModel::StartUpdating() { |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 Browser::TYPE_APP_PANEL | | 932 Browser::TYPE_APP_PANEL | |
| 932 Browser::TYPE_DEVTOOLS | | 933 Browser::TYPE_DEVTOOLS | |
| 933 Browser::TYPE_POPUP)) { | 934 Browser::TYPE_POPUP)) { |
| 934 browser = BrowserList::GetLastActive(); | 935 browser = BrowserList::GetLastActive(); |
| 935 DCHECK(browser); | 936 DCHECK(browser); |
| 936 } | 937 } |
| 937 | 938 |
| 938 browser->window()->Show(); | 939 browser->window()->Show(); |
| 939 } | 940 } |
| 940 } | 941 } |
| OLD | NEW |