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

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

Issue 6903084: Add UMA private PPAPI interface for UMA logging from NaCl plugin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: addressing brett's feedback Created 9 years, 7 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_uma_private_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(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 #define RETURN_IF_BAD_ARGS(_name, _sample, _min, _max, _bucket_count) \
19 do { \
20 if (_name.type != PP_VARTYPE_STRING || _name.value.as_id == 0) \
21 return; \
22 if (_min >= _max) \
23 return; \
24 if (_bucket_count <= 1) \
25 return; \
26 } while (0)
27
28 void HistogramCustomTimes(PP_Var name,
29 int64_t sample,
30 int64_t min, int64_t max,
31 uint32_t bucket_count) {
32 RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count);
33
34 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
35 base::Histogram* counter =
36 base::Histogram::FactoryTimeGet(
37 name_string->value(),
38 base::TimeDelta::FromMilliseconds(min),
39 base::TimeDelta::FromMilliseconds(max),
40 bucket_count,
41 base::Histogram::kUmaTargetedHistogramFlag);
42 counter->AddTime(base::TimeDelta::FromMilliseconds(sample));
43 }
44
45 void HistogramCustomCounts(PP_Var name,
46 int32_t sample,
47 int32_t min, int32_t max,
48 uint32_t bucket_count) {
49 RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count);
50
51 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
52 base::Histogram* counter =
53 base::Histogram::FactoryGet(
54 name_string->value(),
55 min,
56 max,
57 bucket_count,
58 base::Histogram::kUmaTargetedHistogramFlag);
59 counter->Add(sample);
60 }
61
62 void HistogramEnumeration(PP_Var name,
63 int32_t sample,
64 int32_t boundary_value) {
65 RETURN_IF_BAD_ARGS(name, sample, 1, boundary_value, boundary_value + 1);
66
67 scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
brettw 2011/04/29 22:11:06 You still need to check this pointer for NULL. The
elijahtaylor (use chromium) 2011/04/29 22:27:04 Done.
68 base::Histogram* counter =
69 base::LinearHistogram::FactoryGet(
70 name_string->value(),
71 1,
72 boundary_value,
73 boundary_value + 1,
74 base::Histogram::kUmaTargetedHistogramFlag);
75 counter->Add(sample);
76 }
77
78 } // namespace
79
80 const PPB_UMA_Private ppb_uma = {
81 &HistogramCustomTimes,
82 &HistogramCustomCounts,
83 &HistogramEnumeration,
84 };
85
86 // static
87 const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() {
88 return &ppb_uma;
89 }
90
91 } // namespace ppapi
92 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_uma_private_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698