| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_METRICS_FIELD_TRIAL_SYNCHRONIZER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_FIELD_TRIAL_SYNCHRONIZER_H_ |
| 6 #define CHROME_BROWSER_METRICS_FIELD_TRIAL_SYNCHRONIZER_H_ | 6 #define CHROME_BROWSER_METRICS_FIELD_TRIAL_SYNCHRONIZER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Construction also sets up the global singleton instance. This instance is | 30 // Construction also sets up the global singleton instance. This instance is |
| 31 // used to communicate between the UI and other threads, and is destroyed only | 31 // used to communicate between the UI and other threads, and is destroyed only |
| 32 // as the main thread (browser_main) terminates, which means all other threads | 32 // as the main thread (browser_main) terminates, which means all other threads |
| 33 // have completed, and will not need this instance any further. It adds itself | 33 // have completed, and will not need this instance any further. It adds itself |
| 34 // as an observer of FieldTrialList so that it gets notified whenever a group | 34 // as an observer of FieldTrialList so that it gets notified whenever a group |
| 35 // is finalized in the browser process. | 35 // is finalized in the browser process. |
| 36 FieldTrialSynchronizer(); | 36 FieldTrialSynchronizer(); |
| 37 | 37 |
| 38 virtual ~FieldTrialSynchronizer(); | 38 virtual ~FieldTrialSynchronizer(); |
| 39 | 39 |
| 40 // Initialize the synchronizer, which sets up the child process logging. |
| 41 void Init(); |
| 42 |
| 40 // Notify all renderer processes about the |group_name| that is finalized for | 43 // Notify all renderer processes about the |group_name| that is finalized for |
| 41 // the given field trail (|field_trial_name|). This is called on UI thread. | 44 // the given field trail (|field_trial_name|). This is called on UI thread. |
| 42 void NotifyAllRenderers(const std::string& field_trial_name, | 45 void NotifyAllRenderers(const std::string& field_trial_name, |
| 43 const std::string& group_name); | 46 const std::string& group_name); |
| 44 | 47 |
| 45 // FieldTrialList::Observer methods: | 48 // FieldTrialList::Observer methods: |
| 46 | 49 |
| 47 // This method is called by the FieldTrialList singleton when a trial's group | 50 // This method is called by the FieldTrialList singleton when a trial's group |
| 48 // is finalized. This method contacts all renderers (by calling | 51 // is finalized. This method contacts all renderers (by calling |
| 49 // NotifyAllRenderers) to create a FieldTrial that carries the randomly | 52 // NotifyAllRenderers) to create a FieldTrial that carries the randomly |
| 50 // selected state from the browser process into all the renderer processes. | 53 // selected state from the browser process into all the renderer processes. |
| 51 virtual void OnFieldTrialGroupFinalized( | 54 virtual void OnFieldTrialGroupFinalized( |
| 52 const std::string& name, | 55 const std::string& name, |
| 53 const std::string& group_name) OVERRIDE; | 56 const std::string& group_name) OVERRIDE; |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 // This singleton instance should be constructed during the single threaded | 59 // This singleton instance should be constructed during the single threaded |
| 57 // portion of main(). It initializes globals to provide support for all future | 60 // portion of main(). It initializes globals to provide support for all future |
| 58 // calls. This object is created on the UI thread, and it is destroyed after | 61 // calls. This object is created on the UI thread, and it is destroyed after |
| 59 // all the other threads have gone away. | 62 // all the other threads have gone away. |
| 60 static FieldTrialSynchronizer* field_trial_synchronizer_; | 63 static FieldTrialSynchronizer* field_trial_synchronizer_; |
| 61 | 64 |
| 62 DISALLOW_COPY_AND_ASSIGN(FieldTrialSynchronizer); | 65 DISALLOW_COPY_AND_ASSIGN(FieldTrialSynchronizer); |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 #endif // CHROME_BROWSER_METRICS_FIELD_TRIAL_SYNCHRONIZER_H_ | 68 #endif // CHROME_BROWSER_METRICS_FIELD_TRIAL_SYNCHRONIZER_H_ |
| OLD | NEW |