Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/metrics/field_trial.h" | 5 #include "base/metrics/field_trial.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 if (trials_string.empty() || !global_) | 407 if (trials_string.empty() || !global_) |
| 408 return true; | 408 return true; |
| 409 | 409 |
| 410 size_t next_item = 0; | 410 size_t next_item = 0; |
| 411 while (next_item < trials_string.length()) { | 411 while (next_item < trials_string.length()) { |
| 412 size_t name_end = trials_string.find(kPersistentStringSeparator, next_item); | 412 size_t name_end = trials_string.find(kPersistentStringSeparator, next_item); |
| 413 if (name_end == trials_string.npos || next_item == name_end) | 413 if (name_end == trials_string.npos || next_item == name_end) |
| 414 return false; | 414 return false; |
| 415 size_t group_name_end = trials_string.find(kPersistentStringSeparator, | 415 size_t group_name_end = trials_string.find(kPersistentStringSeparator, |
| 416 name_end + 1); | 416 name_end + 1); |
| 417 if (group_name_end == trials_string.npos || name_end + 1 == group_name_end) | 417 if (name_end + 1 == group_name_end) |
| 418 return false; | 418 return false; |
| 419 if (group_name_end == trials_string.npos) | |
| 420 group_name_end = trials_string.length(); | |
| 419 std::string name(trials_string, next_item, name_end - next_item); | 421 std::string name(trials_string, next_item, name_end - next_item); |
| 420 std::string group_name(trials_string, name_end + 1, | 422 std::string group_name(trials_string, name_end + 1, |
| 421 group_name_end - name_end - 1); | 423 group_name_end - name_end - 1); |
| 422 next_item = group_name_end + 1; | 424 next_item = group_name_end + 1; |
| 423 | |
|
Alexei Svitkine (slow)
2014/08/08 18:28:48
Nit: Restore the existing whitespace as it was bef
gayane -on leave until 09-2017
2014/08/08 18:50:16
Done.
| |
| 424 if (ignored_trial_names.find(name) != ignored_trial_names.end()) | 425 if (ignored_trial_names.find(name) != ignored_trial_names.end()) |
| 425 continue; | 426 continue; |
| 426 | |
| 427 FieldTrial* trial = CreateFieldTrial(name, group_name); | 427 FieldTrial* trial = CreateFieldTrial(name, group_name); |
| 428 if (!trial) | 428 if (!trial) |
| 429 return false; | 429 return false; |
| 430 if (mode == ACTIVATE_TRIALS) { | 430 if (mode == ACTIVATE_TRIALS) { |
| 431 // Call |group()| to mark the trial as "used" and notify observers, if | 431 // Call |group()| to mark the trial as "used" and notify observers, if |
| 432 // any. This is useful to ensure that field trials created in child | 432 // any. This is useful to ensure that field trials created in child |
| 433 // processes are properly reported in crash reports. | 433 // processes are properly reported in crash reports. |
| 434 trial->group(); | 434 trial->group(); |
| 435 } | 435 } |
| 436 } | 436 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 return; | 531 return; |
| 532 } | 532 } |
| 533 AutoLock auto_lock(global_->lock_); | 533 AutoLock auto_lock(global_->lock_); |
| 534 DCHECK(!global_->PreLockedFind(trial->trial_name())); | 534 DCHECK(!global_->PreLockedFind(trial->trial_name())); |
| 535 trial->AddRef(); | 535 trial->AddRef(); |
| 536 trial->SetTrialRegistered(); | 536 trial->SetTrialRegistered(); |
| 537 global_->registered_[trial->trial_name()] = trial; | 537 global_->registered_[trial->trial_name()] = trial; |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace base | 540 } // namespace base |
| OLD | NEW |