Index: ash/system/monitor/tray_monitor.cc |
diff --git a/ash/system/monitor/tray_monitor.cc b/ash/system/monitor/tray_monitor.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..61d1debe151c179fb35bc8ac83fa83e43370455e |
--- /dev/null |
+++ b/ash/system/monitor/tray_monitor.cc |
@@ -0,0 +1,62 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#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.
|
+#include "ash/system/tray/tray_item_view.h" |
+#include "base/process_util.h" |
+#include "base/stringprintf.h" |
+#include "base/utf_string_conversions.h" |
+#include "ui/base/text/bytes_formatting.h" |
+#include "ui/views/controls/label.h" |
+#include "ui/views/border.h" |
+ |
+namespace { |
+const int kRefreshTimeoutMs = 1000; |
+} |
+namespace ash { |
+namespace internal { |
+ |
+TrayMonitor::TrayMonitor() : label_(NULL) { |
+ refresh_timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromMilliseconds(kRefreshTimeoutMs), |
+ this, &TrayMonitor::RefreshStats); |
+} |
+ |
+TrayMonitor::~TrayMonitor() { |
+} |
+ |
+views::View* TrayMonitor::CreateTrayView(user::LoginStatus status) { |
+ TrayItemView* view = new TrayItemView; |
+ view->CreateLabel(); |
+ 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
|
+ label_->SetFont( |
+ label_->font().DeriveFont(2, gfx::Font::BOLD)); |
+ label_->SetAutoColorReadabilityEnabled(false); |
+ label_->SetEnabledColor(SK_ColorWHITE); |
+ label_->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); |
+ label_->SetShadowColors(SkColorSetARGB(64, 0, 0, 0), |
+ SkColorSetARGB(64, 0, 0, 0)); |
+ 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/
|
+ label_->set_border(views::Border::CreateEmptyBorder(0, 4, 0, 0)); |
+ return view; |
+} |
+ |
+void TrayMonitor::RefreshStats() { |
+ base::SystemMemoryInfoKB mem_info; |
+ base::GetSystemMemoryInfo(&mem_info); |
+ std::string output; |
+ string16 free_bytes = |
+ ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024); |
+ output = StringPrintf("%s free", UTF16ToUTF8(free_bytes).c_str()); |
+ if (mem_info.gem_objects != -1 && mem_info.gem_size != -1) { |
+ string16 gem_size = ui::FormatBytes(mem_info.gem_size); |
+ output += StringPrintf(", %d gobjects alloced (%s)", |
+ mem_info.gem_objects, |
+ UTF16ToUTF8(gem_size).c_str()); |
+ } |
+ label_->SetText(UTF8ToUTF16(output)); |
+} |
+ |
+} // namespace internal |
+} // namespace ash |