[go: nahoru, domu]

Mac: UI tweaks for task manager.

Nib change: Reduce row height, make scrollbars smaller.

Make text in task manager table slightly smaller.

Show in decimal digit for %cpu.

Show memory in KB/MB, not always in K.

Change update frequency from 1s to 2s to match Activity Monitor's default.

(all mac-only. ui team is fine with this.)

Finally, turn taskman on.

BUG=13156
TEST=Open task manager, look at it. Should look & feel similar to Activity Monitor.

Review URL: http://codereview.chromium.org/536038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36096 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/process_util.h b/base/process_util.h
index eb21188..1dc01df 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -429,10 +429,10 @@
   // Returns the CPU usage in percent since the last time this method was
   // called. The first time this method is called it returns 0 and will return
   // the actual CPU info on subsequent calls.
-  // Note that on multi-processor machines, the CPU usage value is for all
-  // CPUs. So if you have 2 CPUs and your process is using all the cycles
-  // of 1 CPU and not the other CPU, this method returns 50.
-  int GetCPUUsage();
+  // On Windows, the CPU usage value is for all CPUs. So if you have 2 CPUs and
+  // your process is using all the cycles of 1 CPU and not the other CPU, this
+  // method returns 50.
+  double GetCPUUsage();
 
   // Retrieves accounting information for all I/O operations performed by the
   // process.
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index a4b2603..29147f1 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -408,7 +408,7 @@
   return total_cpu;
 }
 
