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

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

Issue 2719823003: Convert first contentful paint logging to the new UKM client API (Closed)
Patch Set: renames 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
« no previous file with comments | « components/metrics/proto/ukm/source.proto ('k') | components/ukm/test_ukm_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 UkmSource* GetSource(size_t source_num) const;
26 26
27 size_t entries_count() const { return entries_for_testing().size(); }
28 const UkmEntry* GetEntry(size_t entry_num) const;
29
27 private: 30 private:
28 metrics::TestMetricsServiceClient test_metrics_service_client_; 31 metrics::TestMetricsServiceClient test_metrics_service_client_;
29 32
30 DISALLOW_COPY_AND_ASSIGN(TestUkmService); 33 DISALLOW_COPY_AND_ASSIGN(TestUkmService);
31 }; 34 };
32 35
33 // Convenience harness used for testing; creates a TestUkmService and 36 // Convenience harness used for testing; creates a TestUkmService and
34 // supplies it with a prefs service with a longer lifespan. 37 // supplies it with a prefs service with a longer lifespan.
35 class UkmServiceTestingHarness { 38 class UkmServiceTestingHarness {
36 public: 39 public:
37 UkmServiceTestingHarness(); 40 UkmServiceTestingHarness();
38 virtual ~UkmServiceTestingHarness(); 41 virtual ~UkmServiceTestingHarness();
39 42
40 TestUkmService* test_ukm_service() { return test_ukm_service_.get(); } 43 TestUkmService* test_ukm_service() { return test_ukm_service_.get(); }
41 44
42 private: 45 private:
43 TestingPrefServiceSimple test_prefs_; 46 TestingPrefServiceSimple test_prefs_;
44 std::unique_ptr<TestUkmService> test_ukm_service_; 47 std::unique_ptr<TestUkmService> test_ukm_service_;
45 48
46 DISALLOW_COPY_AND_ASSIGN(UkmServiceTestingHarness); 49 DISALLOW_COPY_AND_ASSIGN(UkmServiceTestingHarness);
47 }; 50 };
48 51
49 } // namespace ukm 52 } // namespace ukm
50 53
51 #endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_ 54 #endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_
OLDNEW
« no previous file with comments | « components/metrics/proto/ukm/source.proto ('k') | components/ukm/test_ukm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698