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

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

Issue 2768263003: Plugins: Add UKM Metrics to Flash loads (Closed)
Patch Set: merge Created 3 years, 8 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 | « chrome/browser/plugins/plugin_info_message_filter.cc ('k') | no next file » | 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_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>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/feature_list.h" 13 #include "base/feature_list.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "components/metrics/metrics_provider.h" 18 #include "components/metrics/metrics_provider.h"
19 #include "components/metrics/metrics_rotation_scheduler.h" 19 #include "components/metrics/metrics_rotation_scheduler.h"
20 #include "components/ukm/ukm_reporting_service.h" 20 #include "components/ukm/ukm_reporting_service.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 class PluginInfoMessageFilter;
23 class PrefRegistrySimple; 24 class PrefRegistrySimple;
24 class PrefService; 25 class PrefService;
25 class UkmPageLoadMetricsObserver; 26 class UkmPageLoadMetricsObserver;
26 27
27 namespace autofill { 28 namespace autofill {
28 class AutofillMetrics; 29 class AutofillMetrics;
29 } // namespace autofill 30 } // namespace autofill
30 31
31 namespace metrics { 32 namespace metrics {
32 class MetricsServiceClient; 33 class MetricsServiceClient;
33 } 34 }
34 35
35 namespace ukm { 36 namespace ukm {
36 37
37 class UkmEntry; 38 class UkmEntry;
38 class UkmEntryBuilder; 39 class UkmEntryBuilder;
39 class UkmSource; 40 class UkmSource;
40 41
41 // This feature controls whether UkmService should be created. 42 // This feature controls whether UkmService should be created.
42 extern const base::Feature kUkmFeature; 43 extern const base::Feature kUkmFeature;
43 44
44 // The URL-Keyed Metrics (UKM) service is responsible for gathering and 45 // The URL-Keyed Metrics (UKM) service is responsible for gathering and
45 // uploading reports that contain fine grained performance metrics including 46 // uploading reports that contain fine grained performance metrics including
46 // URLs for top-level navigations. 47 // URLs for top-level navigations.
47 class UkmService : public base::SupportsWeakPtr<UkmService> { 48 class UkmService {
48 public: 49 public:
49 // Constructs a UkmService. 50 // Constructs a UkmService.
50 // Calling code is responsible for ensuring that the lifetime of 51 // Calling code is responsible for ensuring that the lifetime of
51 // |pref_service| is longer than the lifetime of UkmService. 52 // |pref_service| is longer than the lifetime of UkmService.
52 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client); 53 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client);
53 virtual ~UkmService(); 54 virtual ~UkmService();
54 55
55 // Get the new source ID, which is unique for the duration of a browser 56 // Get the new source ID, which is unique for the duration of a browser
56 // session. 57 // session.
57 static int32_t GetNewSourceID(); 58 static int32_t GetNewSourceID();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const std::map<int32_t, std::unique_ptr<UkmSource>>& sources_for_testing() 102 const std::map<int32_t, std::unique_ptr<UkmSource>>& sources_for_testing()
102 const { 103 const {
103 return sources_; 104 return sources_;
104 } 105 }
105 106
106 const std::vector<std::unique_ptr<UkmEntry>>& entries_for_testing() const { 107 const std::vector<std::unique_ptr<UkmEntry>>& entries_for_testing() const {
107 return entries_; 108 return entries_;
108 } 109 }
109 110
110 private: 111 private:
112 friend autofill::AutofillMetrics;
113 friend PluginInfoMessageFilter;
111 friend UkmPageLoadMetricsObserver; 114 friend UkmPageLoadMetricsObserver;
112 friend autofill::AutofillMetrics;
113 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics); 115 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics);
114 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization); 116 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization);
115 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, 117 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest,
116 LogsUploadedOnlyWhenHavingSourcesOrEntries); 118 LogsUploadedOnlyWhenHavingSourcesOrEntries);
117 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest); 119 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest);
118 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge); 120 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge);
119 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, WhitelistEntryTest); 121 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, WhitelistEntryTest);
120 122
121 // Get a new UkmEntryBuilder object for the specified source ID and event, 123 // Get a new UkmEntryBuilder object for the specified source ID and event,
122 // which can get metrics added to. 124 // which can get metrics added to.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Weak pointers factory used to post task on different threads. All weak 196 // Weak pointers factory used to post task on different threads. All weak
195 // pointers managed by this factory have the same lifetime as UkmService. 197 // pointers managed by this factory have the same lifetime as UkmService.
196 base::WeakPtrFactory<UkmService> self_ptr_factory_; 198 base::WeakPtrFactory<UkmService> self_ptr_factory_;
197 199
198 DISALLOW_COPY_AND_ASSIGN(UkmService); 200 DISALLOW_COPY_AND_ASSIGN(UkmService);
199 }; 201 };
200 202
201 } // namespace ukm 203 } // namespace ukm
202 204
203 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 205 #endif // COMPONENTS_UKM_UKM_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_info_message_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698