-int ProcessMetrics::GetCPUUsage() {
+double ProcessMetrics::GetCPUUsage() {
   // This queries the /proc-specific scaling factor which is
   // conceptually the system hertz.  To dump this value on another
   // system, try
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm
index a7875f3..509828b6 100644
--- a/base/process_util_mac.mm
+++ b/base/process_util_mac.mm
@@ -248,7 +248,7 @@
   (r)->tv_usec = (a)->microseconds;       \
 } while (0)
 
-int ProcessMetrics::GetCPUUsage() {
+double ProcessMetrics::GetCPUUsage() {
   mach_port_t task = TaskForPid(process_);
   if (task == MACH_PORT_NULL)
     return 0;
@@ -307,8 +307,8 @@
     return 0;
 
   // We add time_delta / 2 so the result is rounded.
-  int cpu = static_cast<int>((system_time_delta * 100 + time_delta / 2) /
-                             (time_delta));
+  double cpu = static_cast<double>(
+      (system_time_delta * 100.0 + time_delta / 2.0) / time_delta);
 
   last_system_time_ = task_time;
   last_time_ = time;
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 4d742263..d00e1de8 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -608,7 +608,7 @@
   return li.QuadPart;
 }
 
-int ProcessMetrics::GetCPUUsage() {
+double ProcessMetrics::GetCPUUsage() {
   FILETIME now;
   FILETIME creation_time;
   FILETIME exit_time;
diff --git a/base/string_util.cc b/base/string_util.cc
index 6bb91da..3a5cef3 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -874,9 +874,9 @@
   // This must match the DataUnits enum.
   static const int64 kUnitThresholds[] = {
     0,              // DATA_UNITS_BYTE,
-    3*1024,         // DATA_UNITS_KILOBYTE,
-    2*1024*1024,    // DATA_UNITS_MEGABYTE,
-    1024*1024*1024  // DATA_UNITS_GIGABYTE,
+    3*1024,         // DATA_UNITS_KIBIBYTE,
+    2*1024*1024,    // DATA_UNITS_MEBIBYTE,
+    1024*1024*1024  // DATA_UNITS_GIBIBYTE,
   };
 
   if (bytes < 0) {
@@ -890,7 +890,7 @@
       break;
   }
 
-  DCHECK(unit_index >= DATA_UNITS_BYTE && unit_index <= DATA_UNITS_GIGABYTE);
+  DCHECK(unit_index >= DATA_UNITS_BYTE && unit_index <= DATA_UNITS_GIBIBYTE);
   return DataUnits(unit_index);
 }
 
@@ -919,7 +919,7 @@
     return std::wstring();
   }
 
-  DCHECK(units >= DATA_UNITS_BYTE && units <= DATA_UNITS_GIGABYTE);
+  DCHECK(units >= DATA_UNITS_BYTE && units <= DATA_UNITS_GIBIBYTE);
 
   // Put the quantity in the right units.
   double unit_amount = static_cast<double>(bytes);
diff --git a/base/string_util.h b/base/string_util.h
index ee70a161..dd0f8c1 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -339,13 +339,11 @@
   return wcschr(kWhitespaceWide, c) != NULL;
 }
 
-// TODO(mpcomplete): Decide if we should change these names to KIBI, etc,
-// or if we should actually use metric units, or leave as is.
 enum DataUnits {
   DATA_UNITS_BYTE = 0,
-  DATA_UNITS_KILOBYTE,
-  DATA_UNITS_MEGABYTE,
-  DATA_UNITS_GIGABYTE,
+  DATA_UNITS_KIBIBYTE,
+  DATA_UNITS_MEBIBYTE,
+  DATA_UNITS_GIBIBYTE,
 };
 
 // Return the unit type that is appropriate for displaying the amount of bytes
@@ -354,13 +352,13 @@
 
 // Return a byte string in human-readable format, displayed in units appropriate
 // specified by 'units', with an optional unit suffix.
-// Ex: FormatBytes(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB"
-// Ex: FormatBytes(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1"
+// Ex: FormatBytes(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB"
+// Ex: FormatBytes(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1"
 std::wstring FormatBytes(int64 bytes, DataUnits units, bool show_units);
 
 // As above, but with "/s" units.
-// Ex: FormatSpeed(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB/s"
-// Ex: FormatSpeed(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1"
+// Ex: FormatSpeed(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB/s"
+// Ex: FormatSpeed(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1"
 std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units);
 
 // Return a number formated with separators in the user's locale way.
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index 7e3062a..2c1f484 100644
--- a/base/string_util_unittest.cc
+++ b/base/string_util_unittest.cc
@@ -326,10 +326,10 @@
   } cases[] = {
     {0, DATA_UNITS_BYTE},
     {512, DATA_UNITS_BYTE},
-    {10*1024, DATA_UNITS_KILOBYTE},
-    {10*1024*1024, DATA_UNITS_MEGABYTE},
-    {10LL*1024*1024*1024, DATA_UNITS_GIGABYTE},
-    {~(1LL<<63), DATA_UNITS_GIGABYTE},
+    {10*1024, DATA_UNITS_KIBIBYTE},
+    {10*1024*1024, DATA_UNITS_MEBIBYTE},
+    {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE},
+    {~(1LL<<63), DATA_UNITS_GIBIBYTE},
 #ifdef NDEBUG
     {-1, DATA_UNITS_BYTE},
 #endif
@@ -348,18 +348,18 @@
   } cases[] = {
     {0, DATA_UNITS_BYTE, L"0", L"0 B"},
     {512, DATA_UNITS_BYTE, L"512", L"512 B"},
-    {512, DATA_UNITS_KILOBYTE, L"0.5", L"0.5 kB"},
-    {1024*1024, DATA_UNITS_KILOBYTE, L"1024", L"1024 kB"},
-    {1024*1024, DATA_UNITS_MEGABYTE, L"1", L"1 MB"},
-    {1024*1024*1024, DATA_UNITS_GIGABYTE, L"1", L"1 GB"},
-    {10LL*1024*1024*1024, DATA_UNITS_GIGABYTE, L"10", L"10 GB"},
-    {~(1LL<<63), DATA_UNITS_GIGABYTE, L"8589934592", L"8589934592 GB"},
+    {512, DATA_UNITS_KIBIBYTE, L"0.5", L"0.5 kB"},
+    {1024*1024, DATA_UNITS_KIBIBYTE, L"1024", L"1024 kB"},
+    {1024*1024, DATA_UNITS_MEBIBYTE, L"1", L"1 MB"},
+    {1024*1024*1024, DATA_UNITS_GIBIBYTE, L"1", L"1 GB"},
+    {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"10", L"10 GB"},
+    {~(1LL<<63), DATA_UNITS_GIBIBYTE, L"8589934592", L"8589934592 GB"},
     // Make sure the first digit of the fractional part works.
-    {1024*1024 + 103, DATA_UNITS_KILOBYTE, L"1024.1", L"1024.1 kB"},
-    {1024*1024 + 205 * 1024, DATA_UNITS_MEGABYTE, L"1.2", L"1.2 MB"},
-    {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIGABYTE,
+    {1024*1024 + 103, DATA_UNITS_KIBIBYTE, L"1024.1", L"1024.1 kB"},
+    {1024*1024 + 205 * 1024, DATA_UNITS_MEBIBYTE, L"1.2", L"1.2 MB"},
+    {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIBIBYTE,
      L"1.9", L"1.9 GB"},
-    {10LL*1024*1024*1024, DATA_UNITS_GIGABYTE, L"10", L"10 GB"},
+    {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"10", L"10 GB"},
 #ifdef NDEBUG
     {-1, DATA_UNITS_BYTE, L"", L""},
 #endif
diff --git a/base/trace_event.cc b/base/trace_event.cc
index ff834eaf..fbfd426f 100644
--- a/base/trace_event.cc
+++ b/base/trace_event.cc
@@ -83,7 +83,7 @@
 }
 
 void TraceLog::Heartbeat() {
-  std::string cpu = StringPrintf("%d", process_metrics_->GetCPUUsage());
+  std::string cpu = StringPrintf("%.0f", process_metrics_->GetCPUUsage());
   TRACE_EVENT_INSTANT("heartbeat.cpu", 0, cpu);
 }
 
diff --git a/chrome/app/nibs/TaskManager.xib b/chrome/app/nibs/TaskManager.xib
index 4231806..2fe33d8 100644
--- a/chrome/app/nibs/TaskManager.xib
+++ b/chrome/app/nibs/TaskManager.xib
@@ -8,7 +8,7 @@
 		<string key="IBDocument.HIToolboxVersion">353.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="1" id="9"/>
+			<integer value="3"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -61,26 +61,26 @@
 										<object class="NSTableView" id="573715149">
 											<reference key="NSNextResponder" ref="591559926"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrameSize">{423, 157}</string>
+											<string key="NSFrameSize">{427, 161}</string>
 											<reference key="NSSuperview" ref="591559926"/>
 											<bool key="NSEnabled">YES</bool>
 											<object class="NSTableHeaderView" key="NSHeaderView" id="518410225">
 												<reference key="NSNextResponder" ref="309854133"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrameSize">{423, 17}</string>
+												<string key="NSFrameSize">{427, 17}</string>
 												<reference key="NSSuperview" ref="309854133"/>
 												<reference key="NSTableView" ref="573715149"/>
 											</object>
 											<object class="_NSCornerView" key="NSCornerView" id="704068535">
 												<reference key="NSNextResponder" ref="69694332"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{424, 0}, {16, 17}}</string>
