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

Side by Side Diff: chrome/browser/memory_details.h

Issue 177024: Linux: about:memory (Closed)
Patch Set: ... Created 11 years, 3 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
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_MEMORY_DETAILS_H_ 5 #ifndef CHROME_BROWSER_MEMORY_DETAILS_H_
6 #define CHROME_BROWSER_MEMORY_DETAILS_H_ 6 #define CHROME_BROWSER_MEMORY_DETAILS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "chrome/common/child_process_info.h" 12 #include "chrome/common/child_process_info.h"
13 13
14 class MessageLoop; 14 class MessageLoop;
15 15
16 // We collect data about each browser process. A browser may 16 // We collect data about each browser process. A browser may
17 // have multiple processes (of course!). Even IE has multiple 17 // have multiple processes (of course!). Even IE has multiple
18 // processes these days. 18 // processes these days.
19 struct ProcessMemoryInformation { 19 struct ProcessMemoryInformation {
20 ProcessMemoryInformation() { 20 ProcessMemoryInformation()
21 memset(this, 0, sizeof(ProcessMemoryInformation)); 21 : pid(0),
22 num_processes(0),
23 is_diagnostics(false),
24 type(ChildProcessInfo::UNKNOWN_PROCESS) {
22 } 25 }
23 26
24 // The process id. 27 // The process id.
25 int pid; 28 int pid;
26 // The working set information. 29 // The working set information.
27 base::WorkingSetKBytes working_set; 30 base::WorkingSetKBytes working_set;
28 // The committed bytes. 31 // The committed bytes.
29 base::CommittedKBytes committed; 32 base::CommittedKBytes committed;
30 // The process version 33 // The process version
31 std::wstring version; 34 std::wstring version;
32 // The process product name. 35 // The process product name.
33 std::wstring product_name; 36 std::wstring product_name;
34 // The number of processes which this memory represents. 37 // The number of processes which this memory represents.
35 int num_processes; 38 int num_processes;
36 // A process is a diagnostics process if it is rendering 39 // A process is a diagnostics process if it is rendering
37 // about:xxx information. 40 // about:xxx information.
38 bool is_diagnostics; 41 bool is_diagnostics;
39 // If this is a child process of Chrome, what type (i.e. plugin) it is. 42 // If this is a child process of Chrome, what type (i.e. plugin) it is.
40 ChildProcessInfo::ProcessType type; 43 ChildProcessInfo::ProcessType type;
41 // A collection of titles used, i.e. for a tab it'll show all the page titles. 44 // A collection of titles used, i.e. for a tab it'll show all the page titles.
42 std::vector<std::wstring> titles; 45 std::vector<std::wstring> titles;
43 }; 46 };
44 47
45 typedef std::vector<ProcessMemoryInformation> ProcessMemoryInformationList; 48 typedef std::vector<ProcessMemoryInformation> ProcessMemoryInformationList;
46 49
47 // Browser Process Information. 50 // Browser Process Information.
48 struct ProcessData { 51 struct ProcessData {
49 const wchar_t* name; 52 std::wstring name;
50 const wchar_t* process_name; 53 std::wstring process_name;
51 ProcessMemoryInformationList processes; 54 ProcessMemoryInformationList processes;
52 }; 55 };
53 56
54 // MemoryDetails fetches memory details about current running browsers. 57 // MemoryDetails fetches memory details about current running browsers.
55 // Because this data can only be fetched asynchronously, callers use 58 // Because this data can only be fetched asynchronously, callers use
56 // this class via a callback. 59 // this class via a callback.
57 // 60 //
58 // Example usage: 61 // Example usage:
59 // 62 //
60 // class MyMemoryDetailConsumer : public MemoryDetails { 63 // class MyMemoryDetailConsumer : public MemoryDetails {
61 // 64 //
62 // MyMemoryDetailConsumer() : MemoryDetails(true) { 65 // MyMemoryDetailConsumer() : MemoryDetails(true) {
63 // StartFetch(); // Starts fetching details. 66 // StartFetch(); // Starts fetching details.
64 // } 67 // }
65 // 68 //
66 // // Your class stuff here 69 // // Your class stuff here
67 // 70 //
68 // virtual void OnDetailsAvailable() { 71 // virtual void OnDetailsAvailable() {
69 // // do work with memory info here 72 // // do work with memory info here
70 // } 73 // }
71 // } 74 // }
72 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> { 75 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> {
73 public: 76 public:
74 // Known browsers which we collect details for.
75 enum {
76 CHROME_BROWSER = 0,
77 IE_BROWSER,
78 FIREFOX_BROWSER,
79 OPERA_BROWSER,
80 SAFARI_BROWSER,
81 IE_64BIT_BROWSER,
82 KONQUEROR_BROWSER,
83 MAX_BROWSERS
84 } BrowserProcess;
85
86 // Constructor. 77 // Constructor.
87 MemoryDetails(); 78 MemoryDetails();
88 virtual ~MemoryDetails() {} 79 virtual ~MemoryDetails() {}
89 80
90 // Access to the process detail information. This is an array 81 // Access to the process detail information. This data is only available
91 // of MAX_BROWSER ProcessData structures. This data is only available
92 // after OnDetailsAvailable() has been called. 82 // after OnDetailsAvailable() has been called.
93 ProcessData* processes() { return process_data_; } 83 const std::vector<ProcessData>& processes() { return process_data_; }
94 84
95 // Initiate updating the current memory details. These are fetched 85 // Initiate updating the current memory details. These are fetched
96 // asynchronously because data must be collected from multiple threads. 86 // asynchronously because data must be collected from multiple threads.
97 // OnDetailsAvailable will be called when this process is complete. 87 // OnDetailsAvailable will be called when this process is complete.
98 void StartFetch(); 88 void StartFetch();
99 89
100 virtual void OnDetailsAvailable() {} 90 virtual void OnDetailsAvailable() {}
101 91
102 private: 92 private:
103 // Collect child process information on the IO thread. This is needed because 93 // Collect child process information on the IO thread. This is needed because
(...skipping 12 matching lines...) Expand all
116 void CollectProcessData(std::vector<ProcessMemoryInformation>); 106 void CollectProcessData(std::vector<ProcessMemoryInformation>);
117 107
118 // Collect child process information on the UI thread. Information about 108 // Collect child process information on the UI thread. Information about
119 // renderer processes is only available there. 109 // renderer processes is only available there.
120 void CollectChildInfoOnUIThread(); 110 void CollectChildInfoOnUIThread();
121 111
122 // Each time we take a memory sample, we do a little work to update 112 // Each time we take a memory sample, we do a little work to update
123 // the global histograms for tracking memory usage. 113 // the global histograms for tracking memory usage.
124 void UpdateHistograms(); 114 void UpdateHistograms();
125 115
126 ProcessData process_data_[MAX_BROWSERS]; 116 // Returns a pointer to the ProcessData structure for Chrome.
117 ProcessData* ChromeBrowser();
118
119 std::vector<ProcessData> process_data_;
127 MessageLoop* ui_loop_; 120 MessageLoop* ui_loop_;
128 121
129 DISALLOW_EVIL_CONSTRUCTORS(MemoryDetails); 122 DISALLOW_EVIL_CONSTRUCTORS(MemoryDetails);
130 }; 123 };
131 124
132 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_ 125 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698