From 4f9e57bfe013c38c2adadc15632f08a775d9684d Mon Sep 17 00:00:00 2001 From: Taras Glek Date: Mon, 1 Aug 2011 13:17:47 -0700 Subject: [PATCH] Bug 674767: Use double conversion macros for jsvals, squash windows double r=glandium --- toolkit/components/telemetry/Telemetry.cpp | 2 +- toolkit/components/telemetry/Telemetry.h | 2 +- toolkit/components/telemetry/tests/unit/test_nsITelemetry.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 69f09b1c646..2bfe11c6c92 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -177,7 +177,7 @@ ReflectHistogramSnapshot(JSContext *cx, JSObject *obj, Histogram *h) if (!(JS_DefineProperty(cx, obj, "min", INT_TO_JSVAL(h->declared_min()), NULL, NULL, JSPROP_ENUMERATE) && JS_DefineProperty(cx, obj, "max", INT_TO_JSVAL(h->declared_max()), NULL, NULL, JSPROP_ENUMERATE) && JS_DefineProperty(cx, obj, "histogram_type", INT_TO_JSVAL(h->histogram_type()), NULL, NULL, JSPROP_ENUMERATE) - && JS_DefineProperty(cx, obj, "sum", INT_TO_JSVAL(ss.sum()), NULL, NULL, JSPROP_ENUMERATE) + && JS_DefineProperty(cx, obj, "sum", DOUBLE_TO_JSVAL(ss.sum()), NULL, NULL, JSPROP_ENUMERATE) && (rarray = JS_NewArrayObject(cx, count, NULL)) && JS_DefineProperty(cx, obj, "ranges", OBJECT_TO_JSVAL(rarray), NULL, NULL, JSPROP_ENUMERATE) && FillRanges(cx, rarray, h) diff --git a/toolkit/components/telemetry/Telemetry.h b/toolkit/components/telemetry/Telemetry.h index 102d439d854..79231bacbb8 100644 --- a/toolkit/components/telemetry/Telemetry.h +++ b/toolkit/components/telemetry/Telemetry.h @@ -72,7 +72,7 @@ public: } ~AutoTimer() { - Accumulate(id, (TimeStamp::Now() - start).ToMilliseconds()); + Accumulate(id, static_cast((TimeStamp::Now() - start).ToMilliseconds())); } private: diff --git a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js index de27dcf4ab8..f0485dd07da 100644 --- a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js +++ b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js @@ -4,6 +4,7 @@ const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; +const INT_MAX = 0x7FFFFFFF; const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry); Cu.import("resource://gre/modules/Services.jsm"); @@ -106,7 +107,7 @@ function run_test() { let kinds = [Telemetry.HISTOGRAM_EXPONENTIAL, Telemetry.HISTOGRAM_LINEAR] for each (let histogram_type in kinds) { - let [min, max, bucket_count] = [1, 10000, 10] + let [min, max, bucket_count] = [1, INT_MAX - 1, 10] test_histogram(histogram_type, "test::"+histogram_type, min, max, bucket_count); const nh = Telemetry.newHistogram;