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

Side by Side Diff: ash/system/monitor/tray_monitor.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/system/monitor/tray_monitor.h" 5 #include "ash/system/monitor/tray_monitor.h"
6 6
7 #include "ash/system/tray/tray_item_view.h" 7 #include "ash/system/tray/tray_item_view.h"
8 #include "ash/system/tray/tray_views.h" 8 #include "ash/system/tray/tray_views.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 refresh_timer_.Stop(); 58 refresh_timer_.Stop();
59 content::GpuDataManager::GetInstance()->GetGpuProcessHandles(callback); 59 content::GpuDataManager::GetInstance()->GetGpuProcessHandles(callback);
60 } 60 }
61 61
62 void TrayMonitor::OnGotHandles(const std::list<base::ProcessHandle>& handles) { 62 void TrayMonitor::OnGotHandles(const std::list<base::ProcessHandle>& handles) {
63 base::SystemMemoryInfoKB mem_info; 63 base::SystemMemoryInfoKB mem_info;
64 base::GetSystemMemoryInfo(&mem_info); 64 base::GetSystemMemoryInfo(&mem_info);
65 std::string output; 65 std::string output;
66 string16 free_bytes = 66 string16 free_bytes =
67 ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024); 67 ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024);
68 output = StringPrintf("free: %s", UTF16ToUTF8(free_bytes).c_str()); 68 output = base::StringPrintf("free: %s", UTF16ToUTF8(free_bytes).c_str());
69 if (mem_info.gem_size != -1) { 69 if (mem_info.gem_size != -1) {
70 string16 gem_size = ui::FormatBytes(mem_info.gem_size); 70 string16 gem_size = ui::FormatBytes(mem_info.gem_size);
71 output += StringPrintf(" gmem: %s", UTF16ToUTF8(gem_size).c_str()); 71 output += base::StringPrintf(" gmem: %s", UTF16ToUTF8(gem_size).c_str());
72 if (mem_info.gem_objects != -1) 72 if (mem_info.gem_objects != -1)
73 output += StringPrintf(" gobjects: %d", mem_info.gem_objects); 73 output += base::StringPrintf(" gobjects: %d", mem_info.gem_objects);
74 } 74 }
75 size_t total_private_bytes = 0, total_shared_bytes = 0; 75 size_t total_private_bytes = 0, total_shared_bytes = 0;
76 for (std::list<base::ProcessHandle>::const_iterator i = handles.begin(); 76 for (std::list<base::ProcessHandle>::const_iterator i = handles.begin();
77 i != handles.end(); ++i) { 77 i != handles.end(); ++i) {
78 base::ProcessMetrics* pm = base::ProcessMetrics::CreateProcessMetrics(*i); 78 base::ProcessMetrics* pm = base::ProcessMetrics::CreateProcessMetrics(*i);
79 size_t private_bytes, shared_bytes; 79 size_t private_bytes, shared_bytes;
80 pm->GetMemoryBytes(&private_bytes, &shared_bytes); 80 pm->GetMemoryBytes(&private_bytes, &shared_bytes);
81 total_private_bytes += private_bytes; 81 total_private_bytes += private_bytes;
82 total_shared_bytes += shared_bytes; 82 total_shared_bytes += shared_bytes;
83 delete pm; 83 delete pm;
84 } 84 }
85 string16 private_size = ui::FormatBytes(total_private_bytes); 85 string16 private_size = ui::FormatBytes(total_private_bytes);
86 string16 shared_size = ui::FormatBytes(total_shared_bytes); 86 string16 shared_size = ui::FormatBytes(total_shared_bytes);
87 87
88 output += StringPrintf("\nGPU private: %s shared: %s", 88 output += base::StringPrintf("\nGPU private: %s shared: %s",
89 UTF16ToUTF8(private_size).c_str(), 89 UTF16ToUTF8(private_size).c_str(),
90 UTF16ToUTF8(shared_size).c_str()); 90 UTF16ToUTF8(shared_size).c_str());
91 label_->SetText(UTF8ToUTF16(output)); 91 label_->SetText(UTF8ToUTF16(output));
92 refresh_timer_.Start(FROM_HERE, 92 refresh_timer_.Start(FROM_HERE,
93 base::TimeDelta::FromMilliseconds(kRefreshTimeoutMs), 93 base::TimeDelta::FromMilliseconds(kRefreshTimeoutMs),
94 this, &TrayMonitor::OnTimer); 94 this, &TrayMonitor::OnTimer);
95 } 95 }
96 96
97 } // namespace internal 97 } // namespace internal
98 } // namespace ash 98 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698