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

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: Clean ups from initial reviews. 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..9baec00e2978532e4ceb6817d3b7443ad84955e0
--- /dev/null
+++ b/blimp/engine/app/blimp_metrics_service_client.h
@@ -0,0 +1,83 @@
+// 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 "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.
Wez 2016/04/26 01:38:19 This comment is somewhat cryptic, IMO! - It's not
Jess 2016/04/26 21:24:11 Inlining since various sub points require own resp
+class BlimpMetricsServiceClient : public metrics::MetricsServiceClient {
+ friend struct base::DefaultLazyInstanceTraits<BlimpMetricsServiceClient>;
+ public:
+ static BlimpMetricsServiceClient* GetInstance();
Wez 2016/04/26 01:38:18 Document this API - e.g. does it return a process-
Jess 2016/04/26 21:24:10 I see what you mean about moving the class definit
+
+ void Initialize(PrefService* pref_service,
+ net::URLRequestContextGetter* request_context);
+ void Finalize();
+
+ // metrics::MetricsServiceClient implementation:
Wez 2016/04/26 01:38:18 nit: End comment with . not :
Jess 2016/04/26 21:24:11 Done.
+ 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;
+ std::unique_ptr<metrics::MetricsLogUploader> CreateUploader(
+ const base::Callback<void(int)>& on_upload_complete) override;
+ base::TimeDelta GetStandardUploadInterval() override;
+
+ private:
+ BlimpMetricsServiceClient();
+ ~BlimpMetricsServiceClient() override;
+
+ bool is_initialized_;
Wez 2016/04/26 01:38:19 Suggest initializing this and other POD members in
Jess 2016/04/26 21:24:11 Done.
+ PrefService* pref_service_;
+ // URLRequestContextGetter* that remains valid for class lifetime for use by
+ // NetMetricsLogUploader in place of
+ // g_browser_process->system_request_context()
Wez 2016/04/26 01:38:18 I'd suggest replacing this entire comment with jus
Jess 2016/04/26 21:24:11 Done.
+ // In engine use subclass BlimpURLRequestContextGetter.
Wez 2016/04/26 01:38:18 If this detail is important for the caller to know
Jess 2016/04/26 21:24:11 Done.
+ // Member of g/e/common/blimp_browser_context.
Wez 2016/04/26 01:38:18 nit:What is g/e/?
Jess 2016/04/26 21:24:10 Comment cleaned up.
+ net::URLRequestContextGetter* request_context_;
Wez 2016/04/26 01:38:18 This class is ref-counted - take a lovely safe ref
Jess 2016/04/26 21:24:11 Done.
+ std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_;
+ std::unique_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