Skip to content

Commit

Permalink
bug 1410907 - Add CanRecord(Pre)Release data to nsITTelemetry r=Dexter
Browse files Browse the repository at this point in the history
We're starting a shift towards talking about release/prerelease data instead of
base/extended collection. For now this is just a naming change.

At the same time, we can render these attributes read-only, which is nice.

MozReview-Commit-ID: IRuKpzLYW7i
  • Loading branch information
chutten committed Nov 3, 2017
1 parent 59f951e commit d401004
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
37 changes: 37 additions & 0 deletions toolkit/components/telemetry/Telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class TelemetryImpl final
const bool success);
static bool CanRecordBase();
static bool CanRecordExtended();
static bool CanRecordReleaseData();
static bool CanRecordPrereleaseData();
private:
TelemetryImpl();
~TelemetryImpl();
Expand Down Expand Up @@ -1174,6 +1176,17 @@ TelemetryImpl::SetCanRecordExtended(bool canRecord) {
return NS_OK;
}

NS_IMETHODIMP
TelemetryImpl::GetCanRecordReleaseData(bool* ret) {
*ret = mCanRecordBase;
return NS_OK;
}

NS_IMETHODIMP
TelemetryImpl::GetCanRecordPrereleaseData(bool* ret) {
*ret = mCanRecordExtended;
return NS_OK;
}

NS_IMETHODIMP
TelemetryImpl::GetIsOfficialTelemetry(bool *ret) {
Expand Down Expand Up @@ -1568,6 +1581,18 @@ TelemetryImpl::CanRecordExtended()
return NS_SUCCEEDED(rv) && canRecordExtended;
}

bool
TelemetryImpl::CanRecordReleaseData()
{
return CanRecordBase();
}

bool
TelemetryImpl::CanRecordPrereleaseData()
{
return CanRecordExtended();
}

NS_IMPL_ISUPPORTS(TelemetryImpl, nsITelemetry, nsIMemoryReporter)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITelemetry, TelemetryImpl::CreateTelemetryInstance)

Expand Down Expand Up @@ -1954,6 +1979,18 @@ CanRecordExtended()
return TelemetryImpl::CanRecordExtended();
}

bool
CanRecordReleaseData()
{
return TelemetryImpl::CanRecordReleaseData();
}

bool
CanRecordPrereleaseData()
{
return TelemetryImpl::CanRecordPrereleaseData();
}

void
RecordSlowSQLStatement(const nsACString &statement,
const nsACString &dbName,
Expand Down
15 changes: 15 additions & 0 deletions toolkit/components/telemetry/Telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,21 @@ bool CanRecordBase();
*/
bool CanRecordExtended();

/**
* Indicates whether Telemetry release data recording is turned on. Usually true.
*
* @see nsITelemetry.canRecordReleaseData
*/
bool CanRecordReleaseData();

/**
* Indicates whether Telemetry pre-release data recording is turned on. Tends
* to be true on pre-release channels.
*
* @see nsITelemetry.canRecordPrereleaseData
*/
bool CanRecordPrereleaseData();

/**
* Records slow SQL statements for Telemetry reporting.
*
Expand Down
28 changes: 28 additions & 0 deletions toolkit/components/telemetry/nsITelemetry.idl
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,34 @@ interface nsITelemetry : nsISupports
*/
attribute boolean canRecordExtended;

/**
* A flag indicating whether Telemetry is recording release data, which is a
* smallish subset of our usage data that we're prepared to handle from our
* largish release population.
*
* This is true most of the time.
*
* This does not indicate whether Telemetry will send any data. That is
* governed by user preference and other mechanisms.
*
* You may use this to determine if it's okay to record your data.
*/
readonly attribute boolean canRecordReleaseData;

/**
* A flag indicating whether Telemetry is recording prerelease data, which is
* a largish amount of usage data that we're prepared to handle from our
* smallish pre-release population.
*
* This is true on pre-release branches of Firefox.
*
* This does not indicate whether Telemetry will send any data. That is
* governed by user preference and other mechanisms.
*
* You may use this to determine if it's okay to record your data.
*/
readonly attribute boolean canRecordPrereleaseData;

/**
* A flag indicating whether Telemetry can submit official results (for base or extended
* data). This is true on official, non-debug builds with built in support for Mozilla
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,13 @@ add_task(async function test_pingRejection() {
() => Assert.ok(true, "Ping submitted after shutdown correctly rejected."));
});

add_task(async function test_newCanRecordsMatchTheOld() {
Assert.equal(Telemetry.canRecordBase, Telemetry.canRecordReleaseData,
"Release Data is the new way to say Base Collection");
Assert.equal(Telemetry.canRecordExtended, Telemetry.canRecordPrereleaseData,
"Prerelease Data is the new way to say Extended Collection");
});

add_task(async function stopServer() {
await PingServer.stop();
});

0 comments on commit d401004

Please sign in to comment.