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

Side by Side Diff: components/ukm/ukm_reporting_service.h

Issue 2770853002: Create Ukm ReportingService implementation. (Closed)
Patch Set: Also revert datatracker unittest change 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
« no previous file with comments | « components/ukm/metrics_reporting_scheduler.cc ('k') | components/ukm/ukm_reporting_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ukm logs to a server.
6
7 #ifndef COMPONENTS_UKM_UKM_REPORTING_SERVICE_H_
8 #define COMPONENTS_UKM_UKM_REPORTING_SERVICE_H_
9
10 #include <stdint.h>
11
12 #include <string>
13
14 #include "base/macros.h"
15 #include "components/metrics/persisted_logs.h"
16 #include "components/metrics/reporting_service.h"
17
18 class PrefService;
19 class PrefRegistrySimple;
20
21 namespace metrics {
22 class MetricsServiceClient;
23 }
24
25 namespace ukm {
26
27 // A service that uploads logs to the UKM server.
28 class UkmReportingService : public metrics::ReportingService {
29 public:
30 // Creates the UkmReportingService with the given |client|, and
31 // |local_state|. Does not take ownership of the paramaters; instead stores
32 // a weak pointer to each. Caller should ensure that the parameters are valid
33 // for the lifetime of this class.
34 UkmReportingService(metrics::MetricsServiceClient* client,
35 PrefService* local_state);
36 ~UkmReportingService() override;
37
38 // At startup, prefs needs to be called with a list of all the pref names and
39 // types we'll be using.
40 static void RegisterPrefs(PrefRegistrySimple* registry);
41
42 metrics::PersistedLogs* ukm_log_store() { return &persisted_logs_; }
43 const metrics::PersistedLogs* ukm_log_store() const {
44 return &persisted_logs_;
45 }
46
47 private:
48 // metrics:ReportingService:
49 metrics::LogStore* log_store() override;
50 std::string GetUploadUrl() const override;
51 base::StringPiece upload_mime_type() const override;
52 metrics::MetricsLogUploader::MetricServiceType service_type() const 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 metrics::PersistedLogs persisted_logs_;
59
60 DISALLOW_COPY_AND_ASSIGN(UkmReportingService);
61 };
62
63 } // namespace ukm
64
65 #endif // COMPONENTS_UKM_UKM_REPORTING_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ukm/metrics_reporting_scheduler.cc ('k') | components/ukm/ukm_reporting_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698