+												<string key="NSFrame">{{428, 0}, {12, 17}}</string>
 												<reference key="NSSuperview" ref="69694332"/>
 											</object>
 											<object class="NSMutableArray" key="NSTableColumns">
 												<bool key="EncodedWithXMLCoder">YES</bool>
 												<object class="NSTableColumn" id="694001717">
-													<double key="NSWidth">4.200000e+02</double>
+													<double key="NSWidth">4.240000e+02</double>
 													<double key="NSMinWidth">4.000000e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -153,7 +153,7 @@
 													<bytes key="NSWhite">MC41AA</bytes>
 												</object>
 											</object>
-											<double key="NSRowHeight">1.700000e+01</double>
+											<double key="NSRowHeight">1.600000e+01</double>
 											<int key="NSTvFlags">1522532352</int>
 											<int key="NSColumnAutoresizingStyle">4</int>
 											<int key="NSDraggingSourceMaskForLocal">15</int>
@@ -161,7 +161,7 @@
 											<bool key="NSAllowsTypeSelect">YES</bool>
 										</object>
 									</object>
-									<string key="NSFrame">{{1, 17}, {423, 157}}</string>
+									<string key="NSFrame">{{1, 17}, {427, 161}}</string>
 									<reference key="NSSuperview" ref="69694332"/>
 									<reference key="NSNextKeyView" ref="573715149"/>
 									<reference key="NSDocView" ref="573715149"/>
