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

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

Issue 2719823003: Convert first contentful paint logging to the new UKM client API (Closed)
Patch Set: migrate to int32_t 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_UKM_SERVICE_H_ 5 #ifndef COMPONENTS_UKM_UKM_SERVICE_H_
6 #define COMPONENTS_UKM_UKM_SERVICE_H_ 6 #define COMPONENTS_UKM_UKM_SERVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Registers the specified |provider| to provide additional metrics into the 77 // Registers the specified |provider| to provide additional metrics into the
78 // UKM log. Should be called during MetricsService initialization only. 78 // UKM log. Should be called during MetricsService initialization only.
79 void RegisterMetricsProvider( 79 void RegisterMetricsProvider(
80 std::unique_ptr<metrics::MetricsProvider> provider); 80 std::unique_ptr<metrics::MetricsProvider> provider);
81 81
82 // Registers the names of all of the preferences used by UkmService in 82 // Registers the names of all of the preferences used by UkmService in
83 // the provided PrefRegistry. 83 // the provided PrefRegistry.
84 static void RegisterPrefs(PrefRegistrySimple* registry); 84 static void RegisterPrefs(PrefRegistrySimple* registry);
85 85
86 // Allocates a new source id. The allocated source id is guaranteed to be
87 // unique for the duration of this browser session.
88 static int32_t NewSourceId();
89
86 using AddEntryCallback = base::Callback<void(std::unique_ptr<UkmEntry>)>; 90 using AddEntryCallback = base::Callback<void(std::unique_ptr<UkmEntry>)>;
87 91
88 protected: 92 protected:
89 const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() const { 93 const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() const {
90 return sources_; 94 return sources_;
91 } 95 }
92 96
97 const std::vector<std::unique_ptr<UkmEntry>>& entries_for_testing() const {
98 return entries_;
99 }
100
93 private: 101 private:
94 friend UkmPageLoadMetricsObserver; 102 friend UkmPageLoadMetricsObserver;
95 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics); 103 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics);
96 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization); 104 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization);
97 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, 105 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest,
98 LogsUploadedOnlyWhenHavingSourcesOrEntries); 106 LogsUploadedOnlyWhenHavingSourcesOrEntries);
99 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest); 107 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest);
100 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge); 108 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge);
101 109
102 // Get a new UkmEntryBuilder object for the specified source ID and event, 110 // Get a new UkmEntryBuilder object for the specified source ID and event,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Weak pointers factory used to post task on different threads. All weak 184 // Weak pointers factory used to post task on different threads. All weak
177 // pointers managed by this factory have the same lifetime as UkmService. 185 // pointers managed by this factory have the same lifetime as UkmService.
178 base::WeakPtrFactory<UkmService> self_ptr_factory_; 186 base::WeakPtrFactory<UkmService> self_ptr_factory_;
179 187
180 DISALLOW_COPY_AND_ASSIGN(UkmService); 188 DISALLOW_COPY_AND_ASSIGN(UkmService);
181 }; 189 };
182 190
183 } // namespace ukm 191 } // namespace ukm
184 192
185 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 193 #endif // COMPONENTS_UKM_UKM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698