Bug 1361661 - Part 2: Make Telemetry IPC code pass around Telemetry::ProcessID. r=dexter
☠☠ backed out by 69c42b4e8877 ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Mon, 22 May 2017 15:40:58 +0700
changeset 359995 9cf5185e6d6fd15b1dd35b1552317ebd5ff258ed
parent 359994 78e8b1f01c25b51564815772c4fa869cb38755b0
child 359996 d1932fb366d4689298ff3811e83fc7c8133899f2
push id31866
push userkwierso@gmail.com
push dateMon, 22 May 2017 23:26:23 +0000
treeherdermozilla-central@5bc1c758ab57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdexter
bugs1361661
milestone55.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 1361661 - Part 2: Make Telemetry IPC code pass around Telemetry::ProcessID. r=dexter Switching to Telemetry::ProcessID allows us to break out extension process data from the content process data.
dom/ipc/ContentParent.cpp
gfx/ipc/GPUChild.cpp
toolkit/components/telemetry/ipc/TelemetryIPC.cpp
toolkit/components/telemetry/ipc/TelemetryIPC.h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -281,16 +281,17 @@ using namespace mozilla::ipc;
 using namespace mozilla::intl;
 using namespace mozilla::layers;
 using namespace mozilla::layout;
 using namespace mozilla::net;
 using namespace mozilla::jsipc;
 using namespace mozilla::psm;
 using namespace mozilla::widget;
 using mozilla::loader::PScriptCacheParent;
+using mozilla::Telemetry::ProcessID;
 
 // XXX Workaround for bug 986973 to maintain the existing broken semantics
 template<>
 struct nsIConsoleService::COMTypeInfo<nsConsoleService, void> {
   static const nsIID kIID;
 };
 const nsIID nsIConsoleService::COMTypeInfo<nsConsoleService, void>::kIID = NS_ICONSOLESERVICE_IID;
 
@@ -528,16 +529,26 @@ ScriptableCPInfo::GetMessageManager(nsIM
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   nsCOMPtr<nsIMessageSender> manager = mContentParent->GetMessageManager();
   manager.forget(aMessenger);
   return NS_OK;
 }
 
+ProcessID
+GetTelemetryProcessID(const nsAString& remoteType)
+{
+  // OOP WebExtensions run in a content process.
+  // For Telemetry though we want to break out collected data from the WebExtensions process into
+  // a separate bucket, to make sure we can analyze it separately and avoid skewing normal content
+  // process metrics.
+  return remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE) ? ProcessID::Extension : ProcessID::Content;
+}
+
 } // anonymous namespace
 
 nsTArray<ContentParent*>* ContentParent::sPrivateContent;
 StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
 UniquePtr<SandboxBrokerPolicyFactory> ContentParent::sSandboxBrokerPolicyFactory;
 #endif
 uint64_t ContentParent::sNextTabParentId = 0;