@@ -171,8 +171,9 @@
 								<object class="NSScroller" id="820842366">
 									<reference key="NSNextResponder" ref="69694332"/>
 									<int key="NSvFlags">256</int>
-									<string key="NSFrame">{{424, 17}, {15, 157}}</string>
+									<string key="NSFrame">{{428, 17}, {11, 161}}</string>
 									<reference key="NSSuperview" ref="69694332"/>
+									<int key="NSsFlags">256</int>
 									<reference key="NSTarget" ref="69694332"/>
 									<string key="NSAction">_doScroller:</string>
 									<double key="NSCurValue">3.700000e+01</double>
@@ -181,9 +182,9 @@
 								<object class="NSScroller" id="974910523">
 									<reference key="NSNextResponder" ref="69694332"/>
 									<int key="NSvFlags">256</int>
-									<string key="NSFrame">{{1, 174}, {423, 15}}</string>
+									<string key="NSFrame">{{1, 178}, {427, 11}}</string>
 									<reference key="NSSuperview" ref="69694332"/>
-									<int key="NSsFlags">1</int>
+									<int key="NSsFlags">257</int>
 									<reference key="NSTarget" ref="69694332"/>
 									<string key="NSAction">_doScroller:</string>
 									<double key="NSPercent">5.714286e-01</double>
@@ -195,7 +196,7 @@
 										<bool key="EncodedWithXMLCoder">YES</bool>
 										<reference ref="518410225"/>
 									</object>
-									<string key="NSFrame">{{1, 0}, {423, 17}}</string>
+									<string key="NSFrame">{{1, 0}, {427, 17}}</string>
 									<reference key="NSSuperview" ref="69694332"/>
 									<reference key="NSNextKeyView" ref="518410225"/>
 									<reference key="NSDocView" ref="518410225"/>
@@ -213,7 +214,7 @@
 							<reference key="NSContentView" ref="591559926"/>
 							<reference key="NSHeaderClipView" ref="309854133"/>
 							<reference key="NSCornerView" ref="704068535"/>
-							<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+							<bytes key="NSScrollAmts">QSAAAEEgAABBkAAAQZAAAA</bytes>
 						</object>
 						<object class="NSCustomView" id="369147393">
 							<reference key="NSNextResponder" ref="1006"/>
@@ -572,7 +573,7 @@
 					<string>{{274, 515}, {480, 270}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>{{274, 515}, {480, 270}}</string>
-					<reference ref="9"/>
+					<integer value="1"/>
 					<string>{196, 240}</string>
 					<string>{{357, 418}, {480, 270}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 6a0ba3e..5d928de2 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -2555,11 +2555,7 @@
   command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false);
   command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, true);
   command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, true);
-// TODO(viettrungluu): Temporarily disabled on Mac. Must disable here (not in
-// BWC) so that it also affects the page menu. http://crbug.com/13156
-//#if !defined(OS_MACOSX)
   command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true);
-//#endif
   command_updater_.UpdateCommandEnabled(IDC_SELECT_PROFILE, true);
   command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
   command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
diff --git a/chrome/browser/cocoa/task_manager_mac.mm b/chrome/browser/cocoa/task_manager_mac.mm
index 91e8f92..4d0741b0 100644
--- a/chrome/browser/cocoa/task_manager_mac.mm
+++ b/chrome/browser/cocoa/task_manager_mac.mm
@@ -91,6 +91,9 @@
   [[column.get() headerCell] setAlignment:textAlignment];
   [[column.get() dataCell] setAlignment:textAlignment];
 
