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

Side by Side Diff: base/debug/activity_tracker.h

Issue 2695813011: Updates for improved PMA 'object' interface. (Closed)
Patch Set: fixed Activity size Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // Activity tracking provides a low-overhead method of collecting information 5 // Activity tracking provides a low-overhead method of collecting information
6 // about the state of the application for analysis both while it is running 6 // about the state of the application for analysis both while it is running
7 // and after it has terminated unexpectedly. Its primary purpose is to help 7 // and after it has terminated unexpectedly. Its primary purpose is to help
8 // locate reasons the browser becomes unresponsive by providing insight into 8 // locate reasons the browser becomes unresponsive by providing insight into
9 // what all the various threads and processes are (or were) doing. 9 // what all the various threads and processes are (or were) doing.
10 10
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Gets a reference to an object of the configured type. This can return 155 // Gets a reference to an object of the configured type. This can return
156 // a null reference if it was not possible to allocate the memory. 156 // a null reference if it was not possible to allocate the memory.
157 Reference GetObjectReference(); 157 Reference GetObjectReference();
158 158
159 // Returns an object to the "free" pool. 159 // Returns an object to the "free" pool.
160 void ReleaseObjectReference(Reference ref); 160 void ReleaseObjectReference(Reference ref);
161 161
162 // Helper function to access an object allocated using this instance. 162 // Helper function to access an object allocated using this instance.
163 template <typename T> 163 template <typename T>
164 T* GetAsObject(Reference ref) { 164 T* GetAsObject(Reference ref) {
165 return allocator_->GetAsObject<T>(ref, object_type_); 165 return allocator_->GetAsObject<T>(ref);
166 } 166 }
167 167
168 // Similar to GetAsObject() but converts references to arrays of objects. 168 // Similar to GetAsObject() but converts references to arrays of objects.
169 template <typename T> 169 template <typename T>
170 T* GetAsArray(Reference ref, size_t count) { 170 T* GetAsArray(Reference ref, size_t count) {
171 return allocator_->GetAsArray<T>(ref, object_type_, count); 171 return allocator_->GetAsArray<T>(ref, object_type_, count);
172 } 172 }
173 173
174 // The current "used size" of the internal cache, visible for testing. 174 // The current "used size" of the internal cache, visible for testing.
175 size_t cache_used() const { return cache_used_; } 175 size_t cache_used() const { return cache_used_; }
(...skipping 15 matching lines...) Expand all
191 191
192 DISALLOW_COPY_AND_ASSIGN(ActivityTrackerMemoryAllocator); 192 DISALLOW_COPY_AND_ASSIGN(ActivityTrackerMemoryAllocator);
193 }; 193 };
194 194
195 195
196 // This structure is the full contents recorded for every activity pushed 196 // This structure is the full contents recorded for every activity pushed
197 // onto the stack. The |activity_type| indicates what is actually stored in 197 // onto the stack. The |activity_type| indicates what is actually stored in
198 // the |data| field. All fields must be explicitly sized types to ensure no 198 // the |data| field. All fields must be explicitly sized types to ensure no
199 // interoperability problems between 32-bit and 64-bit systems. 199 // interoperability problems between 32-bit and 64-bit systems.
200 struct Activity { 200 struct Activity {
201 // SHA1(base::debug::Activity): Increment this if structure changes!
202 static constexpr uint32_t kPersistentTypeId = 0x99425159 + 1;
203 // Expected size for 32/64-bit check. Update this if structure changes!
204 static constexpr size_t kExpectedInstanceSize =
205 48 + 8 * kActivityCallStackSize;
206
201 // The type of an activity on the stack. Activities are broken into 207 // The type of an activity on the stack. Activities are broken into
202 // categories with the category ID taking the top 4 bits and the lower 208 // categories with the category ID taking the top 4 bits and the lower
203 // bits representing an action within that category. This combination 209 // bits representing an action within that category. This combination
204 // makes it easy to "switch" based on the type during analysis. 210 // makes it easy to "switch" based on the type during analysis.
205 enum Type : uint8_t { 211 enum Type : uint8_t {
206 // This "null" constant is used to indicate "do not change" in calls. 212 // This "null" constant is used to indicate "do not change" in calls.
207 ACT_NULL = 0, 213 ACT_NULL = 0,
208 214
209 // Task activities involve callbacks posted to a thread or thread-pool 215 // Task activities involve callbacks posted to a thread or thread-pool
210 // using the PostTask() method or any of its friends. 216 // using the PostTask() method or any of its friends.
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 ScopedProcessWaitActivity(const void* program_counter, 1074 ScopedProcessWaitActivity(const void* program_counter,
1069 const base::Process* process); 1075 const base::Process* process);
1070 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); 1076 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity);
1071 }; 1077 };
1072 #endif 1078 #endif
1073 1079
1074 } // namespace debug 1080 } // namespace debug
1075 } // namespace base 1081 } // namespace base
1076 1082
1077 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ 1083 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698