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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/today_extension/today_metrics_logger.h
diff --git a/ios/chrome/today_extension/today_metrics_logger.h b/ios/chrome/today_extension/today_metrics_logger.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed10df5e5014efa5c9a1ee6f7dcbc7847ad2ab50
--- /dev/null
+++ b/ios/chrome/today_extension/today_metrics_logger.h
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_TODAY_EXTENSION_TODAY_METRICS_LOGGER_H_
+#define IOS_CHROME_TODAY_EXTENSION_TODAY_METRICS_LOGGER_H_
+
+#include <memory>
+#import "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop.h"
+#include "base/metrics/histogram_flattener.h"
+#include "base/metrics/histogram_snapshot_manager.h"
+#include "base/metrics/user_metrics_action.h"
+
+namespace base {
+
+class SequencedWorkerPool;
+class SequencedTaskRunner;
+
+} // namespace base
+
+namespace {
+
+class TodayMetricsLog;
+class TodayMetricsServiceClient;
+
+} // namespace
+
+class ValueMapPrefStore;
+class PrefRegistrySimple;
+class PrefService;
+
+// Utility class to create metrics log that can be pushed to Chrome. The
+// extension creates and fills the logs with UserAction. The upload is done by
+// the Chrome application.
+class TodayMetricsLogger : base::HistogramFlattener {
+ public:
+ // Singleton.
+ static TodayMetricsLogger* GetInstance();
+
+ // Records a user action. The log is saved in the user defaults after each
+ // action.
+ void RecordUserAction(base::UserMetricsAction action);
+
+ // Write the current log in the UserDefaults.
+ void PersistLogs();
+
+ // HistogramFlattener:
+ void RecordDelta(const base::HistogramBase& histogram,
+ const base::HistogramSamples& snapshot) override;
+ void InconsistencyDetected(
+ base::HistogramBase::Inconsistency problem) override;
+ void UniqueInconsistencyDetected(
+ base::HistogramBase::Inconsistency problem) override;
+ void InconsistencyDetectedInLoggedCount(int amount) override;
+
+ private:
+ TodayMetricsLogger();
+ ~TodayMetricsLogger() override;
+
+ bool CreateNewLog();
+
+ base::MessageLoop message_loop_;
+ scoped_refptr<PrefRegistrySimple> pref_registry_;
+ std::unique_ptr<PrefService> pref_service_;
+ scoped_refptr<ValueMapPrefStore> value_map_prefs_;
+ scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
+ std::unique_ptr<TodayMetricsLog> log_;
+ scoped_refptr<base::SequencedWorkerPool> thread_pool_;
+ std::unique_ptr<TodayMetricsServiceClient> metrics_service_client_;
+ base::HistogramSnapshotManager histogram_snapshot_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(TodayMetricsLogger);
+};
+
+#endif // IOS_CHROME_TODAY_EXTENSION_TODAY_METRICS_LOGGER_H_
« 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