Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 125 } |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 // A "null" activity-data that can be passed to indicate "do not change". | 128 // A "null" activity-data that can be passed to indicate "do not change". |
| 129 extern const ActivityData kNullActivityData; | 129 extern const ActivityData kNullActivityData; |
| 130 | 130 |
| 131 | 131 |
| 132 // A helper class that is used for managing memory allocations within a | 132 // A helper class that is used for managing memory allocations within a |
| 133 // persistent memory allocator. Instances of this class are NOT thread-safe. | 133 // persistent memory allocator. Instances of this class are NOT thread-safe. |
| 134 // Use from a single thread or protect access with a lock. | 134 // Use from a single thread or protect access with a lock. |
| 135 class ActivityTrackerMemoryAllocator { | 135 class BASE_EXPORT ActivityTrackerMemoryAllocator { |
| 136 public: | 136 public: |
| 137 using Reference = PersistentMemoryAllocator::Reference; | 137 using Reference = PersistentMemoryAllocator::Reference; |
| 138 | 138 |
| 139 // Creates a instance for allocating objects of a fixed |object_type|, a | 139 // Creates a instance for allocating objects of a fixed |object_type|, a |
| 140 // corresponding |object_free| type, and the |object_size|. An internal | 140 // corresponding |object_free| type, and the |object_size|. An internal |
| 141 // cache of the last |cache_size| released references will be kept for | 141 // cache of the last |cache_size| released references will be kept for |
| 142 // quick future fetches. If |make_iterable| then allocated objects will | 142 // quick future fetches. If |make_iterable| then allocated objects will |
| 143 // be marked "iterable" in the allocator. | 143 // be marked "iterable" in the allocator. |
| 144 ActivityTrackerMemoryAllocator(PersistentMemoryAllocator* allocator, | 144 ActivityTrackerMemoryAllocator(PersistentMemoryAllocator* allocator, |
| 145 uint32_t object_type, | 145 uint32_t object_type, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 SIGNED_VALUE, | 300 SIGNED_VALUE, |
| 301 UNSIGNED_VALUE, | 301 UNSIGNED_VALUE, |
| 302 }; | 302 }; |
| 303 | 303 |
| 304 class BASE_EXPORT TypedValue { | 304 class BASE_EXPORT TypedValue { |
| 305 public: | 305 public: |
| 306 TypedValue(); | 306 TypedValue(); |
| 307 TypedValue(const TypedValue& other); | 307 TypedValue(const TypedValue& other); |
| 308 ~TypedValue(); | 308 ~TypedValue(); |
| 309 | 309 |
| 310 ValueType get_type() const { return type; } | |
|
bcwhite
2016/12/22 17:21:58
Just type().
Can't believe I forgot that one. :-O
manzagop (departed)
2017/01/10 14:11:22
Done. I switched to type() and renamed the variabl
| |
| 311 | |
| 310 // These methods return the extracted value in the correct format. | 312 // These methods return the extracted value in the correct format. |
| 311 StringPiece Get() const; | 313 StringPiece Get() const; |
| 312 StringPiece GetString() const; | 314 StringPiece GetString() const; |
| 313 bool GetBool() const; | 315 bool GetBool() const; |
| 314 char GetChar() const; | 316 char GetChar() const; |
| 315 int64_t GetInt() const; | 317 int64_t GetInt() const; |
| 316 uint64_t GetUint() const; | 318 uint64_t GetUint() const; |
| 317 | 319 |
| 318 // These methods return references to process memory as originally provided | 320 // These methods return references to process memory as originally provided |
| 319 // to corresponding Set calls. USE WITH CAUTION! There is no guarantee that | 321 // to corresponding Set calls. USE WITH CAUTION! There is no guarantee that |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 void ChangeTypeAndData(Activity::Type type, const ActivityData& data); | 532 void ChangeTypeAndData(Activity::Type type, const ActivityData& data); |
| 531 | 533 |
| 532 protected: | 534 protected: |
| 533 // The thread tracker to which this object reports. It can be null if | 535 // The thread tracker to which this object reports. It can be null if |
| 534 // activity tracking is not (yet) enabled. | 536 // activity tracking is not (yet) enabled. |
| 535 ThreadActivityTracker* const tracker_; | 537 ThreadActivityTracker* const tracker_; |
| 536 | 538 |
| 537 // An identifier that indicates a specific activity on the stack. | 539 // An identifier that indicates a specific activity on the stack. |
| 538 ActivityId activity_id_; | 540 ActivityId activity_id_; |
| 539 | 541 |
| 542 private: | |
| 540 DISALLOW_COPY_AND_ASSIGN(ScopedActivity); | 543 DISALLOW_COPY_AND_ASSIGN(ScopedActivity); |
| 541 }; | 544 }; |
| 542 | 545 |
| 543 // A ThreadActivityTracker runs on top of memory that is managed externally. | 546 // A ThreadActivityTracker runs on top of memory that is managed externally. |
| 544 // It must be large enough for the internal header and a few Activity | 547 // It must be large enough for the internal header and a few Activity |
| 545 // blocks. See SizeForStackDepth(). | 548 // blocks. See SizeForStackDepth(). |
| 546 ThreadActivityTracker(void* base, size_t size); | 549 ThreadActivityTracker(void* base, size_t size); |
| 547 virtual ~ThreadActivityTracker(); | 550 virtual ~ThreadActivityTracker(); |
| 548 | 551 |
| 549 // Indicates that an activity has started from a given |origin| address in | 552 // Indicates that an activity has started from a given |origin| address in |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 952 ScopedProcessWaitActivity(const void* program_counter, | 955 ScopedProcessWaitActivity(const void* program_counter, |
| 953 const base::Process* process); | 956 const base::Process* process); |
| 954 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); | 957 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); |
| 955 }; | 958 }; |
| 956 #endif | 959 #endif |
| 957 | 960 |
| 958 } // namespace debug | 961 } // namespace debug |
| 959 } // namespace base | 962 } // namespace base |
| 960 | 963 |
| 961 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ | 964 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ |
| OLD | NEW |