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

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

Issue 2893943004: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fixed contextualsearch 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
« no previous file with comments | « components/ukm/ukm_entry_builder.cc ('k') | components/ukm/ukm_recorder_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_UKM_RECORDER_IMPL_H_
6 #define COMPONENTS_UKM_UKM_RECORDER_IMPL_H_
7
8 #include <map>
9 #include <set>
10 #include <vector>
11
12 #include "base/threading/thread_checker.h"
13 #include "components/ukm/public/interfaces/ukm_interface.mojom.h"
14 #include "components/ukm/public/ukm_recorder.h"
15
16 namespace ukm {
17
18 class UkmSource;
19 class Report;
20
21 namespace debug {
22 class DebugPage;
23 }
24
25 class UkmRecorderImpl : public UkmRecorder {
26 public:
27 UkmRecorderImpl();
28 ~UkmRecorderImpl() override;
29
30 // Enables/disables recording control if data is allowed to be collected.
31 void EnableRecording();
32 void DisableRecording();
33
34 // Deletes stored recordings.
35 void Purge();
36
37 protected:
38 // Cache the list of whitelisted entries from the field trial parameter.
39 void StoreWhitelistedEntries();
40
41 // Writes recordings into a report proto, and clears recordings.
42 void StoreRecordingsInReport(Report* report);
43
44 const std::map<ukm::SourceId, std::unique_ptr<UkmSource>>& sources() const {
45 return sources_;
46 }
47
48 const std::vector<mojom::UkmEntryPtr>& entries() const { return entries_; }
49
50 private:
51 friend ::ukm::debug::DebugPage;
52 // UkmRecorder:
53 void UpdateSourceURL(SourceId source_id, const GURL& url) override;
54 void AddEntry(mojom::UkmEntryPtr entry) override;
55
56 // Whether recording new data is currently allowed.
57 bool recording_enabled_;
58
59 // Contains newly added sources and entries of UKM metrics which periodically
60 // get serialized and cleared by BuildAndStoreLog().
61 std::map<ukm::SourceId, std::unique_ptr<UkmSource>> sources_;
62 std::vector<mojom::UkmEntryPtr> entries_;
63
64 // Whitelisted Entry hashes, only the ones in this set will be recorded.
65 std::set<uint64_t> whitelisted_entry_hashes_;
66
67 THREAD_CHECKER(thread_checker_);
68 };
69
70 } // namespace ukm
71
72 #endif // COMPONENTS_UKM_UKM_RECORDER_IMPL_H_
OLDNEW
« no previous file with comments | « components/ukm/ukm_entry_builder.cc ('k') | components/ukm/ukm_recorder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698