| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" |
| 6 |
| 7 #include "base/metrics/histogram.h" |
| 8 #include "ppapi/c/pp_var.h" |
| 9 #include "ppapi/c/private/ppb_uma_private.h" |
| 10 #include "webkit/glue/webkit_glue.h" |
| 11 #include "webkit/plugins/ppapi/var.h" |
| 12 |
| 13 namespace webkit { |
| 14 namespace ppapi { |
| 15 |
| 16 namespace { |
| 17 |
| 18 void HistogramCustomTimes(PP_Var name, int64_t sample, |
| 19 int64_t min, int64_t max, uint32_t bucket_count) { |
| 20 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); |
| 21 base::Histogram* counter = |
| 22 base::Histogram::FactoryTimeGet(name_string->value(), |
| 23 base::TimeDelta::FromMilliseconds(min), |
| 24 base::TimeDelta::FromMilliseconds(max), |
| 25 bucket_count, |
| 26 base::Histogram::kUmaTargetedHistogramFlag); |
| 27 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); |
| 28 } |
| 29 |
| 30 void HistogramCustomCounts(PP_Var name, int32_t sample, |
| 31 int32_t min, int32_t max, uint32_t bucket_count) { |
| 32 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); |
| 33 base::Histogram* counter = |
| 34 base::Histogram::FactoryGet(name_string->value(),min, max, bucket_count, |
| 35 base::Histogram::kUmaTargetedHistogramFlag); |
| 36 counter->Add(sample); |
| 37 } |
| 38 |
| 39 void HistogramEnumeration(PP_Var name, int32_t sample, int32_t boundary_value) { |
| 40 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); |
| 41 base::Histogram* counter = |
| 42 base::LinearHistogram::FactoryGet(name_string->value(), 1, boundary_value, |
| 43 boundary_value + 1, base::Histogram::kUmaTargetedHistogramFlag); |
| 44 counter->Add(sample); |
| 45 } |
| 46 |
| 47 } // namespace |
| 48 |
| 49 const PPB_UMA_Private ppb_uma = { |
| 50 &HistogramCustomTimes, |
| 51 &HistogramCustomCounts, |
| 52 &HistogramEnumeration, |
| 53 }; |
| 54 |
| 55 // static |
| 56 const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() { |
| 57 return &ppb_uma; |
| 58 } |
| 59 |
| 60 } // namespace ppapi |
| 61 } // namespace webkit |
| OLD | NEW |