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

Side by Side Diff: webkit/plugins/ppapi/ppb_uma_private_impl.cc

Issue 7621054: Don't use a scoped_refptr for StringVar::FromPPVar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_transport_impl.cc ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698