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

Unified Diff: base/metrics/field_trial.h

Issue 2501283002: Refactor field_trial.cc (Closed)
Patch Set: git rebase-update Created 4 years, 1 month 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 | base/metrics/field_trial.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.h
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
index 7fd067ad74c5841857b600fb37bdcbcc4964980a..306f0075c6657d04c6e23f95a41e8dce455e37a3 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -219,6 +219,8 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, FloatBoundariesGiveEqualGroupSizes);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, DoesNotSurpassTotalProbability);
+ typedef SharedPersistentMemoryAllocator::Reference FieldTrialRef;
+
friend class base::FieldTrialList;
friend class RefCounted<FieldTrial>;
@@ -322,7 +324,7 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
bool trial_registered_;
// Reference to related field trial struct and data in shared memory.
- SharedPersistentMemoryAllocator::Reference ref_;
+ FieldTrialRef ref_;
// When benchmarking is enabled, field trials all revert to the 'default'
// group.
@@ -337,6 +339,8 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
// Only one instance of this class exists.
class BASE_EXPORT FieldTrialList {
public:
+ typedef SharedPersistentMemoryAllocator FieldTrialAllocator;
+
// Year that is guaranteed to not be expired when instantiating a field trial
// via |FactoryGetFieldTrial()|. Set to two years from the build date.
static int kNoExpirationYear;
@@ -540,6 +544,13 @@ class BASE_EXPORT FieldTrialList {
FRIEND_TEST_ALL_PREFIXES(FieldTrialListTest, InstantiateAllocator);
FRIEND_TEST_ALL_PREFIXES(FieldTrialListTest, AddTrialsToAllocator);
+#if defined(OS_WIN)
+ // Takes in |handle| that should have been retrieved from the command line and
+ // creates a SharedMemoryHandle from it, and then calls
+ // CreateTrialsFromSharedMemory(). Returns true on success, false on failure.
+ static bool CreateTrialsFromWindowsHandle(HANDLE handle);
+#endif
+
// Expects a mapped piece of shared memory |shm| that was created from the
// browser process's field_trial_allocator and shared via the command line.
// This function recreates the allocator, iterates through all the field
@@ -601,8 +612,7 @@ class BASE_EXPORT FieldTrialList {
// browser and child processes, but readonly in the child.
// In the future, we may want to move this to a more generic place if we want
// to start passing more data other than field trials.
- std::unique_ptr<SharedPersistentMemoryAllocator> field_trial_allocator_ =
- nullptr;
+ std::unique_ptr<FieldTrialAllocator> field_trial_allocator_ = nullptr;
#if defined(OS_WIN)
// Readonly copy of the handle to the allocator. Needs to be a member variable
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698