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

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: rebase 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
« no previous file with comments | « chrome/browser/low_memory_observer.cc ('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) 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // } 100 // }
101 // 101 //
102 // // Your other class stuff here 102 // // Your other class stuff here
103 // 103 //
104 // virtual void OnDetailsAvailable() { 104 // virtual void OnDetailsAvailable() {
105 // // do work with memory info here 105 // // do work with memory info here
106 // } 106 // }
107 // } 107 // }
108 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> { 108 class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> {
109 public: 109 public:
110 enum UserMetricsMode {
111 UPDATE_USER_METRICS, // Update UMA memory histograms with results.
112 SKIP_USER_METRICS
113 };
114
110 // Constructor. 115 // Constructor.
111 MemoryDetails(); 116 MemoryDetails();
112 117
113 // Access to the process detail information. This data is only available 118 // Access to the process detail information. This data is only available
114 // after OnDetailsAvailable() has been called. 119 // after OnDetailsAvailable() has been called.
115 const std::vector<ProcessData>& processes() { return process_data_; } 120 const std::vector<ProcessData>& processes() { return process_data_; }
116 121
117 // Initiate updating the current memory details. These are fetched 122 // Initiate updating the current memory details. These are fetched
118 // asynchronously because data must be collected from multiple threads. 123 // asynchronously because data must be collected from multiple threads.
124 // Updates UMA memory histograms if |mode| is UPDATE_USER_METRICS.
119 // OnDetailsAvailable will be called when this process is complete. 125 // OnDetailsAvailable will be called when this process is complete.
120 void StartFetch(); 126 void StartFetch(UserMetricsMode user_metrics_mode);
121 127
122 virtual void OnDetailsAvailable() {} 128 virtual void OnDetailsAvailable() = 0;
129
130 // Returns a string summarizing memory usage of the Chrome browser process
131 // and all sub-processes, suitable for logging.
132 std::string ToLogString();
123 133
124 protected: 134 protected:
125 friend class base::RefCountedThreadSafe<MemoryDetails>; 135 friend class base::RefCountedThreadSafe<MemoryDetails>;
126 136
127 virtual ~MemoryDetails(); 137 virtual ~MemoryDetails();
128 138
129 private: 139 private:
130 // Collect child process information on the IO thread. This is needed because 140 // 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 141 // 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, 142 // on that thread. The data will be used by about:memory. When finished,
(...skipping 16 matching lines...) Expand all
149 void CollectProcessDataChrome( 159 void CollectProcessDataChrome(
150 const std::vector<ProcessMemoryInformation>& child_info, 160 const std::vector<ProcessMemoryInformation>& child_info,
151 base::ProcessId pid, 161 base::ProcessId pid,
152 const ProcessInfoSnapshot& process_info); 162 const ProcessInfoSnapshot& process_info);
153 #endif 163 #endif
154 164
155 // Collect child process information on the UI thread. Information about 165 // Collect child process information on the UI thread. Information about
156 // renderer processes is only available there. 166 // renderer processes is only available there.
157 void CollectChildInfoOnUIThread(); 167 void CollectChildInfoOnUIThread();
158 168
159 // Each time we take a memory sample, we do a little work to update 169 // Updates the global histograms for tracking memory usage.
160 // the global histograms for tracking memory usage.
161 void UpdateHistograms(); 170 void UpdateHistograms();
162 171
163 // Returns a pointer to the ProcessData structure for Chrome. 172 // Returns a pointer to the ProcessData structure for Chrome.
164 ProcessData* ChromeBrowser(); 173 ProcessData* ChromeBrowser();
165 174
166 std::vector<ProcessData> process_data_; 175 std::vector<ProcessData> process_data_;
167 176
177 UserMetricsMode user_metrics_mode_;
178
168 DISALLOW_COPY_AND_ASSIGN(MemoryDetails); 179 DISALLOW_COPY_AND_ASSIGN(MemoryDetails);
169 }; 180 };
170 181
171 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_ 182 #endif // CHROME_BROWSER_MEMORY_DETAILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/low_memory_observer.cc ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698