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

Side by Side Diff: components/metrics/metrics_reporting_service.h

Issue 2608833002: Move logic for uploading logs into a ReportingService object. (Closed)
Patch Set: Incorporate feedback Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(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 // MetricsReportingService is concrete implementation of ReportingService for
26 // UMA logs. It uses a MetricsLogStore as its LogStore, reports to the UMA
27 // endpoint, and logs some histograms with the UMA prefix.
28 class MetricsReportingService : public ReportingService {
29 public:
30 // Creates a ReportingService with the given |client|, |local_state|, and
31 // |max_retransmit_size|. Does not take ownership of the parameters; instead
Alexei Svitkine (slow) 2017/03/06 22:15:21 Nit: Update comment since max_retransmit_size isn'
Steven Holte 2017/03/06 22:31:40 Done.
32 // it stores a weak pointer to each. Caller should ensure that the parameters
33 // are valid for the lifetime of this class.
34 MetricsReportingService(MetricsServiceClient* client,
35 PrefService* local_state);
36 ~MetricsReportingService() override;
37
38 MetricsLogStore* metrics_log_store() { return &metrics_log_store_; }
39 const MetricsLogStore* metrics_log_store() const {
40 return &metrics_log_store_;
41 }
42
43 // Registers local state prefs used by this class.
44 static void RegisterPrefs(PrefRegistrySimple* registry);
45
46 private:
47 // ReportingService:
48 LogStore* log_store() override;
49 std::string GetUploadUrl() const override;
50 base::StringPiece upload_mime_type() const override;
51 MetricsLogUploader::MetricServiceType service_type() const override;
52 void LogActualUploadInterval(base::TimeDelta interval) override;
53 void LogCellularConstraint(bool upload_canceled) override;
54 void LogResponseCode(int response_code) override;
55 void LogSuccess(size_t log_size) override;
56 void LogLargeRejection(size_t log_size) override;
57
58 MetricsLogStore metrics_log_store_;
59
60 DISALLOW_COPY_AND_ASSIGN(MetricsReportingService);
61 };
62
63 } // namespace metrics
64
65 #endif // COMPONENTS_METRICS_METRICS_REPORTING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698