OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
9 #include "ppapi/c/private/ppb_uma_private.h" | 9 #include "ppapi/c/private/ppb_uma_private.h" |
10 #include "ppapi/shared_impl/var.h" | 10 #include "ppapi/shared_impl/var.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (_bucket_count <= 1) \ | 26 if (_bucket_count <= 1) \ |
27 return; \ | 27 return; \ |
28 } while (0) | 28 } while (0) |
29 | 29 |
30 void HistogramCustomTimes(PP_Var name, | 30 void HistogramCustomTimes(PP_Var name, |
31 int64_t sample, | 31 int64_t sample, |
32 int64_t min, int64_t max, | 32 int64_t min, int64_t max, |
33 uint32_t bucket_count) { | 33 uint32_t bucket_count) { |
34 RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count); | 34 RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count); |
35 | 35 |
36 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); | 36 StringVar* name_string = StringVar::FromPPVar(name); |
37 if (name_string == NULL) | 37 if (name_string == NULL) |
38 return; | 38 return; |
39 base::Histogram* counter = | 39 base::Histogram* counter = |
40 base::Histogram::FactoryTimeGet( | 40 base::Histogram::FactoryTimeGet( |
41 name_string->value(), | 41 name_string->value(), |
42 base::TimeDelta::FromMilliseconds(min), | 42 base::TimeDelta::FromMilliseconds(min), |
43 base::TimeDelta::FromMilliseconds(max), | 43 base::TimeDelta::FromMilliseconds(max), |
44 bucket_count, | 44 bucket_count, |
45 base::Histogram::kUmaTargetedHistogramFlag); | 45 base::Histogram::kUmaTargetedHistogramFlag); |
46 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); | 46 counter->AddTime(base::TimeDelta::FromMilliseconds(sample)); |
47 } | 47 } |
48 | 48 |
49 void HistogramCustomCounts(PP_Var name, | 49 void HistogramCustomCounts(PP_Var name, |
50 int32_t sample, | 50 int32_t sample, |
51 int32_t min, int32_t max, | 51 int32_t min, int32_t max, |
52 uint32_t bucket_count) { | 52 uint32_t bucket_count) { |
53 RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count); | 53 RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count); |
54 | 54 |
55 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); | 55 StringVar* name_string = StringVar::FromPPVar(name); |
56 if (name_string == NULL) | 56 if (name_string == NULL) |
57 return; | 57 return; |
58 base::Histogram* counter = | 58 base::Histogram* counter = |
59 base::Histogram::FactoryGet( | 59 base::Histogram::FactoryGet( |
60 name_string->value(), | 60 name_string->value(), |
61 min, | 61 min, |
62 max, | 62 max, |
63 bucket_count, | 63 bucket_count, |
64 base::Histogram::kUmaTargetedHistogramFlag); | 64 base::Histogram::kUmaTargetedHistogramFlag); |
65 counter->Add(sample); | 65 counter->Add(sample); |
66 } | 66 } |
67 | 67 |
68 void HistogramEnumeration(PP_Var name, | 68 void HistogramEnumeration(PP_Var name, |
69 int32_t sample, | 69 int32_t sample, |
70 int32_t boundary_value) { | 70 int32_t boundary_value) { |
71 RETURN_IF_BAD_ARGS(name, sample, 1, boundary_value, boundary_value + 1); | 71 RETURN_IF_BAD_ARGS(name, sample, 1, boundary_value, boundary_value + 1); |
72 | 72 |
73 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name)); | 73 StringVar* name_string = StringVar::FromPPVar(name); |
74 if (name_string == NULL) | 74 if (name_string == NULL) |
75 return; | 75 return; |
76 base::Histogram* counter = | 76 base::Histogram* counter = |
77 base::LinearHistogram::FactoryGet( | 77 base::LinearHistogram::FactoryGet( |
78 name_string->value(), | 78 name_string->value(), |
79 1, | 79 1, |
80 boundary_value, | 80 boundary_value, |
81 boundary_value + 1, | 81 boundary_value + 1, |
82 base::Histogram::kUmaTargetedHistogramFlag); | 82 base::Histogram::kUmaTargetedHistogramFlag); |
83 counter->Add(sample); | 83 counter->Add(sample); |
84 } | 84 } |
85 | 85 |
86 } // namespace | 86 } // namespace |
87 | 87 |
88 const PPB_UMA_Private ppb_uma = { | 88 const PPB_UMA_Private ppb_uma = { |
89 &HistogramCustomTimes, | 89 &HistogramCustomTimes, |
90 &HistogramCustomCounts, | 90 &HistogramCustomCounts, |
91 &HistogramEnumeration, | 91 &HistogramEnumeration, |
92 }; | 92 }; |
93 | 93 |
94 // static | 94 // static |
95 const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() { | 95 const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() { |
96 return &ppb_uma; | 96 return &ppb_uma; |
97 } | 97 } |
98 | 98 |
99 } // namespace ppapi | 99 } // namespace ppapi |
100 } // namespace webkit | 100 } // namespace webkit |
OLD | NEW |