Chromium Code Reviews| Index: base/metrics/field_trial.h |
| diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h |
| index fa283271beb05da1a1f60d74eb5e5370c0155487..af5f68958a82b5222a16ac0acbc0159c4185853f 100644 |
| --- a/base/metrics/field_trial.h |
| +++ b/base/metrics/field_trial.h |
| @@ -511,6 +511,11 @@ class BASE_EXPORT FieldTrialList { |
| // list of handles to be inherited. |
| static void AppendFieldTrialHandleIfNeeded( |
| base::HandlesToInheritVector* handles); |
| +#elif defined(OS_POSIX) |
| + // On POSIX, we also need to explicitly pass down any fds to be inherited via |
| + // |files_to_register| in child_process_launcher.cc. This gets the handle so |
| + // we can add it to the mapping there. |
|
Alexei Svitkine (slow)
2016/11/23 17:49:55
You check the return value of this for -1 but don'
lawrencewu
2016/11/23 18:59:44
Done.
|
| + static int FieldTrialHandle(); |
|
Alexei Svitkine (slow)
2016/11/23 17:49:55
Functions should use a verb. GetFieldTrialHandle()
lawrencewu
2016/11/23 18:59:44
Done.
|
| #endif |
| // Adds a switch to the command line containing the field trial state as a |
| @@ -554,12 +559,22 @@ class BASE_EXPORT FieldTrialList { |
| 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 |
| + // Takes in |cli_switch| that should have been retrieved from the command line |
| + // and constructs a SharedMemoryHandle from it, and then calls |
| // CreateTrialsFromSharedMemory(). Returns true on success, false on failure. |
| - static bool CreateTrialsFromWindowsHandle(HANDLE handle); |
| + static bool CreateTrialsFromWindowsSwitch(std::string cli_switch); |
|
Alexei Svitkine (slow)
2016/11/23 17:49:55
Don't pass strings by value.
const std::string&
lawrencewu
2016/11/23 18:59:44
Done.
|
| +#elif defined(OS_POSIX) |
| + // Takes in |cli_switch| that should have been retrieved from the command |
| + // line, looks up the fd using GlobalDescriptor, constructs a |
| + // SharedMemoryHandle from it, and then calls CreateTrialsFromSharedMemory(). |
| + // Returns true on success, false on failure. |
| + static bool CreateTrialsFromPosixSwitch(std::string cli_switch); |
|
Alexei Svitkine (slow)
2016/11/23 17:49:55
Do we need two separate functions? Why not keeping
lawrencewu
2016/11/23 18:59:44
Yeah, that works better. Done.
|
| #endif |
| + // Takes an unmapped SharedMemoryHandle, creates a SharedMemory object from it |
| + // and maps it with the correct size. |
| + static bool CreateTrialsFromSharedMemoryHandle(SharedMemoryHandle shm_handle); |
| + |
| // 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 |
| @@ -628,6 +643,8 @@ class BASE_EXPORT FieldTrialList { |
| // because it's needed from both CopyFieldTrialStateToFlags() and |
| // AppendFieldTrialHandleIfNeeded(). |
| HANDLE readonly_allocator_handle_ = nullptr; |
| +#elif defined(OS_POSIX) |
| + int readonly_allocator_handle_ = -1; |
| #endif |
| // Tracks whether CreateTrialsFromCommandLine() has been called. |