OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/chromeos/status/status_area_button.h" | 11 #include "chrome/browser/chromeos/status/status_area_button.h" |
12 #include "content/common/notification_observer.h" | 12 #include "content/common/notification_observer.h" |
13 #include "content/common/notification_registrar.h" | 13 #include "content/common/notification_registrar.h" |
14 #include "views/controls/menu/menu_delegate.h" | 14 #include "views/controls/menu/menu_delegate.h" |
15 #include "views/controls/menu/view_menu_delegate.h" | 15 #include "views/controls/menu/view_menu_delegate.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 struct SystemMemoryInfoKB; | 18 struct SystemMemoryInfoKB; |
19 } | 19 } |
20 | 20 |
21 namespace views { | 21 namespace views { |
22 class MenuItemView; | 22 class MenuItemView; |
| 23 class MenuRunner; |
23 } | 24 } |
24 | 25 |
25 namespace chromeos { | 26 namespace chromeos { |
26 | 27 |
27 class StatusAreaHost; | 28 class StatusAreaHost; |
28 | 29 |
29 // Memory debugging display that lives in the status area. | 30 // Memory debugging display that lives in the status area. |
30 class MemoryMenuButton : public StatusAreaButton, | 31 class MemoryMenuButton : public StatusAreaButton, |
31 public views::MenuDelegate, | 32 public views::MenuDelegate, |
32 public views::ViewMenuDelegate, | 33 public views::ViewMenuDelegate, |
(...skipping 18 matching lines...) Expand all Loading... |
51 // Updates the text on the menu button. | 52 // Updates the text on the menu button. |
52 void UpdateText(); | 53 void UpdateText(); |
53 | 54 |
54 protected: | 55 protected: |
55 virtual int horizontal_padding() OVERRIDE; | 56 virtual int horizontal_padding() OVERRIDE; |
56 | 57 |
57 private: | 58 private: |
58 // Execute command id for each renderer. Used for heap profiling. | 59 // Execute command id for each renderer. Used for heap profiling. |
59 void SendCommandToRenderers(int id); | 60 void SendCommandToRenderers(int id); |
60 | 61 |
61 // Create and initialize menu if not already present. | 62 // Creates and returns the menu. The caller owns the returned value. |
62 void EnsureMenu(); | 63 views::MenuItemView* CreateMenu(); |
63 | 64 |
64 // Updates text and schedules the timer to fire at the next minute interval. | 65 // Updates text and schedules the timer to fire at the next minute interval. |
65 void UpdateTextAndSetNextTimer(); | 66 void UpdateTextAndSetNextTimer(); |
66 | 67 |
67 base::OneShotTimer<MemoryMenuButton> timer_; | 68 base::OneShotTimer<MemoryMenuButton> timer_; |
68 | 69 |
69 // NOTE: we use a scoped_ptr here as menu calls into 'this' from the | |
70 // constructor. | |
71 scoped_ptr<views::MenuItemView> menu_; | |
72 | |
73 // Raw data from /proc/meminfo | 70 // Raw data from /proc/meminfo |
74 scoped_ptr<base::SystemMemoryInfoKB> meminfo_; | 71 scoped_ptr<base::SystemMemoryInfoKB> meminfo_; |
75 | 72 |
76 NotificationRegistrar registrar_; | 73 NotificationRegistrar registrar_; |
77 | 74 |
78 // Number of renderer kills we have observed. | 75 // Number of renderer kills we have observed. |
79 int renderer_kills_; | 76 int renderer_kills_; |
80 | 77 |
81 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton); | 78 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton); |
82 }; | 79 }; |
83 | 80 |
84 } // namespace chromeos | 81 } // namespace chromeos |
85 | 82 |
86 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ | 83 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ |
OLD | NEW |