Bug 1553213 - Correct new MediaAccess telemetry probes. r=mjf, a=jcristau
authorNico Grunbaum <na-g@nostrum.com>
Wed, 22 May 2019 19:02:37 +0000
changeset 536864 ca143ce6478199dca407a10754dc92a6970324b3
parent 536863 2a684be8b912e9b109f5ebf1389d248f04d0b922
child 536865 00a108b014dac0f3ee308bbc0a7cb097236ed79e
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjf, jcristau
bugs1553213
milestone68.0
Bug 1553213 - Correct new MediaAccess telemetry probes. r=mjf, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D32095
dom/media/MediaDevices.cpp
--- a/dom/media/MediaDevices.cpp
+++ b/dom/media/MediaDevices.cpp
@@ -64,28 +64,31 @@ static bool IsSameOriginWithAllParentDoc
     }
   }
   return true;
 }
 
 already_AddRefed<Promise> MediaDevices::GetUserMedia(
     const MediaStreamConstraints& aConstraints, CallerType aCallerType,
     ErrorResult& aRv) {
-  if (Document* doc = GetOwner()->GetExtantDoc()) {
-    if (!GetOwner()->IsSecureContext()) {
-      doc->SetDocumentAndPageUseCounter(eUseCounter_custom_GetUserMediaInsec);
-    }
-    if (!IsSameOriginWithAllParentDocs(doc)) {
-      doc->SetDocumentAndPageUseCounter(eUseCounter_custom_GetUserMediaXOrigin);
-    }
-    Document* topDoc = doc->GetTopLevelContentDocument();
-    IgnoredErrorResult ignored;
-    if (topDoc && !topDoc->HasFocus(ignored)) {
-      doc->SetDocumentAndPageUseCounter(
-          eUseCounter_custom_GetUserMediaUnfocused);
+  if (RefPtr<nsPIDOMWindowInner> owner = GetOwner()) {
+    if (Document* doc = owner->GetExtantDoc()) {
+      if (!owner->IsSecureContext()) {
+        doc->SetDocumentAndPageUseCounter(eUseCounter_custom_GetUserMediaInsec);
+      }
+      if (!IsSameOriginWithAllParentDocs(doc)) {
+        doc->SetDocumentAndPageUseCounter(
+            eUseCounter_custom_GetUserMediaXOrigin);
+      }
+      Document* topDoc = doc->GetTopLevelContentDocument();
+      IgnoredErrorResult ignored;
+      if (topDoc && !topDoc->HasFocus(ignored)) {
+        doc->SetDocumentAndPageUseCounter(
+            eUseCounter_custom_GetUserMediaUnfocused);
+      }
     }
   }
   RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
   RefPtr<MediaDevices> self(this);
   MediaManager::Get()
@@ -107,26 +110,28 @@ already_AddRefed<Promise> MediaDevices::
           });
   return p.forget();
 }
 
 already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
                                                          ErrorResult& aRv) {
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (Document* doc = GetOwner()->GetExtantDoc()) {
-    if (!GetOwner()->IsSecureContext()) {
-      doc->SetDocumentAndPageUseCounter(
-          eUseCounter_custom_EnumerateDevicesInsec);
-    }
-    Document* topDoc = doc->GetTopLevelContentDocument();
-    IgnoredErrorResult ignored;
-    if (topDoc && !topDoc->HasFocus(ignored)) {
-      doc->SetDocumentAndPageUseCounter(
-          eUseCounter_custom_EnumerateDevicesUnfocused);
+  if (RefPtr<nsPIDOMWindowInner> owner = GetOwner()) {
+    if (Document* doc = owner->GetExtantDoc()) {
+      if (!owner->IsSecureContext()) {
+        doc->SetDocumentAndPageUseCounter(
+            eUseCounter_custom_EnumerateDevicesInsec);
+      }
+      Document* topDoc = doc->GetTopLevelContentDocument();
+      IgnoredErrorResult ignored;
+      if (topDoc && !topDoc->HasFocus(ignored)) {
+        doc->SetDocumentAndPageUseCounter(
+            eUseCounter_custom_EnumerateDevicesUnfocused);
+      }
     }
   }
   RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
   RefPtr<MediaDevices> self(this);
   MediaManager::Get()
@@ -167,20 +172,22 @@ already_AddRefed<Promise> MediaDevices::
             p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
           });
   return p.forget();
 }
 
 already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
     const DisplayMediaStreamConstraints& aConstraints, CallerType aCallerType,
     ErrorResult& aRv) {
-  if (Document* doc = GetOwner()->GetExtantDoc()) {
-    if (!IsSameOriginWithAllParentDocs(doc)) {
-      doc->SetDocumentAndPageUseCounter(
-          eUseCounter_custom_GetDisplayMediaXOrigin);
+  if (RefPtr<nsPIDOMWindowInner> owner = GetOwner()) {
+    if (Document* doc = owner->GetExtantDoc()) {
+      if (!IsSameOriginWithAllParentDocs(doc)) {
+        doc->SetDocumentAndPageUseCounter(
+            eUseCounter_custom_GetDisplayMediaXOrigin);
+      }
     }
   }
   RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
   RefPtr<MediaDevices> self(this);
   MediaManager::Get()