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

Side by Side Diff: ios/chrome/today_extension/today_metrics_logger.h

Issue 2586713002: Upstream code and resources for Chrome on iOS extensions. (Closed)
Patch Set: Created 4 years 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 2015 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 IOS_CHROME_TODAY_EXTENSION_TODAY_METRICS_LOGGER_H_
6 #define IOS_CHROME_TODAY_EXTENSION_TODAY_METRICS_LOGGER_H_
7
8 #include <memory>
9 #import "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram_flattener.h"
12 #include "base/metrics/histogram_snapshot_manager.h"
13 #include "base/metrics/user_metrics_action.h"
14
15 namespace base {
16
17 class SequencedWorkerPool;
18 class SequencedTaskRunner;
19
20 } // namespace base
21
22 namespace {
23
24 class TodayMetricsLog;
25 class TodayMetricsServiceClient;
26
27 } // namespace
28
29 class ValueMapPrefStore;
30 class PrefRegistrySimple;
31 class PrefService;
32
33 // Utility class to create metrics log that can be pushed to Chrome. The
34 // extension creates and fills the logs with UserAction. The upload is done by
35 // the Chrome application.
36 class TodayMetricsLogger : base::HistogramFlattener {
37 public:
38 // Singleton.
39 static TodayMetricsLogger* GetInstance();
40
41 // Records a user action. The log is saved in the user defaults after each
42 // action.
43 void RecordUserAction(base::UserMetricsAction action);
44
45 // Write the current log in the UserDefaults.
46 void PersistLogs();
47
48 // HistogramFlattener:
49 void RecordDelta(const base::HistogramBase& histogram,
50 const base::HistogramSamples& snapshot) override;
51 void InconsistencyDetected(
52 base::HistogramBase::Inconsistency problem) override;
53 void UniqueInconsistencyDetected(
54 base::HistogramBase::Inconsistency problem) override;
55 void InconsistencyDetectedInLoggedCount(int amount) override;
56
57 private:
58 TodayMetricsLogger();
59 ~TodayMetricsLogger() override;
60
61 bool CreateNewLog();
62
63 base::MessageLoop message_loop_;
64 scoped_refptr<PrefRegistrySimple> pref_registry_;
65 std::unique_ptr<PrefService> pref_service_;
66 scoped_refptr<ValueMapPrefStore> value_map_prefs_;
67 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
68 std::unique_ptr<TodayMetricsLog> log_;
69 scoped_refptr<base::SequencedWorkerPool> thread_pool_;
70 std::unique_ptr<TodayMetricsServiceClient> metrics_service_client_;
71 base::HistogramSnapshotManager histogram_snapshot_manager_;
72
73 DISALLOW_COPY_AND_ASSIGN(TodayMetricsLogger);
74 };
75
76 #endif // IOS_CHROME_TODAY_EXTENSION_TODAY_METRICS_LOGGER_H_
OLDNEW
« no previous file with comments | « ios/chrome/today_extension/resources/todayview_voice_search@3x.png ('k') | ios/chrome/today_extension/today_metrics_logger.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698