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

Unified Diff: base/metrics/field_trial.h

Issue 2365273004: Initial implementation for sharing field trial state (win) (Closed)
Patch Set: rebase + gclient sync 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') | 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 2b8894904dd350e94899581bd858506300e83cd7..99e705a1fa82dd80a34701cbad08e857c589d9f7 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -64,9 +64,11 @@
#include <vector>
#include "base/base_export.h"
+#include "base/command_line.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/shared_memory.h"
#include "base/observer_list_threadsafe.h"
#include "base/strings/string_piece.h"
#include "base/synchronization/lock.h"
@@ -464,6 +466,28 @@ class BASE_EXPORT FieldTrialList {
const std::string& trials_string,
const std::set<std::string>& ignored_trial_names);
+ // Achieves the same thing as CreateTrialsFromString, except wraps the logic
+ // by taking in the trials from the command line, either via shared memory
+ // handle or command line argument.
+ // If using shared memory to pass around the list of field trials, then
+ // expects |field_trial_handle_switch| command line argument to
+ // contain the shared memory handle.
+ // If not, then create the trials as before (using the kForceFieldTrials
+ // switch). Needs the |field_trial_handle_switch| argument to be passed in
+ // since base/ can't depend on content/.
+ static void CreateTrialsFromCommandLine(
+ const base::CommandLine& cmd_line,
+ const char* field_trial_handle_switch);
+
+ // 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);
+
// Create a FieldTrial with the given |name| and using 100% probability for
// the FieldTrial, force FieldTrial to have the same group string as
// |group_name|. This is commonly used in a non-browser process, to carry
« 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