OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/system/monitor/tray_monitor.h" | |
sadrul
2012/10/29 23:50:57
new line after this
DaveMoore
2012/10/30 16:18:49
Done.
| |
6 #include "ash/system/tray/tray_item_view.h" | |
7 #include "base/process_util.h" | |
8 #include "base/stringprintf.h" | |
9 #include "base/utf_string_conversions.h" | |
10 #include "ui/base/text/bytes_formatting.h" | |
11 #include "ui/views/controls/label.h" | |
12 #include "ui/views/border.h" | |
13 | |
14 namespace { | |
15 const int kRefreshTimeoutMs = 1000; | |
16 } | |
17 namespace ash { | |
18 namespace internal { | |
19 | |
20 TrayMonitor::TrayMonitor() : label_(NULL) { | |
21 refresh_timer_.Start(FROM_HERE, | |
22 base::TimeDelta::FromMilliseconds(kRefreshTimeoutMs), | |
23 this, &TrayMonitor::RefreshStats); | |
24 } | |
25 | |
26 TrayMonitor::~TrayMonitor() { | |
27 } | |
28 | |
29 views::View* TrayMonitor::CreateTrayView(user::LoginStatus status) { | |
30 TrayItemView* view = new TrayItemView; | |
31 view->CreateLabel(); | |
32 label_ = view->label(); | |
sadrul
2012/10/29 23:50:57
You should reset |label_| to NULL in DestroyTrayVi
DaveMoore
2012/10/30 16:18:49
Done.
sadrul
2012/10/30 16:44:47
I actually meant from TrayMonitor::DestroyTrayView
| |
33 label_->SetFont( | |
34 label_->font().DeriveFont(2, gfx::Font::BOLD)); | |
35 label_->SetAutoColorReadabilityEnabled(false); | |
36 label_->SetEnabledColor(SK_ColorWHITE); | |
37 label_->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); | |
38 label_->SetShadowColors(SkColorSetARGB(64, 0, 0, 0), | |
39 SkColorSetARGB(64, 0, 0, 0)); | |
40 label_->SetShadowOffset(0, 1); | |
sadrul
2012/10/29 23:50:57
You can call SetupLabelForTray(view->labe()) to re
DaveMoore
2012/10/30 16:18:49
Done...didn't see that in tray_views.h
On 2012/10/
| |
41 label_->set_border(views::Border::CreateEmptyBorder(0, 4, 0, 0)); | |
42 return view; | |
43 } | |
44 | |
45 void TrayMonitor::RefreshStats() { | |
46 base::SystemMemoryInfoKB mem_info; | |
47 base::GetSystemMemoryInfo(&mem_info); | |
48 std::string output; | |
49 string16 free_bytes = | |
50 ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024); | |
51 output = StringPrintf("%s free", UTF16ToUTF8(free_bytes).c_str()); | |
52 if (mem_info.gem_objects != -1 && mem_info.gem_size != -1) { | |
53 string16 gem_size = ui::FormatBytes(mem_info.gem_size); | |
54 output += StringPrintf(", %d gobjects alloced (%s)", | |
55 mem_info.gem_objects, | |
56 UTF16ToUTF8(gem_size).c_str()); | |
57 } | |
58 label_->SetText(UTF8ToUTF16(output)); | |
59 } | |
60 | |
61 } // namespace internal | |
62 } // namespace ash | |
OLD | NEW |