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

Side by Side Diff: components/ukm/public/ukm_recorder.h

Issue 2883563002: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fix uma_session_stats.cc Created 3 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_UKM_PUBLIC_UKM_RECORDER_H_
6 #define COMPONENTS_UKM_PUBLIC_UKM_RECORDER_H_
7
8 #include <stddef.h>
9
10 #include "base/callback.h"
11 #include "base/feature_list.h"
12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h"
14 #include "components/ukm/public/interfaces/ukm_interface.mojom.h"
15 #include "components/ukm/public/ukm_entry_builder.h"
16 #include "url/gurl.h"
17
18 class PluginInfoMessageFilter;
19 class UkmPageLoadMetricsObserver;
20
21 namespace autofill {
22 class AutofillMetrics;
23 }
24
25 namespace content {
26 class RenderFrameImpl;
27 }
28
29 namespace translate {
30 class TranslateRankerImpl;
31 }
32
33 namespace payments {
34 class JourneyLogger;
35 }
36
37 namespace ukm {
38
39 class UkmEntryBuilder;
40 class UkmInterface;
41 class TestRecordingHelper;
42
43 // This feature controls whether UkmService should be created.
44 extern const base::Feature kUkmFeature;
45
46 typedef int64_t SourceId;
47
48 // Interface for recording UKM
49 class UkmRecorder {
50 public:
51 UkmRecorder();
52 virtual ~UkmRecorder();
53
54 // Get the new source ID, which is unique for the duration of a browser
55 // session.
56 static SourceId GetNewSourceID();
57
58 // Update the URL on the source keyed to the given source ID. If the source
59 // does not exist, it will create a new UkmSource object.
60 virtual void UpdateSourceURL(SourceId source_id, const GURL& url) = 0;
61
62 private:
63 friend autofill::AutofillMetrics;
64 friend payments::JourneyLogger;
65 friend PluginInfoMessageFilter;
66 friend UkmPageLoadMetricsObserver;
67 friend translate::TranslateRankerImpl;
68 friend TestRecordingHelper;
69 friend UkmInterface;
70 friend content::RenderFrameImpl;
71 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryWithEmptyMetrics);
72 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization);
73 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest,
74 LogsUploadedOnlyWhenHavingSourcesOrEntries);
75 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest);
76 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge);
77 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, WhitelistEntryTest);
78
79 // Get a new UkmEntryBuilder object for the specified source ID and event,
80 // which can get metrics added to.
81 //
82 // This API being private is intentional. Any client using UKM needs to
83 // declare itself to be a friend of UkmService and go through code review
84 // process.
85 std::unique_ptr<UkmEntryBuilder> GetEntryBuilder(SourceId source_id,
86 const char* event_name);
87
88 private:
89 // Add an entry to the UkmEntry list.
90 virtual void AddEntry(mojom::UkmEntryPtr entry) = 0;
91
92 DISALLOW_COPY_AND_ASSIGN(UkmRecorder);
93 };
94
95 } // namespace ukm
96
97 #endif // COMPONENTS_UKM_PUBLIC_UKM_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698