Chromium Code Reviews| Index: webrtc/test/field_trial.cc |
| diff --git a/webrtc/test/field_trial.cc b/webrtc/test/field_trial.cc |
| index 1f56ad32d73889edaadfe20c83a6374d59886d49..92aa6b08150a4ac672f4713fddd776df90beb004 100644 |
| --- a/webrtc/test/field_trial.cc |
| +++ b/webrtc/test/field_trial.cc |
| @@ -45,12 +45,12 @@ namespace test { |
| void InitFieldTrialsFromString(const std::string& trials_string) { |
| static const char kPersistentStringSeparator = '/'; |
| + // Catch an error if this is called more than once. |
| + assert(field_trials_initiated_ == false); |
| field_trials_initiated_ = true; |
| - if (trials_string.empty()) { |
| - field_trials_.clear(); |
| + if (trials_string == "") |
|
tommi
2015/07/08 09:01:35
nit: empty() is better than comparison
pbos-webrtc
2015/07/08 12:10:36
I think == "" reads better. It's also under test c
tommi
2015/07/08 12:21:12
Here are some reasons for why I don't agree:
* It'
pbos-webrtc
2015/07/08 12:44:18
So my argument is readability (which is personal).
tommi
2015/07/08 13:36:59
std::string is a container. http://stackoverflow.c
pbos-webrtc
2015/07/08 15:49:46
I like those compilers.
No I'm not saying that I'
|
| return; |
| - } |
| size_t next_item = 0; |
| while (next_item < trials_string.length()) { |
| @@ -83,5 +83,18 @@ void InitFieldTrialsFromString(const std::string& trials_string) { |
| // Using abort so it crashs both in debug and release mode. |
| abort(); |
| } |
| + |
| +ScopedFieldTrials::ScopedFieldTrials(const std::string& config) |
| + : previous_field_trials_(field_trials_) { |
| + assert(field_trials_initiated_); |
| + field_trials_initiated_ = false; |
| + field_trials_ = std::map<std::string, std::string>(); |
|
tommi
2015/07/08 09:01:35
why not clear()?
pbos-webrtc
2015/07/08 12:10:36
Brain fart, ptal: https://codereview.webrtc.org/12
|
| + InitFieldTrialsFromString(config); |
| +} |
| + |
| +ScopedFieldTrials::~ScopedFieldTrials() { |
| + field_trials_ = previous_field_trials_; |
|
tommi
2015/07/08 09:01:35
also restore field_trials_initiated_ ?
pbos-webrtc
2015/07/08 12:10:36
Not necessary (InitFieldTrialsFromString called fr
tommi
2015/07/08 12:21:12
I would still want the preconditions to mast the p
pbos-webrtc
2015/07/08 12:44:17
It works. field_trials_initiated_ doesn't need to
tommi
2015/07/08 13:36:59
Ah, I see.
|
| +} |
| + |
| } // namespace test |
| } // namespace webrtc |