summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorelijahtaylor@google.com <elijahtaylor@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-29 23:27:21 +0000
committerelijahtaylor@google.com <elijahtaylor@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-29 23:27:21 +0000
commit2687f11c2bd2c52231571f2f51ea4c60587a66da (patch)
tree5580bbe9a8c48f847713ec552a0faddf84d42478 /webkit
parent9ab907d9ce11a1a6791f9a22cd3a43c47fe4a60e (diff)
downloadchromium_src-2687f11c2bd2c52231571f2f51ea4c60587a66da.zip
chromium_src-2687f11c2bd2c52231571f2f51ea4c60587a66da.tar.gz
chromium_src-2687f11c2bd2c52231571f2f51ea4c60587a66da.tar.bz2
Add UMA private PPAPI interface for UMA logging from NaCl plugin
BUG= none TEST= manual test of ppapi_tests, run UMA tests Review URL: http://codereview.chromium.org/6903084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83622 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rwxr-xr-xwebkit/plugins/ppapi/ppb_uma_private_impl.cc98
-rwxr-xr-xwebkit/plugins/ppapi/ppb_uma_private_impl.h21
4 files changed, 125 insertions, 0 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index a19efdb..1e1bfec 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -287,6 +287,8 @@
'../plugins/ppapi/ppb_scrollbar_impl.h',
'../plugins/ppapi/ppb_surface_3d_impl.cc',
'../plugins/ppapi/ppb_surface_3d_impl.h',
+ '../plugins/ppapi/ppb_uma_private_impl.cc',
+ '../plugins/ppapi/ppb_uma_private_impl.h',
'../plugins/ppapi/ppb_url_loader_impl.cc',
'../plugins/ppapi/ppb_url_loader_impl.h',
'../plugins/ppapi/ppb_url_request_info_impl.cc',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 9073ed0..f22ca92 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -62,6 +62,7 @@
#include "ppapi/c/private/ppb_pdf.h"
#include "ppapi/c/private/ppb_proxy_private.h"
#include "ppapi/c/private/ppb_nacl_private.h"
+#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
@@ -94,6 +95,7 @@
#include "webkit/plugins/ppapi/ppb_proxy_impl.h"
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
#include "webkit/plugins/ppapi/ppb_transport_impl.h"
+#include "webkit/plugins/ppapi/ppb_uma_private_impl.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
@@ -299,6 +301,8 @@ const void* GetInterface(const char* name) {
return PPB_Proxy_Impl::GetInterface();
if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
return PPB_Scrollbar_Impl::GetInterface();
+ if (strcmp(name, PPB_UMA_PRIVATE_INTERFACE) == 0)
+ return PPB_UMA_Private_Impl::GetInterface();
if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0)
return PPB_URLLoader_Impl::GetInterface();
if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppb_uma_private_impl.cc b/webkit/plugins/ppapi/ppb_uma_private_impl.cc
new file mode 100755
index 0000000..f08e1df
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_uma_private_impl.cc
@@ -0,0 +1,98 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/plugins/ppapi/ppb_uma_private_impl.h"
+
+#include "base/metrics/histogram.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/private/ppb_uma_private.h"
+#include "webkit/glue/webkit_glue.h"
+#include "webkit/plugins/ppapi/var.h"
+
+namespace webkit {
+namespace ppapi {
+
+namespace {
+
+#define RETURN_IF_BAD_ARGS(_name, _sample, _min, _max, _bucket_count) \
+ do { \
+ if (_name.type != PP_VARTYPE_STRING || _name.value.as_id == 0) \
+ return; \
+ if (_min >= _max) \
+ return; \
+ if (_bucket_count <= 1) \
+ return; \
+ } while (0)
+
+void HistogramCustomTimes(PP_Var name,
+ int64_t sample,
+ int64_t min, int64_t max,
+ uint32_t bucket_count) {
+ RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count);
+
+ scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
+ if (name_string == NULL)
+ return;
+ base::Histogram* counter =
+ base::Histogram::FactoryTimeGet(
+ name_string->value(),
+ base::TimeDelta::FromMilliseconds(min),
+ base::TimeDelta::FromMilliseconds(max),
+ bucket_count,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ counter->AddTime(base::TimeDelta::FromMilliseconds(sample));
+}
+
+void HistogramCustomCounts(PP_Var name,
+ int32_t sample,
+ int32_t min, int32_t max,
+ uint32_t bucket_count) {
+ RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count);
+
+ scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
+ if (name_string == NULL)
+ return;
+ base::Histogram* counter =
+ base::Histogram::FactoryGet(
+ name_string->value(),
+ min,
+ max,
+ bucket_count,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ counter->Add(sample);
+}
+
+void HistogramEnumeration(PP_Var name,
+ int32_t sample,
+ int32_t boundary_value) {
+ RETURN_IF_BAD_ARGS(name, sample, 1, boundary_value, boundary_value + 1);
+
+ scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
+ if (name_string == NULL)
+ return;
+ base::Histogram* counter =
+ base::LinearHistogram::FactoryGet(
+ name_string->value(),
+ 1,
+ boundary_value,
+ boundary_value + 1,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ counter->Add(sample);
+}
+
+} // namespace
+
+const PPB_UMA_Private ppb_uma = {
+ &HistogramCustomTimes,
+ &HistogramCustomCounts,
+ &HistogramEnumeration,
+};
+
+// static
+const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() {
+ return &ppb_uma;
+}
+
+} // namespace ppapi
+} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_uma_private_impl.h b/webkit/plugins/ppapi/ppb_uma_private_impl.h
new file mode 100755
index 0000000..0088713
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_uma_private_impl.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_UMA_PRIVATE_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_UMA_PRIVATE_IMPL_H_
+
+struct PPB_UMA_Private;
+
+namespace webkit {
+namespace ppapi {
+
+class PPB_UMA_Private_Impl {
+ public:
+ static const PPB_UMA_Private* GetInterface();
+};
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_UMA_PRIVATE_IMPL_H_