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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/ukm_reporting_service.h
diff --git a/components/ukm/ukm_reporting_service.h b/components/ukm/ukm_reporting_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..d0af0cc91a5c1c3edd3e390569676b4977dfa41b
--- /dev/null
+++ b/components/ukm/ukm_reporting_service.h
@@ -0,0 +1,65 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file defines a service that sends ukm logs to a server.
+
+#ifndef COMPONENTS_UKM_UKM_REPORTING_SERVICE_H_
+#define COMPONENTS_UKM_UKM_REPORTING_SERVICE_H_
+
+#include <stdint.h>
+
+#include <string>
+
+#include "base/macros.h"
+#include "components/metrics/persisted_logs.h"
+#include "components/metrics/reporting_service.h"
+
+class PrefService;
+class PrefRegistrySimple;
+
+namespace metrics {
+class MetricsServiceClient;
+}
+
+namespace ukm {
+
+// A service that uploads logs to the UKM server.
+class UkmReportingService : public metrics::ReportingService {
+ public:
+ // Creates the UkmReportingService with the given |client|, and
+ // |local_state|. Does not take ownership of the paramaters; instead stores
+ // a weak pointer to each. Caller should ensure that the parameters are valid
+ // for the lifetime of this class.
+ UkmReportingService(metrics::MetricsServiceClient* client,
+ PrefService* local_state);
+ ~UkmReportingService() override;
+
+ // At startup, prefs needs to be called with a list of all the pref names and
+ // types we'll be using.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ metrics::PersistedLogs* ukm_log_store() { return &persisted_logs_; }
+ const metrics::PersistedLogs* ukm_log_store() const {
+ return &persisted_logs_;
+ }
+
+ private:
+ // metrics:ReportingService:
+ metrics::LogStore* log_store() override;
+ std::string GetUploadUrl() const override;
+ base::StringPiece upload_mime_type() const override;
+ metrics::MetricsLogUploader::MetricServiceType service_type() const override;
+ void LogCellularConstraint(bool upload_canceled) override;
+ void LogResponseCode(int response_code) override;
+ void LogSuccess(size_t log_size) override;
+ void LogLargeRejection(size_t log_size) override;
+
+ metrics::PersistedLogs persisted_logs_;
+
+ DISALLOW_COPY_AND_ASSIGN(UkmReportingService);
+};
+
+} // namespace ukm
+
+#endif // COMPONENTS_UKM_UKM_REPORTING_SERVICE_H_
« 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