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

Unified Diff: blimp/engine/app/blimp_metrics_service_client.h

Issue 1885673003: Create and integrate a metrics service client into Blimp engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates based on PrefStore changes before commit. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: blimp/engine/app/blimp_metrics_service_client.h
diff --git a/blimp/engine/app/blimp_metrics_service_client.h b/blimp/engine/app/blimp_metrics_service_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..ef47b3bd3b790bbad645e281043b08aca311d816
--- /dev/null
+++ b/blimp/engine/app/blimp_metrics_service_client.h
@@ -0,0 +1,82 @@
+// Copyright 2016 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 BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_
+#define BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_
+
+#include <stdint.h>
+
+#include <string>
+
+#include "base/lazy_instance.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/metrics/metrics_service_client.h"
+
+class PrefService;
+
+namespace metrics {
+struct ClientInfo;
+class MetricsStateManager;
+} // namespace metrics
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace blimp {
+namespace engine {
+
+// BlimpMetricsServiceClient provides an implementation of MetricsServiceClient
+// that depends on blimp. This singleton manages metrics for an app.
+// Metrics are always turned on. This class should always be used on the main
+// thread because MetricsService is single-threaded.
+// Based on AwMetricsServiceClient.
+class BlimpMetricsServiceClient : public metrics::MetricsServiceClient {
+ friend struct base::DefaultLazyInstanceTraits<BlimpMetricsServiceClient>;
+ public:
+ static BlimpMetricsServiceClient* GetInstance();
+
+ void Initialize(PrefService* pref_service,
+ net::URLRequestContextGetter* request_context);
+ void Finalize();
+
+ // metrics::MetricsServiceClient implementation:
+ metrics::MetricsService* GetMetricsService() override;
+ void SetMetricsClientId(const std::string& client_id) override;
+ void OnRecordingDisabled() override;
+ bool IsOffTheRecordSessionActive() override;
+ int32_t GetProduct() override;
+ std::string GetApplicationLocale() override;
+ bool GetBrand(std::string* brand_code) override;
+ metrics::SystemProfileProto::Channel GetChannel() override;
+ std::string GetVersionString() override;
+ void OnLogUploadComplete() override;
+ void InitializeSystemProfileMetrics(
+ const base::Closure& done_callback) override;
+ void CollectFinalMetricsForLog(const base::Closure& done_callback) override;
+ scoped_ptr<metrics::MetricsLogUploader> CreateUploader(
+ const base::Callback<void(int)>& on_upload_complete) override;
+ base::TimeDelta GetStandardUploadInterval() override;
+
+ private:
+ BlimpMetricsServiceClient();
+ ~BlimpMetricsServiceClient() override;
+
+ // Callback for metrics::MetricsStateManager::Create
+ bool is_reporting_enabled();
Alexei Svitkine (slow) 2016/04/25 20:44:25 Nit: IsReportingEnabled() Or if you want to keep
Jess 2016/04/26 00:01:24 Why not both? :)
+
+ bool is_initialized_;
+ PrefService* pref_service_;
+ net::URLRequestContextGetter* request_context_;
+ scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_;
Alexei Svitkine (slow) 2016/04/25 20:44:25 Nit: Use unique_ptr.
Jess 2016/04/26 00:01:25 Done.
+ scoped_ptr<metrics::MetricsService> metrics_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpMetricsServiceClient);
+};
+
+} // namespace engine
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698