Skip to content

Commit

Permalink
Bug 1313326 - Part 1: Support recording events in child processes. r=…
Browse files Browse the repository at this point in the history
…dexter, r=froydnj
  • Loading branch information
georgf committed Feb 14, 2017
1 parent b338abf commit 5094a3a
Show file tree
Hide file tree
Showing 22 changed files with 541 additions and 166 deletions.
6 changes: 4 additions & 2 deletions browser/modules/test/browser_UsageTelemetry_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ add_task(function* test_context_menu() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "contextmenu", null, {engine: "other-MozSearch"}]]);

contextMenu.hidePopup();
Expand Down Expand Up @@ -117,7 +118,8 @@ add_task(function* test_about_newtab() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "about_newtab", "enter", {engine: "other-MozSearch"}]]);

yield BrowserTestUtils.removeTab(tab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ add_task(function* test_abouthome_simpleQuery() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "about_home", "enter", {engine: "other-MozSearch"}]]);

yield BrowserTestUtils.removeTab(tab);
Expand Down
9 changes: 6 additions & 3 deletions browser/modules/test/browser_UsageTelemetry_searchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ add_task(function* test_plainQuery() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "searchbar", "enter", {engine: "other-MozSearch"}]]);

yield BrowserTestUtils.removeTab(tab);
Expand Down Expand Up @@ -141,7 +142,8 @@ add_task(function* test_oneOff() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "searchbar", "oneoff", {engine: "other-MozSearch2"}]]);

yield BrowserTestUtils.removeTab(tab);
Expand Down Expand Up @@ -187,7 +189,8 @@ add_task(function* test_suggestion() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "searchbar", "suggestion", {engine: searchEngineId}]]);

Services.search.currentEngine = previousEngine;
Expand Down
12 changes: 8 additions & 4 deletions browser/modules/test/browser_UsageTelemetry_urlbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ add_task(function* test_simpleQuery() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "urlbar", "enter", {engine: "other-MozSearch"}]]);

// Check the histograms as well.
Expand Down Expand Up @@ -171,7 +172,8 @@ add_task(function* test_searchAlias() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "urlbar", "alias", {engine: "other-MozSearch"}]]);

// Check the histograms as well.
Expand Down Expand Up @@ -219,7 +221,8 @@ add_task(function* test_oneOff() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "urlbar", "oneoff", {engine: "other-MozSearch"}]]);

// Check the histograms as well.
Expand Down Expand Up @@ -279,7 +282,8 @@ add_task(function* test_suggestion() {

// Also check events.
let events = Services.telemetry.snapshotBuiltinEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
events = events.filter(e => e[1] == "navigation" && e[2] == "search");
Assert.ok("default" in events, "We should have recorded events in the parent process.");
events = events.default.filter(e => e[1] == "navigation" && e[2] == "search");
checkEvents(events, [["navigation", "search", "urlbar", "suggestion", {engine: searchEngineId}]]);

// Check the histograms as well.
Expand Down
7 changes: 7 additions & 0 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5078,6 +5078,13 @@ ContentParent::RecvUpdateChildKeyedScalars(
return IPC_OK();
}

mozilla::ipc::IPCResult
ContentParent::RecvRecordChildEvents(nsTArray<mozilla::Telemetry::ChildEventData>&& aEvents)
{
TelemetryIPC::RecordChildEvents(GeckoProcessType_Content, aEvents);
return IPC_OK();
}

PURLClassifierParent*
ContentParent::AllocPURLClassifierParent(const Principal& aPrincipal,
const bool& aUseTrackingProtection,
Expand Down
2 changes: 2 additions & 0 deletions dom/ipc/ContentParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,8 @@ class ContentParent final : public PContentParent
InfallibleTArray<ScalarAction>&& aScalarActions) override;
virtual mozilla::ipc::IPCResult RecvUpdateChildKeyedScalars(
InfallibleTArray<KeyedScalarAction>&& aScalarActions) override;
virtual mozilla::ipc::IPCResult RecvRecordChildEvents(
nsTArray<ChildEventData>&& events) override;
public:
void SendGetFilesResponseAndForget(const nsID& aID,
const GetFilesResponseResult& aResult);
Expand Down
2 changes: 2 additions & 0 deletions dom/ipc/PContent.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";

union ChromeRegistryItem
{
Expand Down Expand Up @@ -1198,6 +1199,7 @@ parent:
async AccumulateChildKeyedHistograms(KeyedAccumulation[] accumulations);
async UpdateChildScalars(ScalarAction[] updates);
async UpdateChildKeyedScalars(KeyedScalarAction[] updates);
async RecordChildEvents(ChildEventData[] events);

sync GetA11yContentId() returns (uint32_t aContentId);

Expand Down
7 changes: 7 additions & 0 deletions gfx/ipc/GPUChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ GPUChild::RecvUpdateChildKeyedScalars(InfallibleTArray<KeyedScalarAction>&& aSca
return IPC_OK();
}

mozilla::ipc::IPCResult
GPUChild::RecvRecordChildEvents(nsTArray<mozilla::Telemetry::ChildEventData>&& aEvents)
{
TelemetryIPC::RecordChildEvents(GeckoProcessType_GPU, aEvents);
return IPC_OK();
}

mozilla::ipc::IPCResult
GPUChild::RecvNotifyDeviceReset()
{
Expand Down
3 changes: 3 additions & 0 deletions gfx/ipc/GPUChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ class GPUChild final
mozilla::ipc::IPCResult RecvInitComplete(const GPUDeviceData& aData) override;
mozilla::ipc::IPCResult RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog) override;
mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override;

mozilla::ipc::IPCResult RecvAccumulateChildHistograms(InfallibleTArray<Accumulation>&& aAccumulations) override;
mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistograms(InfallibleTArray<KeyedAccumulation>&& aAccumulations) override;
mozilla::ipc::IPCResult RecvUpdateChildScalars(InfallibleTArray<ScalarAction>&& aScalarActions) override;
mozilla::ipc::IPCResult RecvUpdateChildKeyedScalars(InfallibleTArray<KeyedScalarAction>&& aScalarActions) override;
mozilla::ipc::IPCResult RecvRecordChildEvents(nsTArray<ChildEventData>&& events) override;

void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
mozilla::ipc::IPCResult RecvNotifyUiObservers(const nsCString& aTopic) override;
Expand Down
2 changes: 2 additions & 0 deletions gfx/ipc/PGPU.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";

namespace mozilla {
namespace gfx {
Expand Down Expand Up @@ -114,6 +115,7 @@ child:
async AccumulateChildKeyedHistograms(KeyedAccumulation[] accumulations);
async UpdateChildScalars(ScalarAction[] actions);
async UpdateChildKeyedScalars(KeyedScalarAction[] actions);
async RecordChildEvents(ChildEventData[] events);

async NotifyDeviceReset();

Expand Down
1 change: 1 addition & 0 deletions toolkit/components/telemetry/Telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct Accumulation;
struct KeyedAccumulation;
struct ScalarAction;
struct KeyedScalarAction;
struct ChildEventData;

enum TimerResolution {
Millisecond,
Expand Down
Loading

0 comments on commit 5094a3a

Please sign in to comment.