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

Side by Side Diff: chrome/browser/task_manager.cc

Issue 3107021: Convert FormatBytes to string16. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 int ValueCompare(T value1, T value2) { 52 int ValueCompare(T value1, T value2) {
53 if (value1 < value2) 53 if (value1 < value2)
54 return -1; 54 return -1;
55 if (value1 == value2) 55 if (value1 == value2)
56 return 0; 56 return 0;
57 return 1; 57 return 1;
58 } 58 }
59 59
60 string16 FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) { 60 string16 FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) {
61 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT, 61 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT,
62 WideToUTF16Hack(FormatBytes(stat.size, DATA_UNITS_KIBIBYTE, false)), 62 FormatBytes(stat.size, DATA_UNITS_KIBIBYTE, false),
63 WideToUTF16Hack(FormatBytes(stat.liveSize, DATA_UNITS_KIBIBYTE, false))); 63 FormatBytes(stat.liveSize, DATA_UNITS_KIBIBYTE, false));
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 //////////////////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////////////////
69 // TaskManagerModel class 69 // TaskManagerModel class
70 //////////////////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////////////////
71 71
72 TaskManagerModel::TaskManagerModel(TaskManager* task_manager) 72 TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
73 : update_state_(IDLE), 73 : update_state_(IDLE),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { 122 string16 TaskManagerModel::GetResourceNetworkUsage(int index) const {
123 DCHECK(index < ResourceCount()); 123 DCHECK(index < ResourceCount());
124 int64 net_usage = GetNetworkUsage(resources_[index]); 124 int64 net_usage = GetNetworkUsage(resources_[index]);
125 if (net_usage == -1) 125 if (net_usage == -1)
126 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); 126 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
127 if (net_usage == 0) 127 if (net_usage == 0)
128 return ASCIIToUTF16("0"); 128 return ASCIIToUTF16("0");
129 std::wstring net_byte = 129 std::wstring net_byte =
130 FormatSpeed(net_usage, GetByteDisplayUnits(net_usage), true); 130 UTF16ToWideHack(FormatSpeed(net_usage, GetByteDisplayUnits(net_usage),
131 true));
131 // Force number string to have LTR directionality. 132 // Force number string to have LTR directionality.
132 base::i18n::GetDisplayStringInLTRDirectionality(&net_byte); 133 base::i18n::GetDisplayStringInLTRDirectionality(&net_byte);
133 return WideToUTF16Hack(net_byte); 134 return WideToUTF16Hack(net_byte);
134 } 135 }
135 136
136 string16 TaskManagerModel::GetResourceCPUUsage(int index) const { 137 string16 TaskManagerModel::GetResourceCPUUsage(int index) const {
137 DCHECK(index < ResourceCount()); 138 DCHECK(index < ResourceCount());
138 return WideToUTF16Hack(StringPrintf( 139 return WideToUTF16Hack(StringPrintf(
139 #if defined(OS_MACOSX) 140 #if defined(OS_MACOSX)
140 // Activity Monitor shows %cpu with one decimal digit -- be 141 // Activity Monitor shows %cpu with one decimal digit -- be
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (!resources_[index]->ReportsSqliteMemoryUsed()) 212 if (!resources_[index]->ReportsSqliteMemoryUsed())
212 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); 213 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
213 return GetMemCellText(resources_[index]->SqliteMemoryUsedBytes()); 214 return GetMemCellText(resources_[index]->SqliteMemoryUsedBytes());
214 } 215 }
215 216
216 string16 TaskManagerModel::GetResourceV8MemoryAllocatedSize( 217 string16 TaskManagerModel::GetResourceV8MemoryAllocatedSize(
217 int index) const { 218 int index) const {
218 if (!resources_[index]->ReportsV8MemoryStats()) 219 if (!resources_[index]->ReportsV8MemoryStats())
219 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); 220 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
220 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT, 221 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT,
221 WideToUTF16Hack(FormatBytes(resources_[index]->GetV8MemoryAllocated(), 222 FormatBytes(resources_[index]->GetV8MemoryAllocated(),
222 DATA_UNITS_KIBIBYTE, 223 DATA_UNITS_KIBIBYTE,
223 false)), 224 false),
224 WideToUTF16Hack(FormatBytes(resources_[index]->GetV8MemoryUsed(), 225 FormatBytes(resources_[index]->GetV8MemoryUsed(),
225 DATA_UNITS_KIBIBYTE, 226 DATA_UNITS_KIBIBYTE,
226 false))); 227 false));
227 } 228 }
228 229
229 bool TaskManagerModel::IsResourceFirstInGroup(int index) const { 230 bool TaskManagerModel::IsResourceFirstInGroup(int index) const {
230 DCHECK(index < ResourceCount()); 231 DCHECK(index < ResourceCount());
231 TaskManager::Resource* resource = resources_[index]; 232 TaskManager::Resource* resource = resources_[index];
232 GroupMap::const_iterator iter = group_map_.find(resource->GetProcess()); 233 GroupMap::const_iterator iter = group_map_.find(resource->GetProcess());
233 DCHECK(iter != group_map_.end()); 234 DCHECK(iter != group_map_.end());
234 const ResourceList* group = iter->second; 235 const ResourceList* group = iter->second;
235 return ((*group)[0] == resource); 236 return ((*group)[0] == resource);
236 } 237 }
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 MetricsMap::const_iterator iter = metrics_map_.find(handle); 975 MetricsMap::const_iterator iter = metrics_map_.find(handle);
975 if (iter == metrics_map_.end()) 976 if (iter == metrics_map_.end())
976 return false; 977 return false;
977 978
978 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) 979 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second))
979 return false; 980 return false;
980 981
981 memory_usage_map_.insert(std::make_pair(handle, *usage)); 982 memory_usage_map_.insert(std::make_pair(handle, *usage));
982 return true; 983 return true;
983 } 984 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698