| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 // This file defines a service that sends metrics logs to a server. |
| 6 |
| 7 #ifndef COMPONENTS_METRICS_METRICS_REPORTING_SERVICE_H_ |
| 8 #define COMPONENTS_METRICS_METRICS_REPORTING_SERVICE_H_ |
| 9 |
| 10 #include <stdint.h> |
| 11 |
| 12 #include <string> |
| 13 |
| 14 #include "base/macros.h" |
| 15 #include "components/metrics/metrics_log_store.h" |
| 16 #include "components/metrics/reporting_service.h" |
| 17 |
| 18 class PrefService; |
| 19 class PrefRegistrySimple; |
| 20 |
| 21 namespace metrics { |
| 22 |
| 23 class MetricsServiceClient; |
| 24 |
| 25 // See metrics_service.cc for a detailed description. |
| 26 class MetricsReportingService : public ReportingService { |
| 27 public: |
| 28 // Creates the MetricsService with the given |client|, and |
| 29 // |local_state|. Does not take ownership of the paramaters; instead stores |
| 30 // a weak pointer to each. Caller should ensure that the parameters are valid |
| 31 // for the lifetime of this class. |
| 32 MetricsReportingService(MetricsServiceClient* client, |
| 33 PrefService* local_state); |
| 34 ~MetricsReportingService() override; |
| 35 |
| 36 // At startup, prefs needs to be called with a list of all the pref names and |
| 37 // types we'll be using. |
| 38 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 39 |
| 40 MetricsLogStore* metrics_log_store() { return &metrics_log_store_; } |
| 41 const MetricsLogStore* metrics_log_store() const { |
| 42 return &metrics_log_store_; |
| 43 } |
| 44 |
| 45 // Loads any unsent logs from persistent storage. |
| 46 void Initialize() override; |
| 47 |
| 48 private: |
| 49 // ReportingService: |
| 50 LogStore* log_store() override; |
| 51 std::string upload_url() override; |
| 52 std::string upload_mime_type() override; |
| 53 MetricsLogUploader::MetricServiceType service_type() override; |
| 54 void LogActualUploadInterval(base::TimeDelta interval) override; |
| 55 void LogCellularConstraint(bool upload_canceled) override; |
| 56 void LogResponseCode(int response_code) override; |
| 57 void LogSuccess(size_t log_size) override; |
| 58 void LogLargeRejection(size_t log_size) override; |
| 59 |
| 60 MetricsLogStore metrics_log_store_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(MetricsReportingService); |
| 63 }; |
| 64 |
| 65 } // namespace metrics |
| 66 |
| 67 #endif // COMPONENTS_METRICS_METRICS_REPORTING_SERVICE_H_ |
| OLD | NEW |