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