OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_ | 5 #ifndef COMPONENTS_VARIATIONS_FIELD_TRIAL_SYNCER_H_ |
6 #define CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_ | 6 #define COMPONENTS_VARIATIONS_FIELD_TRIAL_SYNCER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class CommandLine; | 14 class CommandLine; |
15 } | 15 } |
16 | 16 |
17 namespace chrome_variations { | 17 namespace variations { |
18 | 18 |
19 // ChildProcessFieldTrialSyncer is a utility class that's responsible for | 19 // ChildProcessFieldTrialSyncer is a utility class that's responsible for |
20 // syncing the "activated" state of field trials between browser and child | 20 // syncing the "activated" state of field trials between browser and child |
21 // processes. Specifically, when a field trial is activated in the browser, it | 21 // processes. Specifically, when a field trial is activated in the browser, it |
22 // also activates it in the child process and when a field trial is activated | 22 // also activates it in the child process and when a field trial is activated |
23 // in the child process, it notifies the browser process to activate it. | 23 // in the child process, it notifies the browser process to activate it. |
24 class ChildProcessFieldTrialSyncer { | 24 class ChildProcessFieldTrialSyncer { |
25 public: | 25 public: |
26 // ChildProcessFieldTrialSyncer constructor taking an externally owned | 26 // ChildProcessFieldTrialSyncer constructor taking an externally owned |
27 // |observer| param that's responsible for sending IPCs to the browser process | 27 // |observer| param that's responsible for sending IPCs to the browser process |
28 // when a trial is activated. The |observer| must outlive this object. | 28 // when a trial is activated. The |observer| must outlive this object. |
29 explicit ChildProcessFieldTrialSyncer( | 29 explicit ChildProcessFieldTrialSyncer( |
30 base::FieldTrialList::Observer* observer); | 30 base::FieldTrialList::Observer* observer); |
31 ~ChildProcessFieldTrialSyncer(); | 31 ~ChildProcessFieldTrialSyncer(); |
32 | 32 |
33 // Initializes field trial state change observation and notifies the browser | 33 // Initializes field trial state change observation and notifies the browser |
34 // of any field trials that might have already been activated. | 34 // of any field trials that might have already been activated. Takes the |
35 void InitFieldTrialObserving(const base::CommandLine& command_line); | 35 // switch name for single process mode as a parameter, since that's not |
| 36 // visible to the component. |
| 37 void InitFieldTrialObserving(const base::CommandLine& command_line, |
| 38 const char* single_process_switch_name); |
36 | 39 |
37 // Handler for messages from the browser process notifying the child process | 40 // Handler for messages from the browser process notifying the child process |
38 // that a field trial was activated. | 41 // that a field trial was activated. |
39 void OnSetFieldTrialGroup(const std::string& trial_name, | 42 void OnSetFieldTrialGroup(const std::string& trial_name, |
40 const std::string& group_name); | 43 const std::string& group_name); |
41 | 44 |
42 private: | 45 private: |
43 base::FieldTrialList::Observer* const observer_; | 46 base::FieldTrialList::Observer* const observer_; |
44 | 47 |
45 DISALLOW_COPY_AND_ASSIGN(ChildProcessFieldTrialSyncer); | 48 DISALLOW_COPY_AND_ASSIGN(ChildProcessFieldTrialSyncer); |
46 }; | 49 }; |
47 | 50 |
48 } // namespace chrome_variations | 51 } // namespace variations |
49 | 52 |
50 #endif // CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_ | 53 #endif // COMPONENTS_VARIATIONS_FIELD_TRIAL_SYNCER_H_ |
OLD | NEW |