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

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

Issue 2798643002: Plugins: Add UKM Metrics to Flash loads (Closed)
Patch Set: 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_reporting_scheduler.h" 19 #include "components/metrics/metrics_reporting_scheduler.h"
20 #include "components/metrics/persisted_logs.h" 20 #include "components/metrics/persisted_logs.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 MetricsLogUploader; 33 class MetricsLogUploader;
33 class MetricsServiceClient; 34 class MetricsServiceClient;
34 } 35 }
35 36
36 namespace ukm { 37 namespace ukm {
37 38
38 class UkmEntry; 39 class UkmEntry;
39 class UkmEntryBuilder; 40 class UkmEntryBuilder;
40 class UkmSource; 41 class UkmSource;
41 42
42 // This feature controls whether UkmService should be created. 43 // This feature controls whether UkmService should be created.
43 extern const base::Feature kUkmFeature; 44 extern const base::Feature kUkmFeature;
44 45
45 // The URL-Keyed Metrics (UKM) service is responsible for gathering and 46 // The URL-Keyed Metrics (UKM) service is responsible for gathering and
46 // uploading reports that contain fine grained performance metrics including 47 // uploading reports that contain fine grained performance metrics including
47 // URLs for top-level navigations. 48 // URLs for top-level navigations.
48 class UkmService : public base::SupportsWeakPtr<UkmService> { 49 class UkmService {
49 public: 50 public:
50 // Constructs a UkmService. 51 // Constructs a UkmService.
51 // Calling code is responsible for ensuring that the lifetime of 52 // Calling code is responsible for ensuring that the lifetime of
52 // |pref_service| is longer than the lifetime of UkmService. 53 // |pref_service| is longer than the lifetime of UkmService.
53 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client); 54 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client);
54 virtual ~UkmService(); 55 virtual ~UkmService();
55 56
56 // Get the new source ID, which is unique for the duration of a browser 57 // Get the new source ID, which is unique for the duration of a browser
57 // session. 58 // session.
58 static int32_t GetNewSourceID(); 59 static int32_t GetNewSourceID();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 protected: 102 protected:
102 const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() const { 103 const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() 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 121
120 // Get a new UkmEntryBuilder object for the specified source ID and event, 122 // Get a new UkmEntryBuilder object for the specified source ID and event,
121 // which can get metrics added to. 123 // which can get metrics added to.
122 // 124 //
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Weak pointers factory used to post task on different threads. All weak 199 // Weak pointers factory used to post task on different threads. All weak
198 // pointers managed by this factory have the same lifetime as UkmService. 200 // pointers managed by this factory have the same lifetime as UkmService.
199 base::WeakPtrFactory<UkmService> self_ptr_factory_; 201 base::WeakPtrFactory<UkmService> self_ptr_factory_;
200 202
201 DISALLOW_COPY_AND_ASSIGN(UkmService); 203 DISALLOW_COPY_AND_ASSIGN(UkmService);
202 }; 204 };
203 205
204 } // namespace ukm 206 } // namespace ukm
205 207
206 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 208 #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