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

Unified 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, 7 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
Index: chrome/common/variations/child_process_field_trial_syncer.h
diff --git a/chrome/common/variations/child_process_field_trial_syncer.h b/chrome/common/variations/child_process_field_trial_syncer.h
new file mode 100644
index 0000000000000000000000000000000000000000..1cce321542515f440f76662b48a3f88c77c90733
--- /dev/null
+++ b/chrome/common/variations/child_process_field_trial_syncer.h
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_
+#define CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_
+
+#include <memory>
Lei Zhang 2016/06/01 20:52:51 not needed
Alexei Svitkine (slow) 2016/06/01 21:00:39 Done.
+#include <string>
+
+#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.
+#include "base/macros.h"
+#include "base/metrics/field_trial.h"
+#include "ipc/ipc_sender.h"
+
+namespace base {
+class CommandLine;
+}
+
+namespace chrome_variations {
+
+// ChildProcessFieldTrialSyncer is a utility class that's responsible for
+// syncing the "activated" state of field trials between browser and child
+// processes. Specifically, when a field trial is activated in the browser, it
+// also activates it in the child process and when a field trial is activated
+// in the child process, it notifies the browser process to activate it.
+class ChildProcessFieldTrialSyncer : public base::FieldTrialList::Observer {
+ public:
+ // ChildProcessFieldTrialSyncer constructor taking an externally owned
+ // |ipc_sender| param for sending ChromeViewHostMsg_FieldTrialActivated IPCs
+ // to the browser process. The |ipc_sender| must outlive this object.
+ explicit ChildProcessFieldTrialSyncer(IPC::Sender* ipc_sender);
+ ~ChildProcessFieldTrialSyncer() override;
+
+ // Initializes field trial state change observation and notifies the browser
+ // of any field trials that might have already been activated.
+ void InitFieldTrialObserving(const base::CommandLine& command_line);
+
+ // Handler for messages from the browser process notifying the child process
+ // that a field trial was activated.
+ void OnSetFieldTrialGroup(const std::string& trial_name,
+ const std::string& group_name);
+
+ private:
+ // base::FieldTrialList::Observer:
+ void OnFieldTrialGroupFinalized(const std::string& trial_name,
+ const std::string& group_name) override;
+
+ 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.
+
+ DISALLOW_COPY_AND_ASSIGN(ChildProcessFieldTrialSyncer);
+};
+
+} // namespace chrome_variations
+
+#endif // CHROME_COMMON_VARIATIONS_CHILD_PROCESS_FIELD_TRIAL_SYNCER_H_

Powered by Google App Engine
This is Rietveld 408576698