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

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

Issue 1874483002: Remove "from all browsers" memory details mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rip out ProcessInfoSnapshot Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // } 105 // }
106 // 106 //
107 // // Your other class stuff here 107 // // Your other class stuff here
108 // 108 //
109 // virtual void OnDetailsAvailable() { 109 // virtual void OnDetailsAvailable() {
110 // // do work with memory info here 110 // // do work with memory info here
111 // } 111 // }
112 // } 112 // }
113 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> { 113 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> {
114 public: 114 public:
115 enum CollectionMode {
116 // Collect metrics from Chrome and other running browsers.
117 FROM_ALL_BROWSERS,
118 // Collect metrics from Chrome processes only.
119 FROM_CHROME_ONLY
120 };
121
122 // Constructor. 115 // Constructor.
123 MemoryDetails(); 116 MemoryDetails();
124 117
125 // Initiate updating the current memory details (based on |mode|). These are 118 // Initiate updating the current memory details. These are fetched
126 // fetched asynchronously because data must be collected from multiple 119 // asynchronously because data must be collected from multiple threads.
127 // threads. OnDetailsAvailable will be called when this process is complete. 120 // OnDetailsAvailable will be called when this process is complete.
128 void StartFetch(CollectionMode mode); 121 void StartFetch();
129 122
130 virtual void OnDetailsAvailable() = 0; 123 virtual void OnDetailsAvailable() = 0;
131 124
132 // Returns a string summarizing memory usage of the Chrome browser process 125 // Returns a string summarizing memory usage of the Chrome browser process
133 // and all sub-processes, suitable for logging. 126 // and all sub-processes, suitable for logging.
134 std::string ToLogString(); 127 std::string ToLogString();
135 128
136 protected: 129 protected:
137 friend class base::RefCountedThreadSafe<MemoryDetails>; 130 friend class base::RefCountedThreadSafe<MemoryDetails>;
138 131
139 virtual ~MemoryDetails(); 132 virtual ~MemoryDetails();
140 133
134
Nico 2016/04/08 19:47:44 (nit: needless new newline)
Elly Fong-Jones 2016/04/13 17:18:24 Done.
141 // Access to the process detail information. This data is only available 135 // Access to the process detail information. This data is only available
142 // after OnDetailsAvailable() has been called. 136 // after OnDetailsAvailable() has been called.
143 const std::vector<ProcessData>& processes() { return process_data_; } 137 const std::vector<ProcessData>& processes() { return process_data_; }
144 138
145 // Returns a pointer to the ProcessData structure for Chrome. 139 // Returns a pointer to the ProcessData structure for Chrome.
146 ProcessData* ChromeBrowser(); 140 ProcessData* ChromeBrowser();
147 141
148 #if defined(OS_CHROMEOS) 142 #if defined(OS_CHROMEOS)
149 const base::SwapInfo& swap_info() const { return swap_info_; } 143 const base::SwapInfo& swap_info() const { return swap_info_; }
150 #endif 144 #endif
151 145
152 private: 146 private:
153 // Collect child process information on the IO thread. This is needed because 147 // Collect child process information on the IO thread. This is needed because
154 // information about some child process types (i.e. plugins) can only be taken 148 // information about some child process types (i.e. plugins) can only be taken
155 // on that thread. The data will be used by about:memory. When finished, 149 // on that thread. The data will be used by about:memory. When finished,
156 // invokes back to the file thread to run the rest of the about:memory 150 // invokes back to the file thread to run the rest of the about:memory
157 // functionality. 151 // functionality.
158 void CollectChildInfoOnIOThread(CollectionMode mode); 152 void CollectChildInfoOnIOThread();
159 153
160 // Collect current process information from the OS and store it 154 // Collect current process information from the OS and store it
161 // for processing. If data has already been collected, clears old 155 // for processing. If data has already been collected, clears old
162 // data and re-collects the data. 156 // data and re-collects the data.
163 // Note - this function enumerates memory details from many processes 157 // Note - this function enumerates memory details from many processes
164 // and is fairly expensive to run, hence it's run on the blocking pool. 158 // and is fairly expensive to run, hence it's run on the blocking pool.
165 // The parameter holds information about processes from the IO thread. 159 // The parameter holds information about processes from the IO thread.
166 void CollectProcessData( 160 void CollectProcessData(
167 CollectionMode mode,
168 const std::vector<ProcessMemoryInformation>& child_info); 161 const std::vector<ProcessMemoryInformation>& child_info);
169 162
170 // Collect child process information on the UI thread. Information about 163 // Collect child process information on the UI thread. Information about
171 // renderer processes is only available there. 164 // renderer processes is only available there.
172 void CollectChildInfoOnUIThread(); 165 void CollectChildInfoOnUIThread();
173 166
174 std::vector<ProcessData> process_data_; 167 std::vector<ProcessData> process_data_;
175 168
176 #if defined(OS_CHROMEOS) 169 #if defined(OS_CHROMEOS)
177 base::SwapInfo swap_info_; 170 base::SwapInfo swap_info_;
178 #endif 171 #endif
179 172
180 DISALLOW_COPY_AND_ASSIGN(MemoryDetails); 173 DISALLOW_COPY_AND_ASSIGN(MemoryDetails);
181 }; 174 };
182 175
183 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_ 176 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698