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

Unified Diff: base/debug/activity_tracker.h

Issue 2687973004: Add convenience methods so callers don't have to check if enabled. (Closed)
Patch Set: rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/activity_tracker.h
diff --git a/base/debug/activity_tracker.h b/base/debug/activity_tracker.h
index 9ffcfaa844ba22ee9edee16dcade2481f5a4f011..fcd3175135f6e0a79b2a8861e41c2e96300b3d22 100644
--- a/base/debug/activity_tracker.h
+++ b/base/debug/activity_tracker.h
@@ -751,6 +751,9 @@ class BASE_EXPORT GlobalActivityTracker {
subtle::Acquire_Load(&g_tracker_));
}
+ // Convenience method for determining if a global tracker is active.
+ static bool IsEnabled() { return Get() != nullptr; }
+
// Gets the persistent-memory-allocator in which data is stored. Callers
// can store additional records here to pass more information to the
// analysis process.
@@ -783,15 +786,31 @@ class BASE_EXPORT GlobalActivityTracker {
// Records a log message. The current implementation does NOT recycle these
// only store critical messages such as FATAL ones.
void RecordLogMessage(StringPiece message);
+ static void RecordLogMessageIfEnabled(StringPiece message) {
+ GlobalActivityTracker* tracker = Get();
+ if (tracker)
+ tracker->RecordLogMessage(message);
+ }
// Records a module load/unload event. This is safe to call multiple times
// even with the same information.
void RecordModuleInfo(const ModuleInfo& info);
+ static void RecordModuleInfoIfEnabled(const ModuleInfo& info) {
+ GlobalActivityTracker* tracker = Get();
+ if (tracker)
+ tracker->RecordModuleInfo(info);
+ }
// Record field trial information. This call is thread-safe. In addition to
// this, construction of a GlobalActivityTracker will cause all existing
// active field trials to be fetched and recorded.
void RecordFieldTrial(const std::string& trial_name, StringPiece group_name);
+ static void RecordFieldTrialIfEnabled(const std::string& trial_name,
+ StringPiece group_name) {
+ GlobalActivityTracker* tracker = Get();
+ if (tracker)
+ tracker->RecordFieldTrial(trial_name, group_name);
+ }
// Accesses the global data record for storing arbitrary key/value pairs.
ActivityUserData& global_data() { return global_data_; }
« 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