| 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> |
| 8 |
| 7 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 8 #include "base/metrics/metrics_hashes.h" | 10 #include "base/metrics/metrics_hashes.h" |
| 9 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 11 #include "components/rappor/log_uploader.h" | 13 #include "components/rappor/log_uploader.h" |
| 12 #include "components/rappor/proto/rappor_metric.pb.h" | 14 #include "components/rappor/proto/rappor_metric.pb.h" |
| 13 #include "components/rappor/rappor_metric.h" | 15 #include "components/rappor/rappor_metric.h" |
| 14 #include "components/rappor/rappor_pref_names.h" | 16 #include "components/rappor/rappor_pref_names.h" |
| 15 #include "components/rappor/rappor_prefs.h" | 17 #include "components/rappor/rappor_prefs.h" |
| 16 #include "components/variations/variations_associated_data.h" | 18 #include "components/variations/variations_associated_data.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 kRapporDailyEventHistogram), | 62 kRapporDailyEventHistogram), |
| 61 recording_groups_(0) { | 63 recording_groups_(0) { |
| 62 } | 64 } |
| 63 | 65 |
| 64 RapporService::~RapporService() { | 66 RapporService::~RapporService() { |
| 65 STLDeleteValues(&metrics_map_); | 67 STLDeleteValues(&metrics_map_); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void RapporService::AddDailyObserver( | 70 void RapporService::AddDailyObserver( |
| 69 scoped_ptr<metrics::DailyEvent::Observer> observer) { | 71 scoped_ptr<metrics::DailyEvent::Observer> observer) { |
| 70 daily_event_.AddObserver(observer.Pass()); | 72 daily_event_.AddObserver(std::move(observer)); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void RapporService::Initialize(net::URLRequestContextGetter* request_context) { | 75 void RapporService::Initialize(net::URLRequestContextGetter* request_context) { |
| 74 DCHECK(thread_checker_.CalledOnValidThread()); | 76 DCHECK(thread_checker_.CalledOnValidThread()); |
| 75 DCHECK(!IsInitialized()); | 77 DCHECK(!IsInitialized()); |
| 76 const GURL server_url = GetServerUrl(); | 78 const GURL server_url = GetServerUrl(); |
| 77 if (!server_url.is_valid()) { | 79 if (!server_url.is_valid()) { |
| 78 DVLOG(1) << server_url.spec() << " is invalid. " | 80 DVLOG(1) << server_url.spec() << " is invalid. " |
| 79 << "RapporService not started."; | 81 << "RapporService not started."; |
| 80 return; | 82 return; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 return scoped_ptr<Sample>( | 255 return scoped_ptr<Sample>( |
| 254 new Sample(cohort_, internal::kRapporParametersForType[type])); | 256 new Sample(cohort_, internal::kRapporParametersForType[type])); |
| 255 } | 257 } |
| 256 | 258 |
| 257 void RapporService::RecordSampleObj(const std::string& metric_name, | 259 void RapporService::RecordSampleObj(const std::string& metric_name, |
| 258 scoped_ptr<Sample> sample) { | 260 scoped_ptr<Sample> sample) { |
| 259 DCHECK(thread_checker_.CalledOnValidThread()); | 261 DCHECK(thread_checker_.CalledOnValidThread()); |
| 260 if (!RecordingAllowed(sample->parameters())) | 262 if (!RecordingAllowed(sample->parameters())) |
| 261 return; | 263 return; |
| 262 DVLOG(1) << "Recording sample of metric \"" << metric_name << "\""; | 264 DVLOG(1) << "Recording sample of metric \"" << metric_name << "\""; |
| 263 sampler_.AddSample(metric_name, sample.Pass()); | 265 sampler_.AddSample(metric_name, std::move(sample)); |
| 264 } | 266 } |
| 265 | 267 |
| 266 } // namespace rappor | 268 } // namespace rappor |
| OLD | NEW |