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

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

Issue 2544853003: Store log messages in global activity tracker. (Closed)
Patch Set: added comment about NUL terminator Created 4 years 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 | « base/debug/activity_analyzer_unittest.cc ('k') | base/debug/activity_tracker.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 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Type identifiers used when storing in persistent memory so they can be 535 // Type identifiers used when storing in persistent memory so they can be
536 // identified during extraction; the first 4 bytes of the SHA1 of the name 536 // identified during extraction; the first 4 bytes of the SHA1 of the name
537 // is used as a unique integer. A "version number" is added to the base 537 // is used as a unique integer. A "version number" is added to the base
538 // so that, if the structure of that object changes, stored older versions 538 // so that, if the structure of that object changes, stored older versions
539 // will be safely ignored. These are public so that an external process 539 // will be safely ignored. These are public so that an external process
540 // can recognize records of this type within an allocator. 540 // can recognize records of this type within an allocator.
541 enum : uint32_t { 541 enum : uint32_t {
542 kTypeIdActivityTracker = 0x5D7381AF + 3, // SHA1(ActivityTracker) v3 542 kTypeIdActivityTracker = 0x5D7381AF + 3, // SHA1(ActivityTracker) v3
543 kTypeIdUserDataRecord = 0x615EDDD7 + 1, // SHA1(UserDataRecord) v1 543 kTypeIdUserDataRecord = 0x615EDDD7 + 1, // SHA1(UserDataRecord) v1
544 kTypeIdGlobalDataRecord = 0xAFE61ABE + 1, // SHA1(GlobalDataRecord) v1 544 kTypeIdGlobalDataRecord = 0xAFE61ABE + 1, // SHA1(GlobalDataRecord) v1
545 kTypeIdGlobalLogMessage = 0x4CF434F9 + 1, // SHA1(GlobalLogMessage) v1
545 546
546 kTypeIdActivityTrackerFree = ~kTypeIdActivityTracker, 547 kTypeIdActivityTrackerFree = ~kTypeIdActivityTracker,
547 kTypeIdUserDataRecordFree = ~kTypeIdUserDataRecord, 548 kTypeIdUserDataRecordFree = ~kTypeIdUserDataRecord,
548 }; 549 };
549 550
550 // This is a thin wrapper around the thread-tracker's ScopedActivity that 551 // This is a thin wrapper around the thread-tracker's ScopedActivity that
551 // accesses the global tracker to provide some of the information, notably 552 // accesses the global tracker to provide some of the information, notably
552 // which thread-tracker to use. It is safe to create even if activity 553 // which thread-tracker to use. It is safe to create even if activity
553 // tracking is not enabled. 554 // tracking is not enabled.
554 class BASE_EXPORT ScopedThreadActivity 555 class BASE_EXPORT ScopedThreadActivity
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 void ReleaseTrackerForCurrentThreadForTesting(); 647 void ReleaseTrackerForCurrentThreadForTesting();
647 648
648 // Gets a reference to memory for holding user-defined activity data. If 649 // Gets a reference to memory for holding user-defined activity data. If
649 // the reference is valid, it's memory will be returned. If not, then a 650 // the reference is valid, it's memory will be returned. If not, then a
650 // new reference will be created (and stored) and that memory returned. 651 // new reference will be created (and stored) and that memory returned.
651 void* GetUserDataMemory(PersistentMemoryAllocator::Reference* reference); 652 void* GetUserDataMemory(PersistentMemoryAllocator::Reference* reference);
652 653
653 // Releases memory for user-defined activity data. 654 // Releases memory for user-defined activity data.
654 void ReleaseUserDataMemory(PersistentMemoryAllocator::Reference* reference); 655 void ReleaseUserDataMemory(PersistentMemoryAllocator::Reference* reference);
655 656
657 // Records a log message. The current implementation does NOT recycle these
658 // only store critical messages such as FATAL ones.
manzagop (departed) 2016/12/02 20:08:09 nit for your next cl: can you mention this is best
659 void RecordLogMessage(StringPiece message);
660
656 // Accesses the global data record for storing arbitrary key/value pairs. 661 // Accesses the global data record for storing arbitrary key/value pairs.
657 ActivityUserData& user_data() { return user_data_; } 662 ActivityUserData& user_data() { return user_data_; }
658 663
659 private: 664 private:
660 friend class ActivityTrackerTest; 665 friend class ActivityTrackerTest;
661 666
662 enum : int { 667 enum : int {
663 // The maximum number of threads that can be tracked within a process. If 668 // The maximum number of threads that can be tracked within a process. If
664 // more than this number run concurrently, tracking of new ones may cease. 669 // more than this number run concurrently, tracking of new ones may cease.
665 kMaxThreadCount = 100, 670 kMaxThreadCount = 100,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 ScopedProcessWaitActivity(const void* program_counter, 863 ScopedProcessWaitActivity(const void* program_counter,
859 const base::Process* process); 864 const base::Process* process);
860 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); 865 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity);
861 }; 866 };
862 #endif 867 #endif
863 868
864 } // namespace debug 869 } // namespace debug
865 } // namespace base 870 } // namespace base
866 871
867 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ 872 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_
OLDNEW
« no previous file with comments | « base/debug/activity_analyzer_unittest.cc ('k') | base/debug/activity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698