1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef METRICSD_UPLOADER_BN_METRICSD_IMPL_H_ 18 #define METRICSD_UPLOADER_BN_METRICSD_IMPL_H_ 19 20 #include "android/brillo/metrics/BnMetricsd.h" 21 #include "uploader/crash_counters.h" 22 23 class BnMetricsdImpl : public android::brillo::metrics::BnMetricsd { 24 public: 25 explicit BnMetricsdImpl(const std::shared_ptr<CrashCounters>& counters); 26 virtual ~BnMetricsdImpl() = default; 27 28 // Records a histogram. 29 android::binder::Status recordHistogram(const android::String16& name, 30 int sample, 31 int min, 32 int max, 33 int nbuckets) override; 34 35 // Records a linear histogram. 36 android::binder::Status recordLinearHistogram(const android::String16& name, 37 int sample, 38 int max) override; 39 40 // Records a sparse histogram. 41 android::binder::Status recordSparseHistogram(const android::String16& name, 42 int sample) override; 43 44 // Records a crash. 45 android::binder::Status recordCrash(const android::String16& type) override; 46 47 // Returns a dump of the histograms aggregated in memory. 48 android::binder::Status getHistogramsDump(android::String16* dump) override; 49 50 private: 51 std::shared_ptr<CrashCounters> counters_; 52 }; 53 54 #endif // METRICSD_UPLOADER_BN_METRICSD_IMPL_H_ 55