OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/rappor/rappor_service.h" | 5 #include "components/rappor/rappor_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 // Skip this metric if its recording_group is not enabled. | 197 // Skip this metric if its recording_group is not enabled. |
198 if (!(recording_groups_ & parameters.recording_group)) { | 198 if (!(recording_groups_ & parameters.recording_group)) { |
199 DVLOG(2) << "Metric not logged due to recording_group " | 199 DVLOG(2) << "Metric not logged due to recording_group " |
200 << recording_groups_ << " < " << parameters.recording_group; | 200 << recording_groups_ << " < " << parameters.recording_group; |
201 return false; | 201 return false; |
202 } | 202 } |
203 return true; | 203 return true; |
204 } | 204 } |
205 | 205 |
206 void RapporService::RecordSample(const std::string& metric_name, | 206 void RapporService::RecordSampleString(const std::string& metric_name, |
207 RapporType type, | 207 RapporType type, |
208 const std::string& sample) { | 208 const std::string& sample) { |
209 DCHECK(thread_checker_.CalledOnValidThread()); | 209 DCHECK(thread_checker_.CalledOnValidThread()); |
210 // Ignore the sample if the service hasn't started yet. | 210 // Ignore the sample if the service hasn't started yet. |
211 if (!IsInitialized()) | 211 if (!IsInitialized()) |
212 return; | 212 return; |
213 DCHECK_LT(type, NUM_RAPPOR_TYPES); | 213 DCHECK_LT(type, NUM_RAPPOR_TYPES); |
214 const RapporParameters& parameters = internal::kRapporParametersForType[type]; | 214 const RapporParameters& parameters = internal::kRapporParametersForType[type]; |
215 DVLOG(2) << "Recording sample \"" << sample | 215 DVLOG(2) << "Recording sample \"" << sample |
216 << "\" for metric \"" << metric_name | 216 << "\" for metric \"" << metric_name |
217 << "\" of type: " << type; | 217 << "\" of type: " << type; |
218 RecordSampleInternal(metric_name, parameters, sample); | 218 RecordSampleInternal(metric_name, parameters, sample); |
(...skipping 26 matching lines...) Expand all Loading... |
245 return new_metric; | 245 return new_metric; |
246 } | 246 } |
247 | 247 |
248 std::unique_ptr<Sample> RapporService::CreateSample(RapporType type) { | 248 std::unique_ptr<Sample> RapporService::CreateSample(RapporType type) { |
249 DCHECK(thread_checker_.CalledOnValidThread()); | 249 DCHECK(thread_checker_.CalledOnValidThread()); |
250 DCHECK(IsInitialized()); | 250 DCHECK(IsInitialized()); |
251 return base::WrapUnique( | 251 return base::WrapUnique( |
252 new Sample(cohort_, internal::kRapporParametersForType[type])); | 252 new Sample(cohort_, internal::kRapporParametersForType[type])); |
253 } | 253 } |
254 | 254 |
255 void RapporService::RecordSampleObj(const std::string& metric_name, | 255 void RapporService::RecordSample(const std::string& metric_name, |
256 std::unique_ptr<Sample> sample) { | 256 std::unique_ptr<Sample> sample) { |
257 DCHECK(thread_checker_.CalledOnValidThread()); | 257 DCHECK(thread_checker_.CalledOnValidThread()); |
258 if (!RecordingAllowed(sample->parameters())) | 258 if (!RecordingAllowed(sample->parameters())) |
259 return; | 259 return; |
260 DVLOG(1) << "Recording sample of metric \"" << metric_name << "\""; | 260 DVLOG(1) << "Recording sample of metric \"" << metric_name << "\""; |
261 sampler_.AddSample(metric_name, std::move(sample)); | 261 sampler_.AddSample(metric_name, std::move(sample)); |
262 } | 262 } |
263 | 263 |
264 } // namespace rappor | 264 } // namespace rappor |
OLD | NEW |