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

Unified Diff: ash/system/monitor/tray_monitor.cc

Issue 11345017: Create ash memory monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New files Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/monitor/tray_monitor.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ash/system/monitor/tray_monitor.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698