Bug 722240 - Submit Telemetry only for official builds; r=taras
authorNathan Froyd <froydnj@mozilla.com>
Wed, 01 Feb 2012 23:42:20 -0500
changeset 86520 1c1ad3dcd78251eb6570f5cb9caa9d6ec3f3e5a3
parent 86519 c4799638be1d19f21cba56fb571d78f2293188fe
child 86521 f348905a6403f4e28011905e7f3022b0a497964f
push id5904
push usergpascutto@mozilla.com
push dateThu, 09 Feb 2012 19:26:00 +0000
treeherdermozilla-inbound@1c1ad3dcd782 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstaras
bugs722240
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 722240 - Submit Telemetry only for official builds; r=taras
toolkit/components/telemetry/Makefile.in
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/TelemetryPing.js
toolkit/components/telemetry/nsITelemetry.idl
--- a/toolkit/components/telemetry/Makefile.in
+++ b/toolkit/components/telemetry/Makefile.in
@@ -80,11 +80,15 @@ CPPSRCS = \
 
 EXTRA_DSO_LDOPTS += \
   $(MOZ_COMPONENT_LIBS) \
   $(MOZ_JS_LIBS) \
   $(NULL)
 
 TEST_DIRS += tests
 
+ifdef MOZILLA_OFFICIAL
+DEFINES += -DMOZILLA_OFFICIAL
+endif
+
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/config/rules.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -689,16 +689,26 @@ TelemetryImpl::SetCanRecord(bool canReco
   return NS_OK;
 }
 
 bool
 TelemetryImpl::CanRecord() {
   return !sTelemetry || sTelemetry->mCanRecord;
 }
 
+NS_IMETHODIMP
+TelemetryImpl::GetCanSend(bool *ret) {
+#if defined(MOZILLA_OFFICIAL) && defined(MOZ_TELEMETRY_REPORTING)
+  *ret = true;
+#else
+  *ret = false;
+#endif
+  return NS_OK;
+}
+
 already_AddRefed<nsITelemetry>
 TelemetryImpl::CreateTelemetryInstance()
 {
   NS_ABORT_IF_FALSE(sTelemetry == NULL, "CreateTelemetryInstance may only be called once, via GetService()");
   sTelemetry = new TelemetryImpl(); 
   // AddRef for the local reference
   NS_ADDREF(sTelemetry);
   // AddRef for the caller
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -568,17 +568,20 @@ TelemetryPing.prototype = {
     case "test-ping":
       server = aData;
       // fall through
     case "idle":
       if (this._isIdleObserver) {
         idleService.removeIdleObserver(this, IDLE_TIMEOUT_SECONDS);
         this._isIdleObserver = false;
       }
-      this.send(aTopic == "idle" ? "idle-daily" : aTopic, server);
+      reason = (Telemetry.canSend && aTopic == "idle"
+		? "idle-daily"
+		: "test-ping");
+      this.send(reason, server);
       break;
     }
   },
 
   classID: Components.ID("{55d6a5fa-130e-4ee6-a158-0133af3b86ba}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
 };
 
--- a/toolkit/components/telemetry/nsITelemetry.idl
+++ b/toolkit/components/telemetry/nsITelemetry.idl
@@ -126,9 +126,14 @@ interface nsITelemetry : nsISupports
    */
   [implicit_jscontext]
   jsval getHistogramById(in ACString id);
 
   /**
    * Set this to false to disable gathering of telemetry statistics.
    */
   attribute boolean canRecord;
+
+  /**
+   * A flag indicating whether Telemetry can submit official results.
+   */
+  readonly attribute boolean canSend;
 };