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

Unified Diff: base/debug/activity_tracker.h

Issue 2666653002: Record field-trial information in stability file for crash analysis. (Closed)
Patch Set: use c++ loop format 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 | « base/debug/activity_analyzer_unittest.cc ('k') | base/debug/activity_tracker.cc » ('j') | 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 348591957cbd9ed6b414cd91bf57e8453a22220f..53290e1b7070b7258a041fb672c3b912ea2eb32e 100644
--- a/base/debug/activity_tracker.h
+++ b/base/debug/activity_tracker.h
@@ -27,6 +27,7 @@
#include "base/gtest_prod_util.h"
#include "base/location.h"
#include "base/metrics/persistent_memory_allocator.h"
+#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_checker.h"
@@ -342,7 +343,7 @@ class BASE_EXPORT ActivityUserData {
using Snapshot = std::map<std::string, TypedValue>;
ActivityUserData(void* memory, size_t size);
- ~ActivityUserData();
+ virtual ~ActivityUserData();
// Gets the unique ID number for this user data. If this changes then the
// contents have been overwritten by another thread. The return value is
@@ -404,6 +405,12 @@ class BASE_EXPORT ActivityUserData {
// Gets the base memory address used for storing data.
const void* GetBaseAddress();
+ protected:
+ virtual void Set(StringPiece name,
+ ValueType type,
+ const void* memory,
+ size_t size);
+
private:
FRIEND_TEST_ALL_PREFIXES(ActivityTrackerTest, UserDataTest);
@@ -437,7 +444,6 @@ class BASE_EXPORT ActivityUserData {
size_t extent; // The total storage of the value,
}; // typically rounded up for alignment.
- void Set(StringPiece name, ValueType type, const void* memory, size_t size);
void SetReference(StringPiece name,
ValueType type,
const void* memory,
@@ -461,8 +467,6 @@ class BASE_EXPORT ActivityUserData {
// A pointer to the unique ID for this instance.
std::atomic<uint32_t>* const id_;
- base::ThreadChecker thread_checker_;
-
// This ID is used to create unique indentifiers for user data so that it's
// possible to tell if the information has been overwritten.
static StaticAtomicSequenceNumber next_id_;
@@ -784,8 +788,13 @@ class BASE_EXPORT GlobalActivityTracker {
// even with the same information.
void RecordModuleInfo(const ModuleInfo& 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);
+
// Accesses the global data record for storing arbitrary key/value pairs.
- ActivityUserData& user_data() { return user_data_; }
+ ActivityUserData& global_data() { return global_data_; }
private:
friend class GlobalActivityAnalyzer;
@@ -800,6 +809,25 @@ class BASE_EXPORT GlobalActivityTracker {
kCachedUserDataMemories = 10,
};
+ // A wrapper around ActivityUserData that is thread-safe and thus can be used
+ // in the global scope without the requirement of being called from only one
+ // thread.
+ class GlobalUserData : public ActivityUserData {
+ public:
+ GlobalUserData(void* memory, size_t size);
+ ~GlobalUserData() override;
+
+ private:
+ void Set(StringPiece name,
+ ValueType type,
+ const void* memory,
+ size_t size) override;
+
+ Lock data_lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(GlobalUserData);
+ };
+
// State of a module as stored in persistent memory. This supports a single
// loading of a module only. If modules are loaded multiple times at
// different addresses, only the last will be recorded and an unload will
@@ -904,7 +932,7 @@ class BASE_EXPORT GlobalActivityTracker {
// An object for holding global arbitrary key value pairs. Values must always
// be written from the main UI thread.
- ActivityUserData user_data_;
+ GlobalUserData global_data_;
// A map of global module information, keyed by module path.
std::map<const std::string, ModuleInfoRecord*> modules_;
« 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