Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_ | |
| 6 #define CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/metrics/field_trial.h" | |
| 12 #include "ipc/ipc_sender.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class CommandLine; | |
| 16 } | |
| 17 | |
| 18 namespace chrome_variations { | |
| 19 | |
| 20 // ChildProcessFieldTrialSyncer is a utility class that's responsible for | |
| 21 // syncing the "activated" state of field trials between browser and child | |
| 22 // processes. Specifically, when a field trial is activated in the browser, it | |
| 23 // also activates it in the child process and when a field trial is activated | |
| 24 // in the child process, it notifies the browser process to activate it. | |
| 25 class ChildProcessFieldTrialSyncer : public base::FieldTrialList::Observer { | |
| 26 public: | |
| 27 // ChildProcessFieldTrialSyncer constructor taking an externally owned | |
| 28 // |ipc_sender| param for sending ChromeViewHostMsg_FieldTrialActivated IPCs | |
| 29 // to the browser process. The |ipc_sender| must outlive this object. | |
| 30 explicit ChildProcessFieldTrialSyncer(IPC::Sender* ipc_sender); | |
| 31 ~ChildProcessFieldTrialSyncer() override; | |
| 32 | |
| 33 // Initializes field trial state change observation and notifies the browser | |
| 34 // of any field trials that might have already been activated. | |
| 35 void InitFieldTrialObserving(const base::CommandLine& command_line); | |
| 36 | |
| 37 // Handler for messages from the browser process notifying the child process | |
| 38 // that a field trial was activated. | |
| 39 void OnSetFieldTrialGroup(const std::string& trial_name, | |
| 40 const std::string& group_name); | |
| 41 | |
| 42 private: | |
| 43 // base::FieldTrialList::Observer: | |
|
rkaplow
2016/06/01 21:08:38
?
Alexei Svitkine (slow)
2016/06/01 21:13:58
That's the comment syntax to indicate that the met
rkaplow
2016/06/01 21:16:06
Acknowledged.
| |
| 44 void OnFieldTrialGroupFinalized(const std::string& trial_name, | |
| 45 const std::string& group_name) override; | |
| 46 | |
| 47 IPC::Sender* const ipc_sender_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(ChildProcessFieldTrialSyncer); | |
| 50 }; | |
| 51 | |
| 52 } // namespace chrome_variations | |
| 53 | |
| 54 #endif // CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_ | |
| OLD | NEW |