Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | |
| 6 #define BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/lazy_instance.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "components/metrics/metrics_service_client.h" | |
| 16 | |
| 17 class PrefService; | |
| 18 | |
| 19 namespace metrics { | |
| 20 struct ClientInfo; | |
| 21 class MetricsStateManager; | |
| 22 } // namespace metrics | |
| 23 | |
| 24 namespace net { | |
| 25 class URLRequestContextGetter; | |
| 26 } | |
| 27 | |
| 28 namespace blimp { | |
| 29 namespace engine { | |
| 30 | |
| 31 // BlimpMetricsServiceClient provides an implementation of MetricsServiceClient | |
| 32 // that depends on blimp. This singleton manages metrics for an app. | |
| 33 // Metrics are always turned on. This class should always be used on the main | |
| 34 // thread because MetricsService is single-threaded. | |
| 35 // Based on AwMetricsServiceClient. | |
| 36 class BlimpMetricsServiceClient : public metrics::MetricsServiceClient { | |
| 37 friend struct base::DefaultLazyInstanceTraits<BlimpMetricsServiceClient>; | |
| 38 public: | |
| 39 static BlimpMetricsServiceClient* GetInstance(); | |
| 40 | |
| 41 void Initialize(PrefService* pref_service, | |
| 42 net::URLRequestContextGetter* request_context); | |
| 43 void Finalize(); | |
| 44 | |
| 45 // metrics::MetricsServiceClient implementation: | |
| 46 metrics::MetricsService* GetMetricsService() override; | |
| 47 void SetMetricsClientId(const std::string& client_id) override; | |
| 48 void OnRecordingDisabled() override; | |
| 49 bool IsOffTheRecordSessionActive() override; | |
| 50 int32_t GetProduct() override; | |
| 51 std::string GetApplicationLocale() override; | |
| 52 bool GetBrand(std::string* brand_code) override; | |
| 53 metrics::SystemProfileProto::Channel GetChannel() override; | |
| 54 std::string GetVersionString() override; | |
| 55 void OnLogUploadComplete() override; | |
| 56 void InitializeSystemProfileMetrics( | |
| 57 const base::Closure& done_callback) override; | |
| 58 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | |
| 59 scoped_ptr<metrics::MetricsLogUploader> CreateUploader( | |
| 60 const base::Callback<void(int)>& on_upload_complete) override; | |
| 61 base::TimeDelta GetStandardUploadInterval() override; | |
| 62 | |
| 63 private: | |
| 64 BlimpMetricsServiceClient(); | |
| 65 ~BlimpMetricsServiceClient() override; | |
| 66 | |
| 67 // Callback for metrics::MetricsStateManager::Create | |
| 68 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? :)
| |
| 69 | |
| 70 bool is_initialized_; | |
| 71 PrefService* pref_service_; | |
| 72 net::URLRequestContextGetter* request_context_; | |
| 73 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.
| |
| 74 scoped_ptr<metrics::MetricsService> metrics_service_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(BlimpMetricsServiceClient); | |
| 77 }; | |
| 78 | |
| 79 } // namespace engine | |
| 80 } // namespace blimp | |
| 81 | |
| 82 #endif // BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | |
| OLD | NEW |