OLD | NEW |
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/gpu_support.h" |
| 8 #include "ash/shell.h" |
7 #include "ash/system/tray/tray_item_view.h" | 9 #include "ash/system/tray/tray_item_view.h" |
8 #include "base/process/memory.h" | 10 #include "base/process/memory.h" |
9 #include "base/process/process_metrics.h" | 11 #include "base/process/process_metrics.h" |
10 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "content/public/browser/gpu_data_manager.h" | |
13 #include "ui/base/text/bytes_formatting.h" | 14 #include "ui/base/text/bytes_formatting.h" |
14 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
15 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 const int kRefreshTimeoutMs = 1000; | 19 const int kRefreshTimeoutMs = 1000; |
19 } | 20 } |
20 | 21 |
21 namespace ash { | 22 namespace ash { |
22 namespace internal { | 23 namespace internal { |
(...skipping 23 matching lines...) Expand all Loading... |
46 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 47 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
47 label_->SetFontList(label_->font_list().DeriveFontListWithSizeDelta(-2)); | 48 label_->SetFontList(label_->font_list().DeriveFontListWithSizeDelta(-2)); |
48 return view; | 49 return view; |
49 } | 50 } |
50 | 51 |
51 void TrayMonitor::DestroyTrayView() { | 52 void TrayMonitor::DestroyTrayView() { |
52 label_ = NULL; | 53 label_ = NULL; |
53 } | 54 } |
54 | 55 |
55 void TrayMonitor::OnTimer() { | 56 void TrayMonitor::OnTimer() { |
56 content::GpuDataManager::GetGpuProcessHandlesCallback callback = | 57 GPUSupport::GetGpuProcessHandlesCallback callback = |
57 base::Bind(&TrayMonitor::OnGotHandles, base::Unretained(this)); | 58 base::Bind(&TrayMonitor::OnGotHandles, base::Unretained(this)); |
58 refresh_timer_.Stop(); | 59 refresh_timer_.Stop(); |
59 content::GpuDataManager::GetInstance()->GetGpuProcessHandles(callback); | 60 Shell::GetInstance()->gpu_support()->GetGpuProcessHandles(callback); |
60 } | 61 } |
61 | 62 |
62 void TrayMonitor::OnGotHandles(const std::list<base::ProcessHandle>& handles) { | 63 void TrayMonitor::OnGotHandles(const std::list<base::ProcessHandle>& handles) { |
63 base::SystemMemoryInfoKB mem_info; | 64 base::SystemMemoryInfoKB mem_info; |
64 base::GetSystemMemoryInfo(&mem_info); | 65 base::GetSystemMemoryInfo(&mem_info); |
65 std::string output; | 66 std::string output; |
66 base::string16 free_bytes = | 67 base::string16 free_bytes = |
67 ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024); | 68 ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024); |
68 output = base::StringPrintf("free: %s", | 69 output = base::StringPrintf("free: %s", |
69 base::UTF16ToUTF8(free_bytes).c_str()); | 70 base::UTF16ToUTF8(free_bytes).c_str()); |
(...skipping 23 matching lines...) Expand all Loading... |
93 base::UTF16ToUTF8(private_size).c_str(), | 94 base::UTF16ToUTF8(private_size).c_str(), |
94 base::UTF16ToUTF8(shared_size).c_str()); | 95 base::UTF16ToUTF8(shared_size).c_str()); |
95 label_->SetText(base::UTF8ToUTF16(output)); | 96 label_->SetText(base::UTF8ToUTF16(output)); |
96 refresh_timer_.Start(FROM_HERE, | 97 refresh_timer_.Start(FROM_HERE, |
97 base::TimeDelta::FromMilliseconds(kRefreshTimeoutMs), | 98 base::TimeDelta::FromMilliseconds(kRefreshTimeoutMs), |
98 this, &TrayMonitor::OnTimer); | 99 this, &TrayMonitor::OnTimer); |
99 } | 100 } |
100 | 101 |
101 } // namespace internal | 102 } // namespace internal |
102 } // namespace ash | 103 } // namespace ash |
OLD | NEW |