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

Side by Side Diff: components/ukm/test_ukm_service.h

Issue 2737953002: UKM: Remove UkmService::RecordSource (Closed)
Patch Set: fix error from rebase Created 3 years, 9 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef COMPONENTS_UKM_TEST_UKM_SERVICE_H_ 5 #ifndef COMPONENTS_UKM_TEST_UKM_SERVICE_H_
6 #define COMPONENTS_UKM_TEST_UKM_SERVICE_H_ 6 #define COMPONENTS_UKM_TEST_UKM_SERVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <memory> 9 #include <memory>
10 10
11 #include "components/metrics/test_metrics_service_client.h" 11 #include "components/metrics/test_metrics_service_client.h"
12 #include "components/prefs/testing_pref_service.h" 12 #include "components/prefs/testing_pref_service.h"
13 #include "components/ukm/ukm_pref_names.h" 13 #include "components/ukm/ukm_pref_names.h"
14 #include "components/ukm/ukm_service.h" 14 #include "components/ukm/ukm_service.h"
15 15
16 namespace ukm { 16 namespace ukm {
17 17
18 // Wraps an UkmService with additional accessors used for testing. 18 // Wraps an UkmService with additional accessors used for testing.
19 class TestUkmService : public UkmService { 19 class TestUkmService : public UkmService {
20 public: 20 public:
21 explicit TestUkmService(PrefService* pref_service); 21 explicit TestUkmService(PrefService* pref_service);
22 ~TestUkmService() override; 22 ~TestUkmService() override;
23 23
24 size_t sources_count() const { return sources_for_testing().size(); } 24 size_t sources_count() const { return sources_for_testing().size(); }
25 const UkmSource* GetSource(size_t source_num) const; 25 const std::map<int32_t, std::unique_ptr<UkmSource>>& GetSources() const;
26 const UkmSource* GetSourceForUrl(const char* url) const;
26 27
27 size_t entries_count() const { return entries_for_testing().size(); } 28 size_t entries_count() const { return entries_for_testing().size(); }
28 const UkmEntry* GetEntry(size_t entry_num) const; 29 const UkmEntry* GetEntry(size_t entry_num) const;
29 30
30 private: 31 private:
31 metrics::TestMetricsServiceClient test_metrics_service_client_; 32 metrics::TestMetricsServiceClient test_metrics_service_client_;
32 33
33 DISALLOW_COPY_AND_ASSIGN(TestUkmService); 34 DISALLOW_COPY_AND_ASSIGN(TestUkmService);
34 }; 35 };
35 36
36 // Convenience harness used for testing; creates a TestUkmService and 37 // Convenience harness used for testing; creates a TestUkmService and
37 // supplies it with a prefs service with a longer lifespan. 38 // supplies it with a prefs service with a longer lifespan.
38 class UkmServiceTestingHarness { 39 class UkmServiceTestingHarness {
39 public: 40 public:
40 UkmServiceTestingHarness(); 41 UkmServiceTestingHarness();
41 virtual ~UkmServiceTestingHarness(); 42 virtual ~UkmServiceTestingHarness();
42 43
43 TestUkmService* test_ukm_service() { return test_ukm_service_.get(); } 44 TestUkmService* test_ukm_service() { return test_ukm_service_.get(); }
44 45
45 private: 46 private:
46 TestingPrefServiceSimple test_prefs_; 47 TestingPrefServiceSimple test_prefs_;
47 std::unique_ptr<TestUkmService> test_ukm_service_; 48 std::unique_ptr<TestUkmService> test_ukm_service_;
48 49
49 DISALLOW_COPY_AND_ASSIGN(UkmServiceTestingHarness); 50 DISALLOW_COPY_AND_ASSIGN(UkmServiceTestingHarness);
50 }; 51 };
51 52
52 } // namespace ukm 53 } // namespace ukm
53 54
54 #endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_ 55 #endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_metrics_unittest.cc ('k') | components/ukm/test_ukm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698