+  NSFont* font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+  [[column.get() dataCell] setFont:font];
+  
   [column.get() setHidden:!isVisible];
   [column.get() setEditable:NO];
   [tableView_ addTableColumn:column.get()];
@@ -109,6 +112,8 @@
       [[NSButtonCell alloc] initTextCell:@""]);
   [nameCell.get() setImagePosition:NSImageLeft];
   [nameCell.get() setButtonType:NSSwitchButton];
+  [nameCell.get() setAlignment:[[nameColumn dataCell] alignment]];
+  [nameCell.get() setFont:[[nameColumn dataCell] font]];
   [nameColumn setDataCell:nameCell.get()];
 
   [self addColumnWithId:IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN visible:YES];
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 0667f94..ab2044f 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -36,7 +36,12 @@
 namespace {
 
 // The delay between updates of the information (in ms).
+#if defined(OS_MACOSX)
+// Match Activity Monitor's default refresh rate.
+const int kUpdateTimeMs = 2000;
+#else
 const int kUpdateTimeMs = 1000;
+#endif
 
 template <class T>
 int ValueCompare(T value1, T value2) {
@@ -49,8 +54,8 @@
 
 std::wstring FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) {
   return l10n_util::GetStringF(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT,
-      FormatBytes(stat.size, DATA_UNITS_KILOBYTE, false),
-      FormatBytes(stat.liveSize, DATA_UNITS_KILOBYTE, false));
+      FormatBytes(stat.size, DATA_UNITS_KIBIBYTE, false),
+      FormatBytes(stat.liveSize, DATA_UNITS_KIBIBYTE, false));
 }
 
 }  // namespace
@@ -124,7 +129,15 @@
 
 std::wstring TaskManagerModel::GetResourceCPUUsage(int index) const {
   DCHECK(index < ResourceCount());
-  return IntToWString(GetCPUUsage(resources_[index]));
+  return StringPrintf(
+#if defined(OS_MACOSX)
+      // Activity Monitor shows %cpu with one decimal digit -- be
+      // consistent with that.
+      L"%.1f",
+#else
+      L"%.0f",
+#endif
+      GetCPUUsage(resources_[index]));
 }
 
 std::wstring TaskManagerModel::GetResourcePrivateMemory(int index) const {
@@ -198,7 +211,7 @@
   DCHECK(index < ResourceCount());
   if (!resources_[index]->ReportsSqliteMemoryUsed())
     return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT);
-  return GetMemCellText(resources_[index]->SqliteMemoryUsedBytes() / 1024);
+  return GetMemCellText(resources_[index]->SqliteMemoryUsedBytes());
 }
 
 std::wstring TaskManagerModel::GetResourceV8MemoryAllocatedSize(
@@ -207,10 +220,10 @@
     return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT);
   return l10n_util::GetStringF(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT,
       FormatBytes(resources_[index]->GetV8MemoryAllocated(),
-                  DATA_UNITS_KILOBYTE,
+                  DATA_UNITS_KIBIBYTE,
                   false),
       FormatBytes(resources_[index]->GetV8MemoryUsed(),
-                  DATA_UNITS_KILOBYTE,
+                  DATA_UNITS_KIBIBYTE,
                   false));
 }
 
@@ -285,8 +298,8 @@
                                  GetNetworkUsage(resources_[row2]));
 
     case IDS_TASK_MANAGER_CPU_COLUMN:
-      return ValueCompare<int>(GetCPUUsage(resources_[row1]),
-                               GetCPUUsage(resources_[row2]));
+      return ValueCompare<double>(GetCPUUsage(resources_[row1]),
+                                  GetCPUUsage(resources_[row2]));
 
     case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: {
       size_t value1;
@@ -366,7 +379,7 @@
   return net_usage;
 }
 
