| 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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/timer.h" | |
| 11 #include "chrome/browser/chromeos/status/status_area_button.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "ui/views/controls/button/menu_button_listener.h" | |
| 15 #include "ui/views/controls/menu/menu_delegate.h" | |
| 16 | |
| 17 namespace base { | |
| 18 struct SystemMemoryInfoKB; | |
| 19 } | |
| 20 | |
| 21 namespace views { | |
| 22 class MenuItemView; | |
| 23 class MenuRunner; | |
| 24 } | |
| 25 | |
| 26 // Memory debugging display that lives in the status area. | |
| 27 class MemoryMenuButton : public StatusAreaButton, | |
| 28 public views::MenuDelegate, | |
| 29 public views::MenuButtonListener, | |
| 30 public content::NotificationObserver { | |
| 31 public: | |
| 32 explicit MemoryMenuButton(StatusAreaButton::Delegate* delegate); | |
| 33 virtual ~MemoryMenuButton(); | |
| 34 | |
| 35 // views::MenuDelegate implementation | |
| 36 virtual string16 GetLabel(int id) const OVERRIDE; | |
| 37 virtual bool IsCommandEnabled(int id) const OVERRIDE; | |
| 38 virtual void ExecuteCommand(int id) OVERRIDE; | |
| 39 | |
| 40 // views::MenuButtonListener implementation. | |
| 41 virtual void OnMenuButtonClicked(views::View* source, | |
| 42 const gfx::Point& point) OVERRIDE; | |
| 43 | |
| 44 // content::NotificationObserver overrides. | |
| 45 virtual void Observe(int type, | |
| 46 const content::NotificationSource& source, | |
| 47 const content::NotificationDetails& details) OVERRIDE; | |
| 48 | |
| 49 // Updates the text on the menu button. | |
| 50 void UpdateText(); | |
| 51 | |
| 52 protected: | |
| 53 virtual int horizontal_padding() OVERRIDE; | |
| 54 | |
| 55 private: | |
| 56 // Execute command id for each renderer. Used for heap profiling. | |
| 57 void SendCommandToRenderers(int id); | |
| 58 | |
| 59 // Creates and returns the menu. The caller owns the returned value. | |
| 60 views::MenuItemView* CreateMenu(); | |
| 61 | |
| 62 // Updates text and schedules the timer to fire at the next minute interval. | |
| 63 void UpdateTextAndSetNextTimer(); | |
| 64 | |
| 65 base::OneShotTimer<MemoryMenuButton> timer_; | |
| 66 | |
| 67 // Raw data from /proc/meminfo | |
| 68 scoped_ptr<base::SystemMemoryInfoKB> meminfo_; | |
| 69 | |
| 70 content::NotificationRegistrar registrar_; | |
| 71 | |
| 72 // Number of renderer kills we have observed. | |
| 73 int renderer_kills_; | |
| 74 | |
| 75 scoped_ptr<views::MenuRunner> menu_runner_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton); | |
| 78 }; | |
| 79 | |
| 80 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | |
| OLD | NEW |