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

Side by Side Diff: components/variations/entropy_provider_unittest.cc

Issue 623133002: replace OVERRIDE and FINAL with override and final in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
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 "components/variations/entropy_provider.h" 5 #include "components/variations/entropy_provider.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 #include <numeric> 9 #include <numeric>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // entropy corresponding to a low entropy source). 76 // entropy corresponding to a low entropy source).
77 class SHA1EntropyGenerator : public TrialEntropyGenerator { 77 class SHA1EntropyGenerator : public TrialEntropyGenerator {
78 public: 78 public:
79 explicit SHA1EntropyGenerator(const std::string& trial_name) 79 explicit SHA1EntropyGenerator(const std::string& trial_name)
80 : trial_name_(trial_name) { 80 : trial_name_(trial_name) {
81 } 81 }
82 82
83 virtual ~SHA1EntropyGenerator() { 83 virtual ~SHA1EntropyGenerator() {
84 } 84 }
85 85
86 virtual double GenerateEntropyValue() const OVERRIDE { 86 virtual double GenerateEntropyValue() const override {
87 // Use a random GUID + 13 additional bits of entropy to match how the 87 // Use a random GUID + 13 additional bits of entropy to match how the
88 // SHA1EntropyProvider is used in metrics_service.cc. 88 // SHA1EntropyProvider is used in metrics_service.cc.
89 const int low_entropy_source = 89 const int low_entropy_source =
90 static_cast<uint16>(base::RandInt(0, kMaxLowEntropySize - 1)); 90 static_cast<uint16>(base::RandInt(0, kMaxLowEntropySize - 1));
91 const std::string high_entropy_source = 91 const std::string high_entropy_source =
92 base::GenerateGUID() + base::IntToString(low_entropy_source); 92 base::GenerateGUID() + base::IntToString(low_entropy_source);
93 return GenerateSHA1Entropy(high_entropy_source, trial_name_); 93 return GenerateSHA1Entropy(high_entropy_source, trial_name_);
94 } 94 }
95 95
96 private: 96 private:
(...skipping 12 matching lines...) Expand all
109 // As a performance optimization, pre-compute the mapping once per trial 109 // As a performance optimization, pre-compute the mapping once per trial
110 // name and index into it for each entropy value. 110 // name and index into it for each entropy value.
111 const uint32 randomization_seed = HashName(trial_name); 111 const uint32 randomization_seed = HashName(trial_name);
112 internal::PermuteMappingUsingRandomizationSeed(randomization_seed, 112 internal::PermuteMappingUsingRandomizationSeed(randomization_seed,
113 &mapping_); 113 &mapping_);
114 } 114 }
115 115
116 virtual ~PermutedEntropyGenerator() { 116 virtual ~PermutedEntropyGenerator() {
117 } 117 }
118 118
119 virtual double GenerateEntropyValue() const OVERRIDE { 119 virtual double GenerateEntropyValue() const override {
120 const int low_entropy_source = 120 const int low_entropy_source =
121 static_cast<uint16>(base::RandInt(0, kMaxLowEntropySize - 1)); 121 static_cast<uint16>(base::RandInt(0, kMaxLowEntropySize - 1));
122 return mapping_[low_entropy_source] / 122 return mapping_[low_entropy_source] /
123 static_cast<double>(kMaxLowEntropySize); 123 static_cast<double>(kMaxLowEntropySize);
124 } 124 }
125 125
126 private: 126 private:
127 std::vector<uint16> mapping_; 127 std::vector<uint16> mapping_;
128 128
129 DISALLOW_COPY_AND_ASSIGN(PermutedEntropyGenerator); 129 DISALLOW_COPY_AND_ASSIGN(PermutedEntropyGenerator);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 ++count; 360 ++count;
361 } 361 }
362 362
363 ASSERT_LT(count, kMaxAttempts) << "Expected average was " << 363 ASSERT_LT(count, kMaxAttempts) << "Expected average was " <<
364 kExpectedAverage << ", average ended at " << cumulative_average << 364 kExpectedAverage << ", average ended at " << cumulative_average <<
365 ", for trial " << kTestTrialNames[i]; 365 ", for trial " << kTestTrialNames[i];
366 } 366 }
367 } 367 }
368 368
369 } // namespace metrics 369 } // namespace metrics
OLDNEW
« no previous file with comments | « components/variations/entropy_provider.h ('k') | components/variations/variations_http_header_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698