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

Side by Side Diff: chrome/common/variations/child_process_field_trial_syncer.h

Issue 2020413002: Refactor out a new class for syncing field trials in child processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak param names & comments. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(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 <memory>
Lei Zhang 2016/06/01 20:52:51 not needed
Alexei Svitkine (slow) 2016/06/01 21:00:39 Done.
9 #include <string>
10
11 #include "base/compiler_specific.h"
Lei Zhang 2016/06/01 20:52:51 probably not needed
Alexei Svitkine (slow) 2016/06/01 21:00:39 Done.
12 #include "base/macros.h"
13 #include "base/metrics/field_trial.h"
14 #include "ipc/ipc_sender.h"
15
16 namespace base {
17 class CommandLine;
18 }
19
20 namespace chrome_variations {
21
22 // ChildProcessFieldTrialSyncer is a utility class that's responsible for
23 // syncing the "activated" state of field trials between browser and child
24 // processes. Specifically, when a field trial is activated in the browser, it
25 // also activates it in the child process and when a field trial is activated
26 // in the child process, it notifies the browser process to activate it.
27 class ChildProcessFieldTrialSyncer : public base::FieldTrialList::Observer {
28 public:
29 // ChildProcessFieldTrialSyncer constructor taking an externally owned
30 // |ipc_sender| param for sending ChromeViewHostMsg_FieldTrialActivated IPCs
31 // to the browser process. The |ipc_sender| must outlive this object.
32 explicit ChildProcessFieldTrialSyncer(IPC::Sender* ipc_sender);
33 ~ChildProcessFieldTrialSyncer() override;
34
35 // Initializes field trial state change observation and notifies the browser
36 // of any field trials that might have already been activated.
37 void InitFieldTrialObserving(const base::CommandLine& command_line);
38
39 // Handler for messages from the browser process notifying the child process
40 // that a field trial was activated.
41 void OnSetFieldTrialGroup(const std::string& trial_name,
42 const std::string& group_name);
43
44 private:
45 // base::FieldTrialList::Observer:
46 void OnFieldTrialGroupFinalized(const std::string& trial_name,
47 const std::string& group_name) override;
48
49 IPC::Sender* ipc_sender_;
Lei Zhang 2016/06/01 20:52:51 IPC::Sender* const ipc_sender_;
Alexei Svitkine (slow) 2016/06/01 21:00:39 Done.
50
51 DISALLOW_COPY_AND_ASSIGN(ChildProcessFieldTrialSyncer);
52 };
53
54 } // namespace chrome_variations
55
56 #endif // CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698