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

Unified 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: formatting Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppb_uma_private_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_uma_private_impl.cc (revision 0)
+++ webkit/plugins/ppapi/ppb_uma_private_impl.cc (revision 0)
@@ -0,0 +1,67 @@
+// 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 {
+
+void HistogramCustomTimes(PP_Var name,
+ int64_t sample,
+ int64_t min, int64_t max,
+ uint32_t bucket_count) {
+ scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
brettw 2011/04/29 21:05:05 You should NULL check these values (same below) in
elijahtaylor (use chromium) 2011/04/29 21:52:08 I noticed other badness that could happen with inv
+ 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) {
+ scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
+ 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) {
+ scoped_refptr<StringVar> name_string(StringVar::FromPPVar(name));
+ base::Histogram* counter =
+ base::LinearHistogram::FactoryGet(name_string->value(), 1, boundary_value,
brettw 2011/04/29 21:05:05 This should use 4-space indents (same above).
elijahtaylor (use chromium) 2011/04/29 21:52:08 Done.
+ 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
Property changes on: webkit/plugins/ppapi/ppb_uma_private_impl.cc
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
« ppapi/c/private/ppb_uma_private.h ('K') | « 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