OLD | NEW |
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() : pid(0), |
21 memset(this, 0, sizeof(ProcessMemoryInformation)); | 21 num_processes(0), |
| 22 is_diagnostics(false) { |
22 } | 23 } |
23 | 24 |
24 // The process id. | 25 // The process id. |
25 int pid; | 26 int pid; |
26 // The working set information. | 27 // The working set information. |
27 base::WorkingSetKBytes working_set; | 28 base::WorkingSetKBytes working_set; |
28 // The committed bytes. | 29 // The committed bytes. |
29 base::CommittedKBytes committed; | 30 base::CommittedKBytes committed; |
30 // The process version | 31 // The process version |
31 std::wstring version; | 32 std::wstring version; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // } | 65 // } |
65 // | 66 // |
66 // // Your class stuff here | 67 // // Your class stuff here |
67 // | 68 // |
68 // virtual void OnDetailsAvailable() { | 69 // virtual void OnDetailsAvailable() { |
69 // // do work with memory info here | 70 // // do work with memory info here |
70 // } | 71 // } |
71 // } | 72 // } |
72 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> { | 73 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> { |
73 public: | 74 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. | 75 // Constructor. |
87 MemoryDetails(); | 76 MemoryDetails(); |
88 virtual ~MemoryDetails() {} | 77 virtual ~MemoryDetails() {} |
89 | 78 |
90 // Access to the process detail information. This is an array | 79 // Access to the process detail information. This is an array |
91 // of MAX_BROWSER ProcessData structures. This data is only available | 80 // of MAX_BROWSER ProcessData structures. This data is only available |
92 // after OnDetailsAvailable() has been called. | 81 // after OnDetailsAvailable() has been called. |
93 ProcessData* processes() { return process_data_; } | 82 const std::vector<ProcessData>& processes() { return process_data_; } |
94 | 83 |
95 // Initiate updating the current memory details. These are fetched | 84 // Initiate updating the current memory details. These are fetched |
96 // asynchronously because data must be collected from multiple threads. | 85 // asynchronously because data must be collected from multiple threads. |
97 // OnDetailsAvailable will be called when this process is complete. | 86 // OnDetailsAvailable will be called when this process is complete. |
98 void StartFetch(); | 87 void StartFetch(); |
99 | 88 |
100 virtual void OnDetailsAvailable() {} | 89 virtual void OnDetailsAvailable() {} |
101 | 90 |
102 private: | 91 private: |
103 // Collect child process information on the IO thread. This is needed because | 92 // Collect child process information on the IO thread. This is needed because |
(...skipping 12 matching lines...) Expand all Loading... |
116 void CollectProcessData(std::vector<ProcessMemoryInformation>); | 105 void CollectProcessData(std::vector<ProcessMemoryInformation>); |
117 | 106 |
118 // Collect child process information on the UI thread. Information about | 107 // Collect child process information on the UI thread. Information about |
119 // renderer processes is only available there. | 108 // renderer processes is only available there. |
120 void CollectChildInfoOnUIThread(); | 109 void CollectChildInfoOnUIThread(); |
121 | 110 |
122 // Each time we take a memory sample, we do a little work to update | 111 // Each time we take a memory sample, we do a little work to update |
123 // the global histograms for tracking memory usage. | 112 // the global histograms for tracking memory usage. |
124 void UpdateHistograms(); | 113 void UpdateHistograms(); |
125 | 114 |
126 ProcessData process_data_[MAX_BROWSERS]; | 115 // Returns a pointer to the ProcessData structure for Chrome. |
| 116 ProcessData* ChromeBrowser(); |
| 117 |
| 118 std::vector<ProcessData> process_data_; |
127 MessageLoop* ui_loop_; | 119 MessageLoop* ui_loop_; |
128 | 120 |
129 DISALLOW_EVIL_CONSTRUCTORS(MemoryDetails); | 121 DISALLOW_EVIL_CONSTRUCTORS(MemoryDetails); |
130 }; | 122 }; |
131 | 123 |
132 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_ | 124 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_ |
OLD | NEW |