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

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

Issue 10151005: cros: Log per-process memory use on low memory events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | 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_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 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 // Access to the process detail information. This data is only available 113 // Access to the process detail information. This data is only available
114 // after OnDetailsAvailable() has been called. 114 // after OnDetailsAvailable() has been called.
115 const std::vector<ProcessData>& processes() { return process_data_; } 115 const std::vector<ProcessData>& processes() { return process_data_; }
116 116
117 // Initiate updating the current memory details. These are fetched 117 // Initiate updating the current memory details. These are fetched
118 // asynchronously because data must be collected from multiple threads. 118 // asynchronously because data must be collected from multiple threads.
119 // OnDetailsAvailable will be called when this process is complete. 119 // OnDetailsAvailable will be called when this process is complete.
120 void StartFetch(); 120 void StartFetch();
121 121
122 virtual void OnDetailsAvailable() {} 122 virtual void OnDetailsAvailable() = 0;
123
124 // Returns a string summarizing memory usage of the Chrome browser process
125 // and all sub-processes, suitable for logging.
126 std::string ToLogString();
123 127
124 protected: 128 protected:
125 friend class base::RefCountedThreadSafe<MemoryDetails>; 129 friend class base::RefCountedThreadSafe<MemoryDetails>;
126 130
127 virtual ~MemoryDetails(); 131 virtual ~MemoryDetails();
128 132
133 // Updates the global histograms for tracking memory usage.
134 void UpdateHistograms();
135
129 private: 136 private:
130 // Collect child process information on the IO thread. This is needed because 137 // Collect child process information on the IO thread. This is needed because
131 // information about some child process types (i.e. plugins) can only be taken 138 // information about some child process types (i.e. plugins) can only be taken
132 // on that thread. The data will be used by about:memory. When finished, 139 // on that thread. The data will be used by about:memory. When finished,
133 // invokes back to the file thread to run the rest of the about:memory 140 // invokes back to the file thread to run the rest of the about:memory
134 // functionality. 141 // functionality.
135 void CollectChildInfoOnIOThread(); 142 void CollectChildInfoOnIOThread();
136 143
137 // Collect current process information from the OS and store it 144 // Collect current process information from the OS and store it
138 // for processing. If data has already been collected, clears old 145 // for processing. If data has already been collected, clears old
(...skipping 10 matching lines...) Expand all
149 void CollectProcessDataChrome( 156 void CollectProcessDataChrome(
150 const std::vector<ProcessMemoryInformation>& child_info, 157 const std::vector<ProcessMemoryInformation>& child_info,
151 base::ProcessId pid, 158 base::ProcessId pid,
152 const ProcessInfoSnapshot& process_info); 159 const ProcessInfoSnapshot& process_info);
153 #endif 160 #endif
154 161
155 // Collect child process information on the UI thread. Information about 162 // Collect child process information on the UI thread. Information about
156 // renderer processes is only available there. 163 // renderer processes is only available there.
157 void CollectChildInfoOnUIThread(); 164 void CollectChildInfoOnUIThread();
158 165
159 // Each time we take a memory sample, we do a little work to update
160 // the global histograms for tracking memory usage.
161 void UpdateHistograms();
162
163 // Returns a pointer to the ProcessData structure for Chrome. 166 // Returns a pointer to the ProcessData structure for Chrome.
164 ProcessData* ChromeBrowser(); 167 ProcessData* ChromeBrowser();
165 168
166 std::vector<ProcessData> process_data_; 169 std::vector<ProcessData> process_data_;
167 170
168 DISALLOW_COPY_AND_ASSIGN(MemoryDetails); 171 DISALLOW_COPY_AND_ASSIGN(MemoryDetails);
169 }; 172 };
170 173
171 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_ 174 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698