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

Side by Side Diff: chrome/browser/chromeos/status/memory_menu_button.h

Issue 7607035: CrOS - Memory debug widget shows anonymous memory and renderer kills. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
13 #include "content/common/notification_registrar.h"
12 #include "views/controls/menu/menu_delegate.h" 14 #include "views/controls/menu/menu_delegate.h"
13 #include "views/controls/menu/view_menu_delegate.h" 15 #include "views/controls/menu/view_menu_delegate.h"
14 16
17 namespace base {
18 class SystemMemoryInfoKB;
stevenjb 2011/08/10 19:45:51 struct
James Cook 2011/08/10 22:07:52 Done.
19 }
20
15 namespace views { 21 namespace views {
16 class MenuItemView; 22 class MenuItemView;
17 } 23 }
18 24
19 namespace chromeos { 25 namespace chromeos {
20 26
21 class StatusAreaHost; 27 class StatusAreaHost;
22 28
23 // Memory debugging display that lives in the status area. 29 // Memory debugging display that lives in the status area.
24 class MemoryMenuButton : public StatusAreaButton, 30 class MemoryMenuButton : public StatusAreaButton,
25 public views::MenuDelegate, 31 public views::MenuDelegate,
26 public views::ViewMenuDelegate { 32 public views::ViewMenuDelegate,
33 public NotificationObserver {
27 public: 34 public:
28 explicit MemoryMenuButton(StatusAreaHost* host); 35 explicit MemoryMenuButton(StatusAreaHost* host);
29 virtual ~MemoryMenuButton(); 36 virtual ~MemoryMenuButton();
30 37
31 // views::MenuDelegate implementation 38 // views::MenuDelegate implementation
32 virtual std::wstring GetLabel(int id) const OVERRIDE; 39 virtual std::wstring GetLabel(int id) const OVERRIDE;
33 virtual bool IsCommandEnabled(int id) const OVERRIDE; 40 virtual bool IsCommandEnabled(int id) const OVERRIDE;
34 virtual void ExecuteCommand(int id) OVERRIDE; 41 virtual void ExecuteCommand(int id) OVERRIDE;
35 42
43 // views::ViewMenuDelegate implementation.
44 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE;
45
46 // NotificationObserver overrides.
47 virtual void Observe(int type,
48 const NotificationSource& source,
49 const NotificationDetails& details) OVERRIDE;
50
36 // Updates the text on the menu button. 51 // Updates the text on the menu button.
37 void UpdateText(); 52 void UpdateText();
38 53
39 protected: 54 protected:
40 virtual int horizontal_padding() OVERRIDE; 55 virtual int horizontal_padding() OVERRIDE;
41 56
42 private: 57 private:
43 // views::ViewMenuDelegate implementation.
44 virtual void RunMenu(views::View* source, const gfx::Point& pt);
45
46 // Create and initialize menu if not already present. 58 // Create and initialize menu if not already present.
47 void EnsureMenu(); 59 void EnsureMenu();
48 60
49 // Updates text and schedules the timer to fire at the next minute interval. 61 // Updates text and schedules the timer to fire at the next minute interval.
50 void UpdateTextAndSetNextTimer(); 62 void UpdateTextAndSetNextTimer();
51 63
52 base::OneShotTimer<MemoryMenuButton> timer_; 64 base::OneShotTimer<MemoryMenuButton> timer_;
53 65
54 // NOTE: we use a scoped_ptr here as menu calls into 'this' from the 66 // NOTE: we use a scoped_ptr here as menu calls into 'this' from the
55 // constructor. 67 // constructor.
56 scoped_ptr<views::MenuItemView> menu_; 68 scoped_ptr<views::MenuItemView> menu_;
57 69
58 int mem_total_; 70 // Raw data from /proc/meminfo
59 int shmem_; // video driver memory, hidden from OS 71 base::SystemMemoryInfoKB* meminfo_;
stevenjb 2011/08/10 19:45:51 scoped_ptr<>
James Cook 2011/08/10 22:07:52 Done.
60 int mem_free_; 72
61 int mem_buffers_; 73 NotificationRegistrar registrar_;
62 int mem_cache_; 74
75 // Number of renderer kills we have observed.
76 int renderer_kills_;
63 77
64 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton); 78 DISALLOW_COPY_AND_ASSIGN(MemoryMenuButton);
65 }; 79 };
66 80
67 } // namespace chromeos 81 } // namespace chromeos
68 82
69 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_ 83 #endif // CHROME_BROWSER_CHROMEOS_STATUS_MEMORY_MENU_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698