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
3 // found in the LICENSE file.
5 #include "components/rappor/test_rappor_service.h"
7 #include "components/rappor/byte_vector_utils.h"
8 #include "components/rappor/proto/rappor_metric.pb.h"
9 #include "components/rappor/rappor_parameters.h"
10 #include "components/rappor/rappor_prefs.h"
11 #include "components/rappor/test_log_uploader.h"
17 bool MockIsIncognito(bool* is_incognito
) {
23 TestRapporService::TestRapporService()
24 : RapporService(&test_prefs_
, base::Bind(&MockIsIncognito
, &is_incognito_
)),
25 next_rotation_(base::TimeDelta()),
26 is_incognito_(false) {
27 RegisterPrefs(test_prefs_
.registry());
28 test_uploader_
= new TestLogUploader();
29 InitializeInternal(make_scoped_ptr(test_uploader_
),
31 HmacByteVectorGenerator::GenerateEntropyInput());
32 Update(FINE_LEVEL
, true);
35 TestRapporService::~TestRapporService() {}
37 int TestRapporService::GetReportsCount() {
38 RapporReports reports
;
39 ExportMetrics(&reports
);
40 return reports
.report_size();
43 void TestRapporService::GetReports(RapporReports
* reports
) {
44 ExportMetrics(reports
);
47 // Cancel the next call to OnLogInterval.
48 void TestRapporService::CancelNextLogRotation() {
49 next_rotation_
= base::TimeDelta();
52 // Schedule the next call to OnLogInterval.
53 void TestRapporService::ScheduleNextLogRotation(base::TimeDelta interval
) {
54 next_rotation_
= interval
;