Chromium Code Reviews
|
| 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, | |
| 19 int64_t sample, | |
| 20 int64_t min, int64_t max, | |
| 21 uint32_t bucket_count) { | |
| 22 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); | |
|
brettw
2011/04/29 21:05:05
You should NULL check these values (same below) in
elijahtaylor (use chromium)
2011/04/29 21:52:08
I noticed other badness that could happen with inv
| |
| 23 base::Histogram* counter = | |
| 24 base::Histogram::FactoryTimeGet(name_string->value(), | |
| 25 base::TimeDelta::FromMilliseconds(min), | |
| 26 base::TimeDelta::FromMilliseconds(max), | |
| 27 bucket_count, | |
| 28 base::Histogram::kUmaTargetedHistogramFlag); | |
| 29 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); | |
| 30 } | |
| 31 | |
| 32 void HistogramCustomCounts(PP_Var name, | |
| 33 int32_t sample, | |
| 34 int32_t min, int32_t max, | |
| 35 uint32_t bucket_count) { | |
| 36 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); | |
| 37 base::Histogram* counter = | |
| 38 base::Histogram::FactoryGet(name_string->value(),min, max, bucket_count, | |
| 39 base::Histogram::kUmaTargetedHistogramFlag); | |
| 40 counter->Add(sample); | |
| 41 } | |
| 42 | |
| 43 void HistogramEnumeration(PP_Var name, | |
| 44 int32_t sample, | |
| 45 int32_t boundary_value) { | |
| 46 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); | |
| 47 base::Histogram* counter = | |
| 48 base::LinearHistogram::FactoryGet(name_string->value(), 1, boundary_value, | |
|
brettw
2011/04/29 21:05:05
This should use 4-space indents (same above).
elijahtaylor (use chromium)
2011/04/29 21:52:08
Done.
| |
| 49 boundary_value + 1, base::Histogram::kUmaTargetedHistogramFlag); | |
| 50 counter->Add(sample); | |
| 51 } | |
| 52 | |
| 53 } // namespace | |
| 54 | |
| 55 const PPB_UMA_Private ppb_uma = { | |
| 56 &HistogramCustomTimes, | |
| 57 &HistogramCustomCounts, | |
| 58 &HistogramEnumeration, | |
| 59 }; | |
| 60 | |
| 61 // static | |
| 62 const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() { | |
| 63 return &ppb_uma; | |
| 64 } | |
| 65 | |
| 66 } // namespace ppapi | |
| 67 } // namespace webkit | |
| OLD | NEW |