Index: base/metrics/field_trial.h |
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h |
index 99e705a1fa82dd80a34701cbad08e857c589d9f7..8732374a38f4eaa8e407e95c6569e20157f2a86f 100644 |
--- a/base/metrics/field_trial.h |
+++ b/base/metrics/field_trial.h |
@@ -69,6 +69,7 @@ |
#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/strings/string_piece.h" |
#include "base/synchronization/lock.h" |
@@ -324,6 +325,9 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { |
// Only one instance of this class exists. |
class BASE_EXPORT FieldTrialList { |
public: |
+ // Allocator used instantiate field trial in child processes. |
+ static base::SharedPersistentMemoryAllocator* field_trial_allocator; |
bcwhite
2016/10/13 14:28:02
I don't suppose there is a more generic place to h
lawrencewu
2016/10/14 04:54:10
While that would be nice, I'm reluctant to do that
bcwhite
2016/10/14 13:56:56
That's fine. Add a comment saying that such _coul
lawrencewu
2016/10/19 16:21:28
Done.
|
+ |
// 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; |
@@ -479,14 +483,20 @@ class BASE_EXPORT FieldTrialList { |
const base::CommandLine& cmd_line, |
const char* field_trial_handle_switch); |
+ // 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); |
Alexei Svitkine (slow)
2016/10/12 20:41:00
If you're only calling this from the .cc file, it
lawrencewu
2016/10/14 04:54:09
It needs to reference regstration_ when creating t
|
+ |
// 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,6 +518,10 @@ 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(). Adds a new entry to |
+ // field_trial_allocator containing the newly-selected field trial and group. |
+ static void UpdateFieldTrialAllocator(FieldTrial* field_trial); |
bcwhite
2016/10/13 14:28:02
Your comment says "adds" but the name says "update
lawrencewu
2016/10/14 04:54:09
It is kind of an "update the list of field trials
|
+ |
// Return the number of active field trials. |
static size_t GetFieldTrialCount(); |