| 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/macros.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "components/metrics/enabled_state_provider.h" | |
| 15 #include "components/metrics/metrics_service_client.h" | |
| 16 | |
| 17 class PrefService; | |
| 18 | |
| 19 namespace metrics { | |
| 20 class MetricsService; | |
| 21 class MetricsStateManager; | |
| 22 class SystemProfileProto; | |
| 23 } | |
| 24 | |
| 25 namespace net { | |
| 26 class URLRequestContextGetter; | |
| 27 } // namespace net | |
| 28 | |
| 29 namespace blimp { | |
| 30 namespace engine { | |
| 31 | |
| 32 // BlimpMetricsServiceClient provides an implementation of MetricsServiceClient | |
| 33 // tailored for the Blimp engine to support the upload of metrics information | |
| 34 // from the engine. | |
| 35 // Metrics are always turned on. | |
| 36 class BlimpMetricsServiceClient : public metrics::MetricsServiceClient, | |
| 37 public metrics::EnabledStateProvider { | |
| 38 public: | |
| 39 // PrefService ownership is retained by the caller. | |
| 40 // The request_context_getter is a system request context. | |
| 41 // Both must remain valid for client lifetime. | |
| 42 BlimpMetricsServiceClient( | |
| 43 PrefService* pref_service, | |
| 44 scoped_refptr<net::URLRequestContextGetter> request_context_getter); | |
| 45 ~BlimpMetricsServiceClient() override; | |
| 46 | |
| 47 // metrics::MetricsServiceClient implementation. | |
| 48 metrics::MetricsService* GetMetricsService() override; | |
| 49 void SetMetricsClientId(const std::string& client_id) 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 InitializeSystemProfileMetrics( | |
| 56 const base::Closure& done_callback) override; | |
| 57 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | |
| 58 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( | |
| 59 const std::string& server_url, | |
| 60 const std::string& mime_type, | |
| 61 const base::Callback<void(int)>& on_upload_complete) override; | |
| 62 base::TimeDelta GetStandardUploadInterval() override; | |
| 63 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override; | |
| 64 | |
| 65 // metrics::EnabledStateProvider implementation. | |
| 66 // Returns if consent is given for the MetricsService to record metrics | |
| 67 // information for the client. Always true. | |
| 68 bool IsConsentGiven() override; | |
| 69 | |
| 70 private: | |
| 71 // Used by NetMetricsLogUploader to create log-upload requests. | |
| 72 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
| 73 | |
| 74 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_; | |
| 75 std::unique_ptr<metrics::MetricsService> metrics_service_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(BlimpMetricsServiceClient); | |
| 78 }; | |
| 79 | |
| 80 } // namespace engine | |
| 81 } // namespace blimp | |
| 82 | |
| 83 #endif // BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | |
| OLD | NEW |