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

Unified Diff: base/metrics/field_trial.h

Issue 2412113002: Use SharedPersistentMemoryAllocator to share field trial state (Closed)
Patch Set: address bcwhite comments Created 4 years, 2 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 | base/metrics/field_trial.cc » ('j') | base/metrics/field_trial.cc » ('J')
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 99e705a1fa82dd80a34701cbad08e857c589d9f7..bd9c2797f9ab8f21aaa736dfb0fca4d93a590545 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -69,7 +69,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/shared_memory.h"
+#include "base/metrics/persistent_memory_allocator.h"
#include "base/observer_list_threadsafe.h"
+#include "base/process/launch.h"
#include "base/strings/string_piece.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
@@ -479,14 +481,18 @@ class BASE_EXPORT FieldTrialList {
const base::CommandLine& cmd_line,
const char* field_trial_handle_switch);
+#if defined(OS_WIN)
+ static void AppendFieldTrialHandleIfNeeded(
+ base::HandlesToInheritVector& handles);
+#endif
+
// Adds a switch to the command line containing the field trial state as a
// string (if not using shared memory to share field trial state), or the
// shared memory handle + length.
// Needs the |field_trial_handle_switch| argument to be passed in since base/
// can't depend on content/.
- static std::unique_ptr<base::SharedMemory> CopyFieldTrialStateToFlags(
- const char* field_trial_handle_switch,
- base::CommandLine* cmd_line);
+ static void CopyFieldTrialStateToFlags(const char* field_trial_handle_switch,
+ base::CommandLine* cmd_line);
// Create a FieldTrial with the given |name| and using 100% probability for
// the FieldTrial, force FieldTrial to have the same group string as
@@ -508,10 +514,24 @@ class BASE_EXPORT FieldTrialList {
// Notify all observers that a group has been finalized for |field_trial|.
static void NotifyFieldTrialGroupSelection(FieldTrial* field_trial);
+ // Called in NotifyFieldTrialGroupSelection(). Updates field_trial_allocator
+ // by adding the newly-created |field_trial|.
+ static void UpdateFieldTrialAllocator(FieldTrial* field_trial);
+
// Return the number of active field trials.
static size_t GetFieldTrialCount();
private:
+ // 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
+ // trials in it, and creates them via CreateFieldTrial().
+ static void CreateTrialsFromSharedMemory(
+ std::unique_ptr<base::SharedMemory> shm);
+
+ // Allocator used to instantiate field trial in child processes.
+ static base::SharedPersistentMemoryAllocator* field_trial_allocator;
+
// A map from FieldTrial names to the actual instances.
typedef std::map<std::string, FieldTrial*> RegistrationMap;
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | base/metrics/field_trial.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698