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

Side by Side Diff: base/metrics/field_trial.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « base/metrics/field_trial.h ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 63
64 // statics 64 // statics
65 const int FieldTrial::kNotFinalized = -1; 65 const int FieldTrial::kNotFinalized = -1;
66 const int FieldTrial::kDefaultGroupNumber = 0; 66 const int FieldTrial::kDefaultGroupNumber = 0;
67 bool FieldTrial::enable_benchmarking_ = false; 67 bool FieldTrial::enable_benchmarking_ = false;
68 68
69 const char FieldTrialList::kPersistentStringSeparator('/'); 69 const char FieldTrialList::kPersistentStringSeparator('/');
70 const char FieldTrialList::kActivationMarker('*');
70 int FieldTrialList::kNoExpirationYear = 0; 71 int FieldTrialList::kNoExpirationYear = 0;
71 72
72 //------------------------------------------------------------------------------ 73 //------------------------------------------------------------------------------
73 // FieldTrial methods and members. 74 // FieldTrial methods and members.
74 75
75 FieldTrial::EntropyProvider::~EntropyProvider() { 76 FieldTrial::EntropyProvider::~EntropyProvider() {
76 } 77 }
77 78
78 void FieldTrial::Disable() { 79 void FieldTrial::Disable() {
79 DCHECK(!group_reported_); 80 DCHECK(!group_reported_);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 while (next_item < trials_string.length()) { 415 while (next_item < trials_string.length()) {
415 size_t name_end = trials_string.find(kPersistentStringSeparator, next_item); 416 size_t name_end = trials_string.find(kPersistentStringSeparator, next_item);
416 if (name_end == trials_string.npos || next_item == name_end) 417 if (name_end == trials_string.npos || next_item == name_end)
417 return false; 418 return false;
418 size_t group_name_end = trials_string.find(kPersistentStringSeparator, 419 size_t group_name_end = trials_string.find(kPersistentStringSeparator,
419 name_end + 1); 420 name_end + 1);
420 if (name_end + 1 == group_name_end) 421 if (name_end + 1 == group_name_end)
421 return false; 422 return false;
422 if (group_name_end == trials_string.npos) 423 if (group_name_end == trials_string.npos)
423 group_name_end = trials_string.length(); 424 group_name_end = trials_string.length();
424 std::string name(trials_string, next_item, name_end - next_item); 425
426 // Verify if the trial should be activated or not.
427 std::string name;
428 bool force_activation = false;
429 if (trials_string[next_item] == kActivationMarker) {
430 // Name cannot be only the indicator.
431 if (name_end - next_item == 1)
432 return false;
433 next_item++;
434 force_activation = true;
435 }
436 name.append(trials_string, next_item, name_end - next_item);
425 std::string group_name(trials_string, name_end + 1, 437 std::string group_name(trials_string, name_end + 1,
426 group_name_end - name_end - 1); 438 group_name_end - name_end - 1);
427 next_item = group_name_end + 1; 439 next_item = group_name_end + 1;
428 440
429 if (ignored_trial_names.find(name) != ignored_trial_names.end()) 441 if (ignored_trial_names.find(name) != ignored_trial_names.end())
430 continue; 442 continue;
431 443
432 FieldTrial* trial = CreateFieldTrial(name, group_name); 444 FieldTrial* trial = CreateFieldTrial(name, group_name);
433 if (!trial) 445 if (!trial)
434 return false; 446 return false;
435 if (mode == ACTIVATE_TRIALS) { 447 if (mode == ACTIVATE_TRIALS || force_activation) {
436 // Call |group()| to mark the trial as "used" and notify observers, if 448 // Call |group()| to mark the trial as "used" and notify observers, if
437 // any. This is useful to ensure that field trials created in child 449 // any. This is useful to ensure that field trials created in child
438 // processes are properly reported in crash reports. 450 // processes are properly reported in crash reports.
439 trial->group(); 451 trial->group();
440 } 452 }
441 } 453 }
442 return true; 454 return true;
443 } 455 }
444 456
445 // static 457 // static
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return; 548 return;
537 } 549 }
538 AutoLock auto_lock(global_->lock_); 550 AutoLock auto_lock(global_->lock_);
539 DCHECK(!global_->PreLockedFind(trial->trial_name())); 551 DCHECK(!global_->PreLockedFind(trial->trial_name()));
540 trial->AddRef(); 552 trial->AddRef();
541 trial->SetTrialRegistered(); 553 trial->SetTrialRegistered();
542 global_->registered_[trial->trial_name()] = trial; 554 global_->registered_[trial->trial_name()] = trial;
543 } 555 }
544 556
545 } // namespace base 557 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial.h ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698