-int TaskManagerModel::GetCPUUsage(TaskManager::Resource* resource) const {
+double TaskManagerModel::GetCPUUsage(TaskManager::Resource* resource) const {
   CPUUsageMap::const_iterator iter =
       cpu_usage_map_.find(resource->GetProcess());
   if (iter == cpu_usage_map_.end())
@@ -379,7 +392,7 @@
   base::ProcessMetrics* process_metrics;
   if (!GetProcessMetricsForRow(index, &process_metrics))
     return false;
-  *result = process_metrics->GetPrivateBytes() / 1024;
+  *result = process_metrics->GetPrivateBytes();
   // On Linux (so far) and win XP, this is not supported and returns 0.
   // Remove with crbug.com/23258
   if (*result == 0)
@@ -395,7 +408,7 @@
   base::WorkingSetKBytes ws_usage;
   if (!process_metrics->GetWorkingSetKBytes(&ws_usage))
     return false;
-  *result = ws_usage.shared;
+  *result = ws_usage.shared * 1024;
   return true;
 }
 
@@ -410,9 +423,9 @@
 
   // Memory = working_set.private + working_set.shareable.
   // We exclude the shared memory.
-  size_t total_kbytes = process_metrics->GetWorkingSetSize() / 1024;
-  total_kbytes -= ws_usage.shared;
-  *result = total_kbytes;
+  size_t total_bytes = process_metrics->GetWorkingSetSize();
+  total_bytes -= ws_usage.shared * 1024;
+  *result = total_bytes;
   return true;
 }
 
@@ -432,11 +445,18 @@
 }
 
 std::wstring TaskManagerModel::GetMemCellText(int64 number) const {
-  std::wstring str = UTF16ToWide(base::FormatNumber(number));
+#if !defined(OS_MACOSX)
+  std::wstring str = UTF16ToWide(base::FormatNumber(number / 1024));
 
   // Adjust number string if necessary.
   l10n_util::AdjustStringForLocaleDirection(str, &str);
   return l10n_util::GetStringF(IDS_TASK_MANAGER_MEM_CELL_TEXT, str);
+#else
+  // System expectation is to show "100 KB", "200 MB", etc.
+  // TODO(thakis): Switch to metric units (as opposed to powers of two).
+  return FormatBytes(
+      number, GetByteDisplayUnits(number), /* show_units=*/true);
+#endif
 }
 
 void TaskManagerModel::StartUpdating() {
diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h
index f49e1e5..1ff02d10 100644
--- a/chrome/browser/task_manager.h
+++ b/chrome/browser/task_manager.h
@@ -299,7 +299,7 @@
   typedef std::vector<TaskManager::ResourceProvider*> ResourceProviderList;
   typedef std::map<base::ProcessHandle, ResourceList*> GroupMap;
   typedef std::map<base::ProcessHandle, base::ProcessMetrics*> MetricsMap;
-  typedef std::map<base::ProcessHandle, int> CPUUsageMap;
+  typedef std::map<base::ProcessHandle, double> CPUUsageMap;
   typedef std::map<TaskManager::Resource*, int64> ResourceValueMap;
 
   // Updates the values for all rows.
@@ -326,17 +326,17 @@
 
   // Returns the CPU usage (in %) that should be displayed for the passed
   // |resource|.
-  int GetCPUUsage(TaskManager::Resource* resource) const;
+  double GetCPUUsage(TaskManager::Resource* resource) const;
 
-  // Gets the private memory (in KB) that should be displayed for the passed
+  // Gets the private memory (in bytes) that should be displayed for the passed
   // resource index.
   bool GetPrivateMemory(int index, size_t* result) const;
 
-  // Gets the shared memory (in KB) that should be displayed for the passed
+  // Gets the shared memory (in bytes) that should be displayed for the passed
   // resource index.
   bool GetSharedMemory(int index, size_t* result) const;
 
-  // Gets the physical memory (in KB) that should be displayed for the passed
+  // Gets the physical memory (in bytes) that should be displayed for the passed
   // resource index.
   bool GetPhysicalMemory(int index, size_t* result) const;