OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 "ppapi/proxy/uma_private_resource.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "ppapi/proxy/ppapi_messages.h" | |
9 #include "ppapi/proxy/resource_message_params.h" | |
10 #include "ppapi/shared_impl/var.h" | |
11 | |
12 namespace { | |
13 | |
14 std::string StringFromPPVar(const PP_Var& var) { | |
15 scoped_refptr<ppapi::StringVar> name_stringvar = | |
16 ppapi::StringVar::FromPPVar(var); | |
17 CHECK(name_stringvar.get()); | |
yzshen1
2014/01/08 00:26:24
Maybe it is sufficient to do if (!...) return std:
elijahtaylor1
2014/01/08 23:59:41
Done.
| |
18 return name_stringvar->value(); | |
19 } | |
20 | |
21 } | |
22 | |
23 namespace ppapi { | |
24 namespace proxy { | |
25 | |
26 UMAPrivateResource::UMAPrivateResource( | |
27 Connection connection, PP_Instance instance) | |
28 : PluginResource(connection, instance) { | |
29 SendCreate(RENDERER, PpapiHostMsg_UMA_Create()); | |
30 } | |
31 | |
32 UMAPrivateResource::~UMAPrivateResource() { | |
33 } | |
34 | |
35 thunk::PPB_UMA_Singleton_API* UMAPrivateResource::AsPPB_UMA_Singleton_API() { | |
36 return this; | |
37 } | |
38 | |
39 void UMAPrivateResource::HistogramCustomTimes( | |
40 PP_Instance instance, | |
41 struct PP_Var name, | |
42 int64_t sample, | |
43 int64_t min, | |
44 int64_t max, | |
45 uint32_t bucket_count) { | |
46 if (name.type != PP_VARTYPE_STRING) | |
47 return; | |
48 | |
49 Post(RENDERER, PpapiHostMsg_UMA_HistogramCustomTimes(StringFromPPVar(name), | |
50 sample, | |
51 min, | |
52 max, | |
53 bucket_count)); | |
54 } | |
55 | |
56 void UMAPrivateResource::HistogramCustomCounts( | |
57 PP_Instance instance, | |
58 struct PP_Var name, | |
59 int32_t sample, | |
60 int32_t min, | |
61 int32_t max, | |
62 uint32_t bucket_count) { | |
63 if (name.type != PP_VARTYPE_STRING) | |
64 return; | |
65 | |
66 Post(RENDERER, PpapiHostMsg_UMA_HistogramCustomCounts(StringFromPPVar(name), | |
67 sample, | |
68 min, | |
69 max, | |
70 bucket_count)); | |
71 } | |
72 | |
73 void UMAPrivateResource::HistogramEnumeration( | |
74 PP_Instance instance, | |
75 struct PP_Var name, | |
76 int32_t sample, | |
77 int32_t boundary_value) { | |
78 if (name.type != PP_VARTYPE_STRING) | |
79 return; | |
80 | |
81 Post(RENDERER, PpapiHostMsg_UMA_HistogramEnumeration(StringFromPPVar(name), | |
82 sample, | |
83 boundary_value)); | |
84 } | |
85 | |
86 } // namespace proxy | |
87 } // namespace ppapi | |
88 | |
OLD | NEW |