@@ -5121,48 +5132,48 @@ ContentParent::NeedsPermissionsUpdate(co
 {
   return mActivePermissionKeys.Contains(aPermissionKey);
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvAccumulateChildHistograms(
                 InfallibleTArray<Accumulation>&& aAccumulations)
 {
-  TelemetryIPC::AccumulateChildHistograms(GeckoProcessType_Content, aAccumulations);
+  TelemetryIPC::AccumulateChildHistograms(GetTelemetryProcessID(mRemoteType), aAccumulations);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvAccumulateChildKeyedHistograms(
                 InfallibleTArray<KeyedAccumulation>&& aAccumulations)
 {
-  TelemetryIPC::AccumulateChildKeyedHistograms(GeckoProcessType_Content, aAccumulations);
+  TelemetryIPC::AccumulateChildKeyedHistograms(GetTelemetryProcessID(mRemoteType), aAccumulations);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvUpdateChildScalars(
                 InfallibleTArray<ScalarAction>&& aScalarActions)
 {
-  TelemetryIPC::UpdateChildScalars(GeckoProcessType_Content, aScalarActions);
+  TelemetryIPC::UpdateChildScalars(GetTelemetryProcessID(mRemoteType), aScalarActions);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvUpdateChildKeyedScalars(
                 InfallibleTArray<KeyedScalarAction>&& aScalarActions)
 {
-  TelemetryIPC::UpdateChildKeyedScalars(GeckoProcessType_Content, aScalarActions);
+  TelemetryIPC::UpdateChildKeyedScalars(GetTelemetryProcessID(mRemoteType), aScalarActions);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvRecordChildEvents(nsTArray<mozilla::Telemetry::ChildEventData>&& aEvents)
 {
-  TelemetryIPC::RecordChildEvents(GeckoProcessType_Content, aEvents);
+  TelemetryIPC::RecordChildEvents(GetTelemetryProcessID(mRemoteType), aEvents);
   return IPC_OK();
 }
 
 //////////////////////////////////////////////////////////////////
 // PURLClassifierParent
 
 PURLClassifierParent*
 ContentParent::AllocPURLClassifierParent(const Principal& aPrincipal,
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -160,45 +160,45 @@ GPUChild::RecvNotifyUiObservers(const ns
     obsSvc->NotifyObservers(nullptr, aTopic.get(), nullptr);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvAccumulateChildHistograms(InfallibleTArray<Accumulation>&& aAccumulations)
 {
-  TelemetryIPC::AccumulateChildHistograms(GeckoProcessType_GPU, aAccumulations);
+  TelemetryIPC::AccumulateChildHistograms(Telemetry::ProcessID::Gpu, aAccumulations);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvAccumulateChildKeyedHistograms(InfallibleTArray<KeyedAccumulation>&& aAccumulations)
 {
-  TelemetryIPC::AccumulateChildKeyedHistograms(GeckoProcessType_GPU, aAccumulations);
+  TelemetryIPC::AccumulateChildKeyedHistograms(Telemetry::ProcessID::Gpu, aAccumulations);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvUpdateChildScalars(InfallibleTArray<ScalarAction>&& aScalarActions)
 {
-  TelemetryIPC::UpdateChildScalars(GeckoProcessType_GPU, aScalarActions);
+  TelemetryIPC::UpdateChildScalars(Telemetry::ProcessID::Gpu, aScalarActions);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvUpdateChildKeyedScalars(InfallibleTArray<KeyedScalarAction>&& aScalarActions)
 {
-  TelemetryIPC::UpdateChildKeyedScalars(GeckoProcessType_GPU, aScalarActions);
+  TelemetryIPC::UpdateChildKeyedScalars(Telemetry::ProcessID::Gpu, aScalarActions);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvRecordChildEvents(nsTArray<mozilla::Telemetry::ChildEventData>&& aEvents)
 {
-  TelemetryIPC::RecordChildEvents(GeckoProcessType_GPU, aEvents);
+  TelemetryIPC::RecordChildEvents(Telemetry::ProcessID::Gpu, aEvents);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvNotifyDeviceReset(const GPUDeviceData& aData)
 {
   gfxPlatform::GetPlatform()->ImportGPUDeviceData(aData);
   mHost->mListener->OnProcessDeviceReset(mHost);
--- a/toolkit/components/telemetry/ipc/TelemetryIPC.cpp
+++ b/toolkit/components/telemetry/ipc/TelemetryIPC.cpp
@@ -7,42 +7,42 @@
 #include "TelemetryIPC.h"
 #include "../TelemetryScalar.h"
 #include "../TelemetryHistogram.h"
 #include "../TelemetryEvent.h"
 
 namespace mozilla {
 
 void
-TelemetryIPC::AccumulateChildHistograms(GeckoProcessType aProcessType,
+TelemetryIPC::AccumulateChildHistograms(Telemetry::ProcessID aProcessType,
                                         const nsTArray<Telemetry::Accumulation>& aAccumulations)
 {
   TelemetryHistogram::AccumulateChild(aProcessType, aAccumulations);
 }
 
 void
-TelemetryIPC::AccumulateChildKeyedHistograms(GeckoProcessType aProcessType,
+TelemetryIPC::AccumulateChildKeyedHistograms(Telemetry::ProcessID aProcessType,
                                             const nsTArray<Telemetry::KeyedAccumulation>& aAccumulations)
 {
   TelemetryHistogram::AccumulateChildKeyed(aProcessType, aAccumulations);
 }
 
 void
-TelemetryIPC::UpdateChildScalars(GeckoProcessType aProcessType,
+TelemetryIPC::UpdateChildScalars(Telemetry::ProcessID aProcessType,
                                  const nsTArray<Telemetry::ScalarAction>& aScalarActions)
 {
   TelemetryScalar::UpdateChildData(aProcessType, aScalarActions);
 }
 
 void
-TelemetryIPC::UpdateChildKeyedScalars(GeckoProcessType aProcessType,
+TelemetryIPC::UpdateChildKeyedScalars(Telemetry::ProcessID aProcessType,
                                       const nsTArray<Telemetry::KeyedScalarAction>& aScalarActions)
 {
   TelemetryScalar::UpdateChildKeyedData(aProcessType, aScalarActions);
 }
 
 void
-TelemetryIPC::RecordChildEvents(GeckoProcessType aProcessType, const nsTArray<Telemetry::ChildEventData>& aEvents)
+TelemetryIPC::RecordChildEvents(Telemetry::ProcessID aProcessType, const nsTArray<Telemetry::ChildEventData>& aEvents)
 {
   TelemetryEvent::RecordChildEvents(aProcessType, aEvents);
 }
 
 }
--- a/toolkit/components/telemetry/ipc/TelemetryIPC.h
+++ b/toolkit/components/telemetry/ipc/TelemetryIPC.h
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TelemetryIPC_h__
 #define TelemetryIPC_h__
 
 #include "nsTArray.h"
 #include "nsXULAppAPI.h"
+#include "mozilla/TelemetryProcessEnums.h"
 
 // This module provides the interface to accumulate Telemetry from child processes.
 // Top-level actors for different child processes types (ContentParent, GPUChild)
 // will call this for messages from their respective processes.
 
 namespace mozilla {
 namespace Telemetry {
 
@@ -27,46 +28,51 @@ struct ChildEventData;
 namespace TelemetryIPC {
 
 /**
  * Accumulate child process data into histograms for the given process type.
  *
  * @param aProcessType - the process type to accumulate the histograms for
  * @param aAccumulations - accumulation actions to perform
  */
-void AccumulateChildHistograms(GeckoProcessType aProcessType, const nsTArray<Telemetry::Accumulation>& aAccumulations);
+void AccumulateChildHistograms(Telemetry::ProcessID aProcessType,
+                               const nsTArray<Telemetry::Accumulation>& aAccumulations);
 
 /**
  * Accumulate child process data into keyed histograms for the given process type.
  *
  * @param aProcessType - the process type to accumulate the keyed histograms for
  * @param aAccumulations - accumulation actions to perform
  */
-void AccumulateChildKeyedHistograms(GeckoProcessType aProcessType, const nsTArray<Telemetry::KeyedAccumulation>& aAccumulations);
+void AccumulateChildKeyedHistograms(Telemetry::ProcessID aProcessType,
+                                    const nsTArray<Telemetry::KeyedAccumulation>& aAccumulations);
 
 /**
  * Update scalars for the given process type with the data coming from child process.
  *
  * @param aProcessType - the process type to process the scalar actions for
  * @param aScalarActions - actions to update the scalar data
  */
-void UpdateChildScalars(GeckoProcessType aProcessType, const nsTArray<Telemetry::ScalarAction>& aScalarActions);
+void UpdateChildScalars(Telemetry::ProcessID aProcessType,
+                        const nsTArray<Telemetry::ScalarAction>& aScalarActions);
 
 /**
  * Update keyed scalars for the given process type with the data coming from child process.
  *
  * @param aProcessType - the process type to process the keyed scalar actions for
  * @param aScalarActions - actions to update the keyed scalar data
  */
-void UpdateChildKeyedScalars(GeckoProcessType aProcessType, const nsTArray<Telemetry::KeyedScalarAction>& aScalarActions);
+void UpdateChildKeyedScalars(Telemetry::ProcessID aProcessType,
+                             const nsTArray<Telemetry::KeyedScalarAction>& aScalarActions);
 
 /**
  * Record events for the given process type with the data coming from child process.
  *
  * @param aProcessType - the process type to record the events for
  * @param aEvents - events to record
  */
-void RecordChildEvents(GeckoProcessType aProcessType, const nsTArray<Telemetry::ChildEventData>& aEvents);
+void RecordChildEvents(Telemetry::ProcessID aProcessType,
+                       const nsTArray<Telemetry::ChildEventData>& aEvents);
 
 }
 }
 
 #endif // TelemetryIPC_h__