Backed out 7 changesets (bug 1565689) for assertion failures at MediaControlUtils.h on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Wed, 07 Aug 2019 04:40:52 +0300
changeset 547150 e0029fe751e0fea1ee69549a9414d26dac1548f4
parent 547149 ed7acf219ce6525a982ad945627138d53b024ab8
child 547151 36592e14f6cefa6e4fc32386f76d9f2558892922
push id11848
push userffxbld-merge
push dateMon, 26 Aug 2019 19:26:25 +0000
treeherdermozilla-beta@9b31bfdfac10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1565689
milestone70.0a1
backs out9ebf6f8a4fda6267d3f44fd3cd775474e1fb1002
49c41a9238f9f1f49714dd4fa199f9d05c178f97
9014276e070a55ebf98afce8f985cba6c8515942
d9f7fcbef3ee97f074aa9a2df66fbdd230e2cf89
d3db3285e9332b56329d23da908edd7f82449e94
1ca26f550f4b66fcfd509179ab9dca838ca7192f
1d27d083e9745f8b170b39ad54c1eedb1cf3306c
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
Backed out 7 changesets (bug 1565689) for assertion failures at MediaControlUtils.h on a CLOSED TREE Backed out changeset 9ebf6f8a4fda (bug 1565689) Backed out changeset 49c41a9238f9 (bug 1565689) Backed out changeset 9014276e070a (bug 1565689) Backed out changeset d9f7fcbef3ee (bug 1565689) Backed out changeset d3db3285e933 (bug 1565689) Backed out changeset 1ca26f550f4b (bug 1565689) Backed out changeset 1d27d083e974 (bug 1565689)
docshell/base/CanonicalBrowsingContext.cpp
docshell/base/CanonicalBrowsingContext.h
dom/audiochannel/AudioChannelService.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsPIDOMWindow.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/media/mediacontrol/AudioFocusManager.cpp
dom/media/mediacontrol/AudioFocusManager.h
dom/media/mediacontrol/MediaControlIPC.h
dom/media/mediacontrol/MediaControlService.cpp
dom/media/mediacontrol/MediaControlService.h
dom/media/mediacontrol/MediaControlUtils.h
dom/media/mediacontrol/MediaController.cpp
dom/media/mediacontrol/MediaController.h
dom/media/mediacontrol/moz.build
dom/media/mediacontrol/tests/browser.ini
dom/media/mediacontrol/tests/browser_audio_focus_management.js
dom/media/mediacontrol/tests/file_autoplay.html
dom/media/mediacontrol/tests/file_muted_autoplay.html
dom/media/mediacontrol/tests/gtest/TestAudioFocusManager.cpp
dom/media/mediacontrol/tests/gtest/TestMediaControlService.cpp
dom/media/mediacontrol/tests/gtest/TestMediaController.cpp
dom/media/mediacontrol/tests/gtest/moz.build
dom/media/moz.build
modules/libpref/init/StaticPrefList.yaml
--- a/docshell/base/CanonicalBrowsingContext.cpp
+++ b/docshell/base/CanonicalBrowsingContext.cpp
@@ -204,26 +204,16 @@ void CanonicalBrowsingContext::NotifyMed
   if (window) {
     window->SetAudioMuted(aMuted);
   }
   Group()->EachParent([&](ContentParent* aParent) {
     Unused << aParent->SendSetMediaMuted(this, aMuted);
   });
 }
 
-void CanonicalBrowsingContext::UpdateMediaAction(MediaControlActions aAction) {
-  nsPIDOMWindowOuter* window = GetDOMWindow();
-  if (window) {
-    window->UpdateMediaAction(aAction);
-  }
-  Group()->EachParent([&](ContentParent* aParent) {
-    Unused << aParent->SendUpdateMediaAction(this, aAction);
-  });
-}
-
 void CanonicalBrowsingContext::SetFieldEpochsForChild(
     ContentParent* aChild, const BrowsingContext::FieldEpochs& aEpochs) {
   mChildFieldEpochs.Put(aChild->ChildID(), aEpochs);
 }
 
 const BrowsingContext::FieldEpochs&
 CanonicalBrowsingContext::GetFieldEpochsForChild(ContentParent* aChild) {
   static const BrowsingContext::FieldEpochs sDefaultFieldEpochs;
--- a/docshell/base/CanonicalBrowsingContext.h
+++ b/docshell/base/CanonicalBrowsingContext.h
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 mozilla_dom_CanonicalBrowsingContext_h
 #define mozilla_dom_CanonicalBrowsingContext_h
 
 #include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/MediaController.h"
 #include "mozilla/RefPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 class nsIDocShell;
 
@@ -74,20 +73,16 @@ class CanonicalBrowsingContext final : p
   // autoplay media.
   void NotifyStartDelayedAutoplayMedia();
 
   // This function is used to mute or unmute all media within a tab. It would
   // set the media mute property for the top level window and propagate it to
   // other top level windows in other processes.
   void NotifyMediaMutedChanged(bool aMuted);
 
-  // This function would update the media action for the current outer window
-  // and propogate the action to other browsing contexts in content processes.
-  void UpdateMediaAction(MediaControlActions aAction);
-
   // Validate that the given process is allowed to perform the given
   // transaction. aSource is |nullptr| if set in the parent process.
   bool ValidateTransaction(const Transaction& aTransaction,
                            ContentParent* aSource);
 
   void SetFieldEpochsForChild(ContentParent* aChild,
                               const FieldEpochs& aEpochs);
   const FieldEpochs& GetFieldEpochsForChild(ContentParent* aChild);
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -134,20 +134,16 @@ bool IsEnableAudioCompetingForAllAgents(
 #endif
 }
 
 }  // anonymous namespace
 
 namespace mozilla {
 namespace dom {
 
-extern void NotifyMediaStarted(uint64_t aWindowID);
-extern void NotifyMediaStopped(uint64_t aWindowID);
-extern void NotifyMediaAudibleChanged(uint64_t aWindowID, bool aAudible);
-
 const char* SuspendTypeToStr(const nsSuspendedTypes& aSuspend) {
   MOZ_ASSERT(aSuspend == nsISuspendedTypes::NONE_SUSPENDED ||
              aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE ||
              aSuspend == nsISuspendedTypes::SUSPENDED_BLOCK ||
              aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
              aSuspend == nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
 
   switch (aSuspend) {
@@ -769,33 +765,31 @@ void AudioChannelService::AudioChannelWi
 
   ++mConfig.mNumberOfAgents;
 
   // TODO: Make NotifyChannelActiveRunnable irrelevant to
   // BrowserElementAudioChannel
   if (mConfig.mNumberOfAgents == 1) {
     NotifyChannelActive(aAgent->WindowID(), true);
   }
-  NotifyMediaStarted(aAgent->WindowID());
 }
 
 void AudioChannelService::AudioChannelWindow::RemoveAgentAndReduceAgentsNum(
     AudioChannelAgent* aAgent) {
   MOZ_ASSERT(aAgent);
   MOZ_ASSERT(mAgents.Contains(aAgent));
 
   mAgents.RemoveElement(aAgent);
 
   MOZ_ASSERT(mConfig.mNumberOfAgents > 0);
   --mConfig.mNumberOfAgents;
 
   if (mConfig.mNumberOfAgents == 0) {
     NotifyChannelActive(aAgent->WindowID(), false);
   }
-  NotifyMediaStopped(aAgent->WindowID());
 }
 
 void AudioChannelService::AudioChannelWindow::AudioCapturedChanged(
     AudioChannelAgent* aAgent, AudioCaptureState aCapture) {
   MOZ_ASSERT(aAgent);
 
   if (mIsAudioCaptured) {
     aAgent->WindowAudioCaptureChanged(aAgent->InnerWindowID(), aCapture);
@@ -825,31 +819,29 @@ void AudioChannelService::AudioChannelWi
   MOZ_ASSERT(mAgents.Contains(aAgent));
 
   if (!mAudibleAgents.Contains(aAgent)) {
     mAudibleAgents.AppendElement(aAgent);
     if (IsFirstAudibleAgent()) {
       NotifyAudioAudibleChanged(aAgent->Window(), AudibleState::eAudible,
                                 aReason);
     }
-    NotifyMediaAudibleChanged(aAgent->WindowID(), true);
   }
 }
 
 void AudioChannelService::AudioChannelWindow::RemoveAudibleAgentIfContained(
     AudioChannelAgent* aAgent, AudibleChangedReasons aReason) {
   MOZ_ASSERT(aAgent);
 
   if (mAudibleAgents.Contains(aAgent)) {
     mAudibleAgents.RemoveElement(aAgent);
     if (IsLastAudibleAgent()) {
       NotifyAudioAudibleChanged(aAgent->Window(), AudibleState::eNotAudible,
                                 aReason);
     }
-    NotifyMediaAudibleChanged(aAgent->WindowID(), false);
   }
 }
 
 bool AudioChannelService::AudioChannelWindow::IsFirstAudibleAgent() const {
   return (mAudibleAgents.Length() == 1);
 }
 
 bool AudioChannelService::AudioChannelWindow::IsLastAudibleAgent() const {
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -25,18 +25,16 @@
 #include "nsIWebProgressListener.h"
 #include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/dom/ContentFrameMessageManager.h"
 #include "mozilla/dom/EventTarget.h"
 #include "mozilla/dom/LocalStorage.h"
 #include "mozilla/dom/LSObject.h"
 #include "mozilla/dom/Storage.h"
 #include "mozilla/dom/MaybeCrossOriginObject.h"
-#include "mozilla/dom/MediaController.h"
-#include "mozilla/dom/MediaControlUtils.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/StorageEvent.h"
 #include "mozilla/dom/StorageEventBinding.h"
 #include "mozilla/dom/StorageNotifierService.h"
 #include "mozilla/dom/StorageUtils.h"
 #include "mozilla/dom/Timeout.h"
 #include "mozilla/dom/TimeoutHandler.h"
 #include "mozilla/dom/TimeoutManager.h"
@@ -267,22 +265,16 @@ class nsIScriptTimeoutHandler;
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 using mozilla::BasePrincipal;
 using mozilla::OriginAttributes;
 using mozilla::TimeStamp;
 
-extern mozilla::LazyLogModule gMediaControlLog;
-
-#define MC_LOG(msg, ...)                     \
-  MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
-          ("WindowOuter=%p, " msg, this, ##__VA_ARGS__))
-
 #define FORWARD_TO_INNER(method, args, err_rval)       \
   PR_BEGIN_MACRO                                       \
   if (!mInnerWindow) {                                 \
     NS_WARNING("No inner window available!");          \
     return err_rval;                                   \
   }                                                    \
   return GetCurrentInnerWindowInternal()->method args; \
   PR_END_MACRO
@@ -2879,36 +2871,16 @@ void nsPIDOMWindowOuter::MaybeActiveMedi
 
   SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
 }
 
 SuspendTypes nsPIDOMWindowOuter::GetMediaSuspend() const {
   return mMediaSuspend;
 }
 
-void nsPIDOMWindowOuter::UpdateMediaAction(const MediaControlActions aAction) {
-  // TODO : we now temporarily map MediaControlActions to nsISuspendedTypes in
-  // order to control media, but for long term goal in which we should not rely
-  // on nsISuspendedTypes and completely decouple them. See bug1571493.
-  MC_LOG("UpdateMediaAction %s", ToMediaControlActionsStr(aAction));
-  switch (aAction) {
-    case MediaControlActions::ePlay:
-      SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
-      break;
-    case MediaControlActions::ePause:
-      SetMediaSuspend(nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE);
-      break;
-    case MediaControlActions::eStop:
-      SetMediaSuspend(nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
-      break;
-    default:
-      MOZ_ASSERT_UNREACHABLE("Invalid action.");
-  };
-}
-
 void nsPIDOMWindowOuter::SetMediaSuspend(SuspendTypes aSuspend) {
   if (!IsDisposableSuspend(aSuspend)) {
     MaybeNotifyMediaResumedFromBlock(aSuspend);
     mMediaSuspend = aSuspend;
   }
 
   RefreshMediaElementsSuspend(aSuspend);
 }
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -65,17 +65,16 @@ class ReportingObserver;
 class Selection;
 class ServiceWorker;
 class ServiceWorkerDescriptor;
 class Timeout;
 class TimeoutManager;
 class WindowGlobalChild;
 class CustomElementRegistry;
 enum class CallerType : uint32_t;
-enum class MediaControlActions : uint32_t;
 }  // namespace dom
 }  // namespace mozilla
 
 enum UIStateChangeType {
   UIStateChangeType_NoChange,
   UIStateChangeType_Set,
   UIStateChangeType_Clear,
   UIStateChangeType_Invalid  // used for serialization only
@@ -752,18 +751,16 @@ class nsPIDOMWindowOuter : public mozIDO
   bool GetAudioMuted() const;
   void SetAudioMuted(bool aMuted);
 
   float GetAudioVolume() const;
   nsresult SetAudioVolume(float aVolume);
 
   void MaybeActiveMediaComponents();
 
-  void UpdateMediaAction(const mozilla::dom::MediaControlActions aAction);
-
   void SetServiceWorkersTestingEnabled(bool aEnabled);
   bool GetServiceWorkersTestingEnabled();
 
   float GetDevicePixelRatio(mozilla::dom::CallerType aCallerType);
 
   void SetLargeAllocStatus(mozilla::dom::LargeAllocStatus aStatus);
 
   bool IsTopLevelWindow();
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -223,17 +223,16 @@
 #    include "mozilla/a11y/AccessibleWrap.h"
 #  endif
 #  include "mozilla/a11y/DocAccessible.h"
 #  include "mozilla/a11y/DocManager.h"
 #  include "mozilla/a11y/OuterDocAccessible.h"
 #endif
 
 #include "mozilla/dom/File.h"
-#include "mozilla/dom/MediaController.h"
 #include "mozilla/dom/PPresentationChild.h"
 #include "mozilla/dom/PresentationIPCService.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/IPCStreamDestination.h"
 #include "mozilla/ipc/IPCStreamSource.h"
 
 #ifdef MOZ_WEBSPEECH
@@ -3746,26 +3745,16 @@ mozilla::ipc::IPCResult ContentChild::Re
   MOZ_ASSERT(aContext);
   nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
   if (window) {
     window->SetAudioMuted(aMuted);
   }
   return IPC_OK();
 }
 
-mozilla::ipc::IPCResult ContentChild::RecvUpdateMediaAction(
-    BrowsingContext* aContext, MediaControlActions aAction) {
-  MOZ_ASSERT(aContext);
-  nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
-  if (window) {
-    window->UpdateMediaAction(aAction);
-  }
-  return IPC_OK();
-}
-
 already_AddRefed<nsIEventTarget> ContentChild::GetSpecificMessageEventTarget(
     const Message& aMsg) {
   switch (aMsg.type()) {
     // Javascript
     case PJavaScript::Msg_DropTemporaryStrongReferences__ID:
     case PJavaScript::Msg_DropObject__ID:
 
     // Navigation
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -69,17 +69,16 @@ class SharedMap;
 }
 
 class AlertObserver;
 class ConsoleListener;
 class ClonedMessageData;
 class BrowserChild;
 class GetFilesHelperChild;
 class TabContext;
-enum class MediaControlActions : uint32_t;
 
 class ContentChild final : public PContentChild,
                            public nsIWindowProvider,
                            public CPOWManagerGetter,
                            public mozilla::ipc::IShmemAllocator {
   typedef mozilla::dom::ClonedMessageData ClonedMessageData;
   typedef mozilla::ipc::FileDescriptor FileDescriptor;
   typedef mozilla::ipc::PFileDescriptorSetChild PFileDescriptorSetChild;
@@ -689,19 +688,16 @@ class ContentChild final : public PConte
       const uint32_t& aRedirectMode);
 
   mozilla::ipc::IPCResult RecvStartDelayedAutoplayMediaComponents(
       BrowsingContext* aContext);
 
   mozilla::ipc::IPCResult RecvSetMediaMuted(BrowsingContext* aContext,
                                             bool aMuted);
 
-  mozilla::ipc::IPCResult RecvUpdateMediaAction(BrowsingContext* aContext,
-                                                MediaControlActions aAction);
-
   void HoldBrowsingContextGroup(BrowsingContextGroup* aBCG);
   void ReleaseBrowsingContextGroup(BrowsingContextGroup* aBCG);
 
 #ifdef NIGHTLY_BUILD
   // Fetch the current number of pending input events.
   //
   // NOTE: This method performs an atomic read, and is safe to call from all
   // threads.
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -7,17 +7,16 @@
 #include "mozilla/DebugOnly.h"
 
 #include "base/basictypes.h"
 #include "base/shared_memory.h"
 
 #include "ContentParent.h"
 #include "ProcessUtils.h"
 #include "BrowserParent.h"
-#include "mozilla/dom/MediaControlService.h"
 
 #if defined(ANDROID) || defined(LINUX)
 #  include <sys/time.h>
 #  include <sys/resource.h>
 #endif
 
 #include "chrome/common/process_watcher.h"
 
@@ -5786,38 +5785,16 @@ ContentParent::RecvFirstPartyStorageAcce
 }
 
 mozilla::ipc::IPCResult ContentParent::RecvStoreUserInteractionAsPermission(
     const Principal& aPrincipal) {
   AntiTrackingCommon::StoreUserInteractionFor(aPrincipal);
   return IPC_OK();
 }
 
-mozilla::ipc::IPCResult ContentParent::RecvNotifyMediaActiveChanged(
-    BrowsingContext* aContext, bool aActive) {
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  MOZ_ASSERT(!aContext->GetParent(), "Should be top level browsing context!");
-  RefPtr<MediaController> controller =
-      service->GetOrCreateControllerById(aContext->Id());
-  controller->NotifyMediaActiveChanged(aActive);
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult ContentParent::RecvNotifyMediaAudibleChanged(
-    BrowsingContext* aContext, bool aAudible) {
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  MOZ_ASSERT(!aContext->GetParent(), "Should be top level browsing context!");
-  RefPtr<MediaController> controller =
-      service->GetControllerById(aContext->Id());
-  if (controller) {
-    controller->NotifyMediaAudibleChanged(aAudible);
-  }
-  return IPC_OK();
-}
-
 mozilla::ipc::IPCResult ContentParent::RecvAttachBrowsingContext(
     BrowsingContext::IPCInitializer&& aInit) {
   RefPtr<CanonicalBrowsingContext> parent;
   if (aInit.mParentId != 0) {
     parent = CanonicalBrowsingContext::Get(aInit.mParentId);
     MOZ_RELEASE_ASSERT(parent, "Parent doesn't exist in parent process");
   }
 
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -1186,22 +1186,16 @@ class ContentParent final : public PCont
       const Principal& aParentPrincipal, const Principal& aTrackingPrincipal,
       const nsCString& aTrackingOrigin, const nsCString& aGrantedOrigin,
       const int& aAllowMode,
       FirstPartyStorageAccessGrantedForOriginResolver&& aResolver);
 
   mozilla::ipc::IPCResult RecvStoreUserInteractionAsPermission(
       const Principal& aPrincipal);
 
-  mozilla::ipc::IPCResult RecvNotifyMediaActiveChanged(
-      BrowsingContext* aContext, bool aActive);
-
-  mozilla::ipc::IPCResult RecvNotifyMediaAudibleChanged(
-      BrowsingContext* aContext, bool aAudible);
-
   // Notify the ContentChild to enable the input event prioritization when
   // initializing.
   void MaybeEnableRemoteInputEventQueue();
 
 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
   void AppendSandboxParams(std::vector<std::string>& aArgs);
   void AppendDynamicSandboxParams(std::vector<std::string>& aArgs);
 #endif
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -100,17 +100,16 @@ using refcounted class nsIInputStream fr
 using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
 using mozilla::dom::BrowsingContextTransaction from "mozilla/dom/BrowsingContext.h";
 using mozilla::dom::BrowsingContextFieldEpochs from "mozilla/dom/BrowsingContext.h";
 using mozilla::dom::BrowsingContextInitializer from "mozilla/dom/BrowsingContext.h";
 using base::SharedMemoryHandle from "base/shared_memory.h";
 using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h";
 using mozilla::fontlist::Pointer from "SharedFontList.h";
 using gfxSparseBitSet from "gfxFontUtils.h";
-using mozilla::dom::MediaControlActions from "ipc/MediaControlIPC.h";
 
 union ChromeRegistryItem
 {
     ChromePackage;
     OverrideMapping;
     SubstitutionMapping;
 };
 
@@ -805,22 +804,16 @@ child:
     */
     async StartDelayedAutoplayMediaComponents(BrowsingContext aContext);
 
     /**
     * This method is used to notifty content process to mute or unmute media.
     */
     async SetMediaMuted(BrowsingContext aContext, bool aMuted);
 
-    /**
-     * This method is used to apply the media action to outer window in the
-     * content process, such as play, pause, stop ..e.t.c.
-     */
-    async UpdateMediaAction(BrowsingContext aContext, MediaControlActions aAction);
-
     // Begin subscribing to a new BrowsingContextGroup, sending down the current
     // value for every individual BrowsingContext.
     async RegisterBrowsingContextGroup(BrowsingContextInitializer[] aInits);
 
 parent:
     async InitBackground(Endpoint<PBackgroundParent> aEndpoint);
 
     sync OpenRecordReplayChannel(uint32_t channelId)
@@ -1389,28 +1382,16 @@ parent:
                                                   Principal aTrackingPrincipal,
                                                   nsCString aTrackingOrigin,
                                                   nsCString aGrantedOrigin,
                                                   int aAllowMode)
           returns (bool unused);
 
     async StoreUserInteractionAsPermission(Principal aPrincipal);
 
-   /**
-    * When media started or stopped in content process, we have to notify the
-    * chrome process in order to know which tab is playing media.
-    */
-    async NotifyMediaActiveChanged(BrowsingContext aContext, bool aActive);
-
-   /**
-    * When media became audible or inaudible in content process, we have to
-    * notify chrome process in order to which tab is audible.
-    */
-    async NotifyMediaAudibleChanged(BrowsingContext aContext, bool aAudible);
-
 both:
     async CommitBrowsingContextTransaction(BrowsingContext aContext,
                                            BrowsingContextTransaction aTransaction,
                                            BrowsingContextFieldEpochs aEpochs);
 
     async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
                        Principal aPrincipal, ClonedMessageData aData);
 
deleted file mode 100644
--- a/dom/media/mediacontrol/AudioFocusManager.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "AudioFocusManager.h"
-
-#include "MediaControlService.h"
-
-#include "mozilla/Logging.h"
-#include "mozilla/StaticPrefs_media.h"
-
-extern mozilla::LazyLogModule gMediaControlLog;
-
-#undef LOG
-#define LOG(msg, ...)                        \
-  MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
-          ("AudioFocusManager=%p, " msg, this, ##__VA_ARGS__))
-
-namespace mozilla {
-namespace dom {
-
-AudioFocusManager::AudioFocusManager(MediaControlService* aService)
-    : mService(aService) {}
-
-void AudioFocusManager::RequestAudioFocus(uint64_t aId) {
-  if (mOwningFocusControllers.Contains(aId)) {
-    return;
-  }
-
-  LOG("Controller %" PRId64 " grants audio focus", aId);
-  mOwningFocusControllers.AppendElement(aId);
-  HandleAudioCompetition(aId);
-}
-
-void AudioFocusManager::RevokeAudioFocus(uint64_t aId) {
-  if (!mOwningFocusControllers.Contains(aId)) {
-    return;
-  }
-
-  LOG("Controller %" PRId64 " loses audio focus", aId);
-  mOwningFocusControllers.RemoveElement(aId);
-}
-
-void AudioFocusManager::HandleAudioCompetition(uint64_t aId) {
-  // Enable audio focus management will start the audio competition which is
-  // only allowing one controller playing at a time.
-  if (!StaticPrefs::media_audioFocus_management()) {
-    return;
-  }
-
-  for (size_t idx = 0; idx < mOwningFocusControllers.Length(); idx++) {
-    const uint64_t controllerId = mOwningFocusControllers[idx];
-    if (controllerId != aId) {
-      LOG("Controller %" PRId64 " loses audio focus in audio competitition",
-          controllerId);
-      RefPtr<MediaController> controller =
-          mService->GetControllerById(controllerId);
-      MOZ_ASSERT(controller);
-      controller->Stop();
-    }
-  }
-
-  mOwningFocusControllers.Clear();
-  mOwningFocusControllers.AppendElement(aId);
-}
-
-uint32_t AudioFocusManager::GetAudioFocusNums() const {
-  return mOwningFocusControllers.Length();
-}
-
-void AudioFocusManager::Shutdown() { mService = nullptr; }
-
-}  // namespace dom
-}  // namespace mozilla
deleted file mode 100644
--- a/dom/media/mediacontrol/AudioFocusManager.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 mozilla_dom_audiofocusmanager_h__
-#define mozilla_dom_audiofocusmanager_h__
-
-#include "base/basictypes.h"
-#include "nsTArray.h"
-
-namespace mozilla {
-namespace dom {
-
-class MediaControlService;
-
-/**
- * AudioFocusManager is used to assign the audio focus to different requester
- * and decide which requester can own audio focus when audio competing happens.
- * When the audio competing happens, the last request would be a winner who can
- * still own the audio focus, and all the other requesters would lose the audio
- * focus. Now MediaController is the onlt requester, it would request the audio
- * focus when it becomes audible and revoke the audio focus when the controller
- * is no longer active.
- */
-class AudioFocusManager {
- public:
-  void RequestAudioFocus(uint64_t aId);
-  void RevokeAudioFocus(uint64_t aId);
-
-  explicit AudioFocusManager(MediaControlService* aService);
-  ~AudioFocusManager() = default;
-
-  uint32_t GetAudioFocusNums() const;
-
- private:
-  friend class MediaControlService;
-  void Shutdown();
-  void HandleAudioCompetition(uint64_t aId);
-
-  RefPtr<MediaControlService> mService;
-  nsTArray<uint64_t> mOwningFocusControllers;
-};
-
-}  // namespace dom
-}  // namespace mozilla
-
-#endif  //  mozilla_dom_audiofocusmanager_h__
deleted file mode 100644
--- a/dom/media/mediacontrol/MediaControlIPC.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 ipc_MediaControlIPC_h
-#define ipc_MediaControlIPC_h
-
-#include "ipc/IPCMessageUtils.h"
-
-#include "mozilla/dom/MediaController.h"
-
-namespace IPC {
-template <>
-struct ParamTraits<mozilla::dom::MediaControlActions>
-    : public ContiguousEnumSerializer<
-          mozilla::dom::MediaControlActions,
-          mozilla::dom::MediaControlActions::ePlay,
-          mozilla::dom::MediaControlActions(
-              mozilla::dom::MediaControlActions::eActionsNum)> {};
-}  // namespace IPC
-
-#endif  // mozilla_MediaControlIPC_hh
\ No newline at end of file
deleted file mode 100644
--- a/dom/media/mediacontrol/MediaControlService.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "MediaControlService.h"
-
-#include "MediaController.h"
-
-#include "mozilla/Assertions.h"
-#include "mozilla/Logging.h"
-#include "mozilla/Services.h"
-#include "mozilla/StaticPtr.h"
-#include "nsIObserverService.h"
-#include "nsXULAppAPI.h"
-
-extern mozilla::LazyLogModule gMediaControlLog;
-
-#undef LOG
-#define LOG(msg, ...)                        \
-  MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
-          ("MediaControlService=%p, " msg, this, ##__VA_ARGS__))
-
-namespace mozilla {
-namespace dom {
-
-StaticRefPtr<MediaControlService> gMediaControlService;
-static bool sIsXPCOMShutdown = false;
-
-/* static */
-RefPtr<MediaControlService> MediaControlService::GetService() {
-  MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
-                        "MediaControlService only runs on Chrome process!");
-  if (sIsXPCOMShutdown) {
-    return nullptr;
-  }
-  if (!gMediaControlService) {
-    gMediaControlService = new MediaControlService();
-  }
-  RefPtr<MediaControlService> service = gMediaControlService.get();
-  return service;
-}
-
-NS_INTERFACE_MAP_BEGIN(MediaControlService)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
-  NS_INTERFACE_MAP_ENTRY(nsIObserver)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_ADDREF(MediaControlService)
-NS_IMPL_RELEASE(MediaControlService)
-
-MediaControlService::MediaControlService() : mAudioFocusManager(this) {
-  LOG("create media control service");
-  RefPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  if (obs) {
-    obs->AddObserver(this, "xpcom-shutdown", false);
-  }
-}
-
-MediaControlService::~MediaControlService() {
-  LOG("destroy media control service");
-  Shutdown();
-}
-
-NS_IMETHODIMP
-MediaControlService::Observe(nsISupports* aSubject, const char* aTopic,
-                             const char16_t* aData) {
-  if (!strcmp(aTopic, "xpcom-shutdown")) {
-    LOG("XPCOM shutdown");
-    MOZ_ASSERT(gMediaControlService);
-    RefPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    if (obs) {
-      obs->RemoveObserver(this, "xpcom-shutdown");
-    }
-    Shutdown();
-    sIsXPCOMShutdown = true;
-    gMediaControlService = nullptr;
-  }
-  return NS_OK;
-}
-
-void MediaControlService::Shutdown() {
-  ShutdownAllControllers();
-  mControllers.Clear();
-  mAudioFocusManager.Shutdown();
-}
-
-RefPtr<MediaController> MediaControlService::GetOrCreateControllerById(
-    const uint64_t aId) const {
-  RefPtr<MediaController> controller = mControllers.Get(aId);
-  if (!controller) {
-    controller = new TabMediaController(aId);
-  }
-  return controller;
-}
-
-RefPtr<MediaController> MediaControlService::GetControllerById(
-    const uint64_t aId) const {
-  return mControllers.Get(aId);
-}
-
-void MediaControlService::AddMediaController(
-    const RefPtr<MediaController>& aController) {
-  MOZ_DIAGNOSTIC_ASSERT(aController);
-  const uint64_t cId = aController->Id();
-  MOZ_DIAGNOSTIC_ASSERT(!mControllers.GetValue(cId),
-                        "Controller has been added already!");
-  mControllers.Put(cId, aController);
-  LOG("Add media controller %" PRId64 ", currentNum=%" PRId64, cId,
-      GetControllersNum());
-}
-
-void MediaControlService::RemoveMediaController(
-    const RefPtr<MediaController>& aController) {
-  MOZ_DIAGNOSTIC_ASSERT(aController);
-  const uint64_t cId = aController->Id();
-  MOZ_DIAGNOSTIC_ASSERT(mControllers.GetValue(cId),
-                        "Controller does not exist!");
-  mControllers.Remove(cId);
-  LOG("Remove media controller %" PRId64 ", currentNum=%" PRId64, cId,
-      GetControllersNum());
-}
-
-void MediaControlService::PlayAllControllers() const {
-  for (auto iter = mControllers.ConstIter(); !iter.Done(); iter.Next()) {
-    const RefPtr<MediaController>& controller = iter.Data();
-    controller->Play();
-  }
-}
-
-void MediaControlService::PauseAllControllers() const {
-  for (auto iter = mControllers.ConstIter(); !iter.Done(); iter.Next()) {
-    const RefPtr<MediaController>& controller = iter.Data();
-    controller->Pause();
-  }
-}
-
-void MediaControlService::StopAllControllers() const {
-  for (auto iter = mControllers.ConstIter(); !iter.Done(); iter.Next()) {
-    const RefPtr<MediaController>& controller = iter.Data();
-    controller->Stop();
-  }
-}
-
-void MediaControlService::ShutdownAllControllers() const {
-  for (auto iter = mControllers.ConstIter(); !iter.Done(); iter.Next()) {
-    const RefPtr<MediaController>& controller = iter.Data();
-    controller->Shutdown();
-  }
-}
-
-uint64_t MediaControlService::GetControllersNum() const {
-  return mControllers.Count();
-}
-
-}  // namespace dom
-}  // namespace mozilla
deleted file mode 100644
--- a/dom/media/mediacontrol/MediaControlService.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 mozilla_dom_mediacontrolservice_h__
-#define mozilla_dom_mediacontrolservice_h__
-
-#include "mozilla/AlreadyAddRefed.h"
-
-#include "AudioFocusManager.h"
-#include "MediaController.h"
-#include "nsDataHashtable.h"
-#include "nsIObserver.h"
-#include "nsTArray.h"
-
-namespace mozilla {
-namespace dom {
-
-/**
- * MediaControlService is an interface to access controllers by providing
- * controller Id. Everytime when controller becomes active, which means there is
- * one or more media started in the corresponding browsing context, so now the
- * controller is actually controlling something in the content process, so it
- * would be added into the list of the MediaControlService. The controller would
- * be removed from the list of the MediaControlService when it becomes inactive,
- * which means no media is playing in the corresponding browsing context. Note
- * that, a controller can't be added to or remove from the list twice. It should
- * should have a responsibility to add and remove itself in the proper time.
- */
-class MediaControlService final : public nsIObserver {
- public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-
-  static RefPtr<MediaControlService> GetService();
-
-  RefPtr<MediaController> GetOrCreateControllerById(const uint64_t aId) const;
-  RefPtr<MediaController> GetControllerById(const uint64_t aId) const;
-  AudioFocusManager& GetAudioFocusManager() { return mAudioFocusManager; }
-
-  void AddMediaController(const RefPtr<MediaController>& aController);
-  void RemoveMediaController(const RefPtr<MediaController>& aController);
-  uint64_t GetControllersNum() const;
-
- private:
-  MediaControlService();
-  ~MediaControlService();
-
-  void Shutdown();
-
-  void PlayAllControllers() const;
-  void PauseAllControllers() const;
-  void StopAllControllers() const;
-  void ShutdownAllControllers() const;
-
-  nsDataHashtable<nsUint64HashKey, RefPtr<MediaController>> mControllers;
-  AudioFocusManager mAudioFocusManager;
-};
-
-}  // namespace dom
-}  // namespace mozilla
-
-#endif
deleted file mode 100644
--- a/dom/media/mediacontrol/MediaControlUtils.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 mozilla_dom_MediaControlUtils_h
-#define mozilla_dom_MediaControlUtils_h
-
-#include "MediaController.h"
-#include "MediaControlService.h"
-
-#include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/ContentChild.h"
-#include "nsGlobalWindowOuter.h"
-#include "nsXULAppAPI.h"
-
-mozilla::LazyLogModule gMediaControlLog("MediaControl");
-
-#undef LOG
-#define LOG(msg, ...)                        \
-  MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
-          ("MediaControlUtils, " msg, ##__VA_ARGS__))
-
-namespace mozilla {
-namespace dom {
-
-static void NotifyMediaActiveChanged(const RefPtr<BrowsingContext>& aBc,
-                                     bool aActive) {
-  if (XRE_IsContentProcess()) {
-    ContentChild* contentChild = ContentChild::GetSingleton();
-    Unused << contentChild->SendNotifyMediaActiveChanged(aBc, aActive);
-  } else {
-    MediaControlService::GetService()
-        ->GetOrCreateControllerById(aBc->Id())
-        ->NotifyMediaActiveChanged(aActive);
-  }
-}
-
-static RefPtr<BrowsingContext> GetBrowingContextByWindowID(uint64_t aWindowID) {
-  RefPtr<nsGlobalWindowOuter> window =
-      nsGlobalWindowOuter::GetOuterWindowWithId(aWindowID);
-  if (!window) {
-    return nullptr;
-  }
-  return window->GetBrowsingContext();
-}
-
-const char* ToMediaControlActionsStr(
-    mozilla::dom::MediaControlActions aAction) {
-  switch (aAction) {
-    case MediaControlActions::ePlay:
-      return "Play";
-    case MediaControlActions::ePause:
-      return "Pause";
-    case MediaControlActions::eStop:
-      return "Stop";
-    default:
-      MOZ_ASSERT_UNREACHABLE("Invalid action.");
-  }
-  return "UNKNOWN";
-}
-
-void NotifyMediaStarted(uint64_t aWindowID) {
-  RefPtr<BrowsingContext> bc = GetBrowingContextByWindowID(aWindowID);
-  if (!bc) {
-    return;
-  }
-  LOG("Notify media started in BC %" PRId64, bc->Id());
-  bc = bc->Top();
-  MOZ_ASSERT(bc->IsTopContent(), "Should use top level browsing context.");
-  NotifyMediaActiveChanged(bc, true);
-}
-
-void NotifyMediaStopped(uint64_t aWindowID) {
-  RefPtr<BrowsingContext> bc = GetBrowingContextByWindowID(aWindowID);
-  if (!bc) {
-    return;
-  }
-  LOG("Notify media stopped in BC %" PRId64, bc->Id());
-  bc = bc->Top();
-  MOZ_ASSERT(bc->IsTopContent(), "Should use top level browsing context.");
-  NotifyMediaActiveChanged(bc, false);
-}
-
-void NotifyMediaAudibleChanged(uint64_t aWindowID, bool aAudible) {
-  RefPtr<BrowsingContext> bc = GetBrowingContextByWindowID(aWindowID);
-  if (!bc) {
-    return;
-  }
-  LOG("Notify media became %s in BC %" PRId64,
-      aAudible ? "audible" : "inaudible", bc->Id());
-  bc = bc->Top();
-  MOZ_ASSERT(bc->IsTopContent(), "Should use top level browsing context.");
-  if (XRE_IsContentProcess()) {
-    ContentChild* contentChild = ContentChild::GetSingleton();
-    Unused << contentChild->SendNotifyMediaAudibleChanged(bc, aAudible);
-  } else {
-    RefPtr<MediaController> controller =
-        MediaControlService::GetService()->GetControllerById(bc->Id());
-    if (controller) {
-      controller->NotifyMediaAudibleChanged(aAudible);
-    }
-  }
-}
-
-}  // namespace dom
-}  // namespace mozilla
-
-#endif  // mozilla_dom_MediaControlUtils_h
deleted file mode 100644
--- a/dom/media/mediacontrol/MediaController.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "MediaController.h"
-
-#include "MediaControlService.h"
-#include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/CanonicalBrowsingContext.h"
-
-extern mozilla::LazyLogModule gMediaControlLog;
-
-// avoid redefined macro in unified build
-#undef LOG
-#define LOG(msg, ...)                                                       \
-  MOZ_LOG(gMediaControlLog, LogLevel::Debug,                                \
-          ("TabMediaController=%p, Id=%" PRId64 ", " msg, this, this->Id(), \
-           ##__VA_ARGS__))
-
-namespace mozilla {
-namespace dom {
-
-already_AddRefed<BrowsingContext> MediaController::GetContext() const {
-  return BrowsingContext::Get(mBrowsingContextId);
-}
-
-TabMediaController::TabMediaController(uint64_t aContextId)
-    : MediaController(aContextId) {
-  MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
-                        "MediaController only runs on Chrome process!");
-  LOG("Create controller %" PRId64, Id());
-}
-
-TabMediaController::~TabMediaController() {
-  LOG("Destroy controller %" PRId64, Id());
-  MOZ_DIAGNOSTIC_ASSERT(!mControlledMediaNum);
-};
-
-void TabMediaController::Play() {
-  LOG("Play");
-  mIsPlaying = true;
-  RefPtr<BrowsingContext> context = GetContext();
-  if (context) {
-    context->Canonical()->UpdateMediaAction(MediaControlActions::ePlay);
-  }
-}
-
-void TabMediaController::Pause() {
-  LOG("Pause");
-  mIsPlaying = false;
-  RefPtr<BrowsingContext> context = GetContext();
-  if (context) {
-    context->Canonical()->UpdateMediaAction(MediaControlActions::ePause);
-  }
-}
-
-void TabMediaController::Stop() {
-  LOG("Stop");
-  mIsPlaying = false;
-  RefPtr<BrowsingContext> context = GetContext();
-  if (context) {
-    context->Canonical()->UpdateMediaAction(MediaControlActions::eStop);
-  }
-}
-
-void TabMediaController::Shutdown() {
-  mIsPlaying = false;
-  mControlledMediaNum = 0;
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  MOZ_ASSERT(service);
-  service->GetAudioFocusManager().RevokeAudioFocus(Id());
-}
-
-bool TabMediaController::IsAudible() const { return mIsPlaying && mAudible; }
-
-void TabMediaController::NotifyMediaActiveChanged(bool aActive) {
-  if (aActive) {
-    IncreaseControlledMediaNum();
-  } else {
-    DecreaseControlledMediaNum();
-  }
-}
-
-void TabMediaController::NotifyMediaAudibleChanged(bool aAudible) {
-  mAudible = aAudible;
-  if (mAudible) {
-    RefPtr<MediaControlService> service = MediaControlService::GetService();
-    MOZ_ASSERT(service);
-    service->GetAudioFocusManager().RequestAudioFocus(Id());
-  }
-}
-
-void TabMediaController::IncreaseControlledMediaNum() {
-  MOZ_DIAGNOSTIC_ASSERT(mControlledMediaNum >= 0);
-  mControlledMediaNum++;
-  LOG("Increase controlled media num to %" PRId64, mControlledMediaNum);
-  if (mControlledMediaNum == 1) {
-    Activate();
-  }
-}
-
-void TabMediaController::DecreaseControlledMediaNum() {
-  MOZ_DIAGNOSTIC_ASSERT(mControlledMediaNum >= 1);
-  mControlledMediaNum--;
-  LOG("Decrease controlled media num to %" PRId64, mControlledMediaNum);
-  if (mControlledMediaNum == 0) {
-    Deactivate();
-  }
-}
-
-// TODO : Use watchable to moniter mControlledMediaNum
-void TabMediaController::Activate() {
-  mIsPlaying = true;
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  MOZ_ASSERT(service);
-  service->AddMediaController(this);
-}
-
-void TabMediaController::Deactivate() {
-  mIsPlaying = false;
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  MOZ_ASSERT(service);
-  service->RemoveMediaController(this);
-  service->GetAudioFocusManager().RevokeAudioFocus(Id());
-}
-
-uint64_t TabMediaController::ControlledMediaNum() const {
-  return mControlledMediaNum;
-}
-
-}  // namespace dom
-}  // namespace mozilla
deleted file mode 100644
--- a/dom/media/mediacontrol/MediaController.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 mozilla_dom_mediacontroller_h__
-#define mozilla_dom_mediacontroller_h__
-
-#include "nsDataHashtable.h"
-#include "nsISupportsImpl.h"
-
-namespace mozilla {
-namespace dom {
-
-class BrowsingContext;
-
-enum class MediaControlActions : uint32_t {
-  ePlay,
-  ePause,
-  eStop,
-  /* do not use this, it's used to indicate the last value of enum */
-  eActionsNum,
-};
-
-/**
- * MediaController is a class which is used to control media in the content
- * process. It's a basic interface class and you should implement you own class
- * to inherit this class. Every controller would correspond to a browsing
- * context. For example, TabMediaController corresponds to the top level
- * browsing context. In the future, we might implement MediaSessionController
- * which could correspond to any browsing context, depending on which browsing
- * context has active media session.
- */
-class MediaController {
- public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaController);
-
-  explicit MediaController(uint64_t aContextId)
-      : mBrowsingContextId(aContextId) {}
-
-  virtual void Play() = 0;
-  virtual void Pause() = 0;
-  virtual void Stop() = 0;
-  virtual void Shutdown() = 0;
-
-  virtual void NotifyMediaActiveChanged(bool aActive) = 0;
-  virtual void NotifyMediaAudibleChanged(bool aAudible) = 0;
-
-  bool IsPlaying() const { return mIsPlaying; }
-  uint64_t Id() const { return mBrowsingContextId; }
-  virtual uint64_t ControlledMediaNum() const { return 0; }
-  virtual bool IsAudible() const { return false; }
-
- protected:
-  virtual ~MediaController() = default;
-
-  already_AddRefed<BrowsingContext> GetContext() const;
-
-  uint64_t mBrowsingContextId;
-  bool mIsPlaying = false;
-};
-
-/**
- * TabMediaController is used to control all media in a tab. It can only be used
- * in Chrome process. Everytime media starts in the tab, it would increase the
- * number of controlled media, and also would decrease the number when media
- * stops. The media it controls might be in different content processes, so we
- * keep tracking the top level browsing context in the tab, which can be used to
- * propagate conmmands to remote content processes.
- */
-class TabMediaController final : public MediaController {
- public:
-  explicit TabMediaController(uint64_t aContextId);
-
-  void Play() override;
-  void Pause() override;
-  void Stop() override;
-  void Shutdown() override;
-
-  uint64_t ControlledMediaNum() const override;
-  bool IsAudible() const override;
-
-  void NotifyMediaActiveChanged(bool aActive) override;
-  void NotifyMediaAudibleChanged(bool aAudible) override;
-
- protected:
-  ~TabMediaController();
-
- private:
-  void IncreaseControlledMediaNum();
-  void DecreaseControlledMediaNum();
-
-  void Activate();
-  void Deactivate();
-
-  int64_t mControlledMediaNum = 0;
-  bool mAudible = false;
-};
-
-}  // namespace dom
-}  // namespace mozilla
-
-#endif
deleted file mode 100644
--- a/dom/media/mediacontrol/moz.build
+++ /dev/null
@@ -1,28 +0,0 @@
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# 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/.
-
-EXPORTS.mozilla.dom += [
-    'AudioFocusManager.h',
-    'MediaController.h',
-    'MediaControlService.h',
-    'MediaControlUtils.h',
-]
-
-EXPORTS.ipc += [
-    'MediaControlIPC.h',
-]
-
-UNIFIED_SOURCES += [
-    'AudioFocusManager.cpp',
-    'MediaController.cpp',
-    'MediaControlService.cpp',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-if CONFIG['ENABLE_TESTS']:
-    DIRS += ['tests/gtest']
-
-FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/browser.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[DEFAULT]
-support-files =
-  file_autoplay.html
-  file_muted_autoplay.html
-  ../../test/gizmo.mp4
-
-[browser_audio_focus_management.js]
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/browser_audio_focus_management.js
+++ /dev/null
@@ -1,176 +0,0 @@
-/* eslint-disable no-undef */
-"use strict";
-
-const PAGE_AUDIBLE =
-  "https://example.com/browser/dom/media/mediacontrol/tests/file_autoplay.html";
-const PAGE_INAUDIBLE =
-  "https://example.com/browser/dom/media/mediacontrol/tests/file_muted_autoplay.html";
-
-/**
- * These tests are used to ensure that the audio focus management works correctly
- * amongs different tabs no matter the pref is on or off. If the pref is on,
- * there is only one tab which is allowed to play audio at a time, the last tab
- * starting audio will immediately stop other tabs which own audio focus. But
- * notice that playing inaudible media won't gain audio focus. If the pref is
- * off, all audible tabs can own audio focus at the same time without
- * interfering each others.
- */
-add_task(async function testDisableAudioFocusManagement() {
-  await switchAudioFocusManagerment(false);
-
-  info(`open audible autoplay media in tab1`);
-  const tab1 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab1);
-
-  info(`open same page on another tab, which shouldn't cause audio competing`);
-  const tab2 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab2);
-
-  info(`media in tab1 should be playing still`);
-  await checkOrWaitUntilMediaStartedPlaying(tab1);
-
-  info(`remove tabs`);
-  await clearTabsAndResetPref([tab1, tab2]);
-});
-
-add_task(async function testEnableAudioFocusManagement() {
-  await switchAudioFocusManagerment(true);
-
-  info(`open audible autoplay media in tab1`);
-  const tab1 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab1);
-
-  info(`open same page on another tab, which should cause audio competing`);
-  const tab2 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab2);
-
-  info(`media in tab1 should be stopped`);
-  await checkOrWaitUntilMediaStoppedPlaying(tab1);
-
-  info(`remove tabs`);
-  await clearTabsAndResetPref([tab1, tab2]);
-});
-
-add_task(async function testMutedMediaWontInvolveAudioCompeting() {
-  await switchAudioFocusManagerment(true);
-
-  info(`open audible autoplay media in tab1`);
-  const tab1 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab1);
-
-  info(
-    `open inaudible media page on another tab, which shouldn't cause audio competing`
-  );
-  const tab2 = await createTabAndLoad(PAGE_INAUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab2);
-
-  info(`media in tab1 should be playing still`);
-  await checkOrWaitUntilMediaStartedPlaying(tab1);
-
-  info(
-    `open audible media page on the third tab, which should cause audio competing`
-  );
-  const tab3 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab3);
-
-  info(`media in tab1 should be stopped`);
-  await checkOrWaitUntilMediaStoppedPlaying(tab1);
-
-  info(`media in tab2 should not be affected because it's inaudible.`);
-  await checkOrWaitUntilMediaStartedPlaying(tab2);
-
-  info(`remove tabs`);
-  await clearTabsAndResetPref([tab1, tab2, tab3]);
-});
-
-add_task(async function testStopMultipleTabsWhenSwitchingPrefDynamically() {
-  await switchAudioFocusManagerment(false);
-
-  info(`open audible autoplay media in tab1`);
-  const tab1 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab1);
-
-  info(`open same page on another tab, which shouldn't cause audio competing`);
-  const tab2 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab2);
-
-  await switchAudioFocusManagerment(true);
-
-  info(`open same page on the third tab, which should cause audio competing`);
-  const tab3 = await createTabAndLoad(PAGE_AUDIBLE);
-  await checkOrWaitUntilMediaStartedPlaying(tab3);
-
-  info(`media in tab1 and tab2 should be stopped`);
-  await checkOrWaitUntilMediaStoppedPlaying(tab1);
-  await checkOrWaitUntilMediaStoppedPlaying(tab2);
-
-  info(`remove tabs`);
-  await clearTabsAndResetPref([tab1, tab2, tab3]);
-});
-
-/**
- * The following are helper funcions.
- */
-async function switchAudioFocusManagerment(enable) {
-  const state = enable ? "Enable" : "Disable";
-  info(`${state} audio focus management`);
-  await SpecialPowers.pushPrefEnv({
-    set: [["media.audioFocus.management", enable]],
-  });
-}
-async function createTabAndLoad(url) {
-  let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser, url);
-  return tab;
-}
-
-async function checkOrWaitUntilMediaStartedPlaying(tab) {
-  await ContentTask.spawn(tab.linkedBrowser, null, () => {
-    return new Promise(resolve => {
-      const video = content.document.getElementById("autoplay");
-      if (!video) {
-        ok(false, `can't get the media element!`);
-      }
-      if (!video.paused) {
-        ok(true, `media started playing`);
-        resolve();
-      } else {
-        info(`wait until media starts playing`);
-        video.onplaying = () => {
-          video.onplaying = null;
-          ok(true, `media started playing`);
-          resolve();
-        };
-      }
-    });
-  });
-}
-
-async function checkOrWaitUntilMediaStoppedPlaying(tab) {
-  await ContentTask.spawn(tab.linkedBrowser, null, () => {
-    return new Promise(resolve => {
-      const video = content.document.getElementById("autoplay");
-      if (!video) {
-        ok(false, `can't get the media element!`);
-      }
-      if (video.paused) {
-        ok(true, `media stopped playing`);
-        resolve();
-      } else {
-        info(`wait until media stops playing`);
-        video.onpause = () => {
-          video.onpause = null;
-          ok(true, `media stopped playing`);
-          resolve();
-        };
-      }
-    });
-  });
-}
-
-async function clearTabsAndResetPref(tabs) {
-  info(`clear tabs and reset pref`);
-  for (let tab of tabs) {
-    BrowserTestUtils.removeTab(tab);
-  }
-  await switchAudioFocusManagerment(false);
-}
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/file_autoplay.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-	<title>Autoplay page</title>
-</head>
-<body>
-<video id="autoplay" src="gizmo.mp4" autoplay loop></video>
-</body>
-</html>
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/file_muted_autoplay.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Muted autoplay page</title>
-</head>
-<body>
-<video id="autoplay" src="gizmo.mp4" autoplay loop muted></video>
-</body>
-</html>
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/gtest/TestAudioFocusManager.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "gtest/gtest.h"
-#include "AudioFocusManager.h"
-#include "MediaControlService.h"
-
-using namespace mozilla::dom;
-
-#define FIRST_CONTROLLER_ID 0
-#define SECOND_CONTROLLER_ID 1
-
-TEST(AudioFocusManager, TestMultipleAudioFocusNums)
-{
-  AudioFocusManager manager(nullptr);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-
-  manager.RequestAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-
-  manager.RequestAudioFocus(SECOND_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 2);
-
-  manager.RevokeAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-
-  manager.RevokeAudioFocus(SECOND_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-}
-
-TEST(AudioFocusManager, TestRequestAudioFocusRepeatedly)
-{
-  AudioFocusManager manager(nullptr);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-
-  manager.RequestAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-
-  manager.RequestAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-}
-
-TEST(AudioFocusManager, TestRevokeAudioFocusRepeatedly)
-{
-  AudioFocusManager manager(nullptr);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-
-  manager.RequestAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-
-  manager.RevokeAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-
-  manager.RevokeAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-}
-
-TEST(AudioFocusManager, TestRevokeAudioFocusWithoutRequestAudioFocus)
-{
-  AudioFocusManager manager(nullptr);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-
-  manager.RevokeAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-}
-
-TEST(AudioFocusManager,
-     TestRevokeAudioFocusForControllerWithoutOwningAudioFocus)
-{
-  AudioFocusManager manager(nullptr);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 0);
-
-  manager.RequestAudioFocus(FIRST_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-
-  manager.RevokeAudioFocus(SECOND_CONTROLLER_ID);
-  ASSERT_TRUE(manager.GetAudioFocusNums() == 1);
-}
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/gtest/TestMediaControlService.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "gtest/gtest.h"
-#include "MediaControlService.h"
-#include "MediaController.h"
-
-using namespace mozilla::dom;
-
-#define FIRST_CONTROLLER_ID 0
-#define SECOND_CONTROLLER_ID 1
-
-TEST(MediaControlService, TestAddOrRemoveControllers)
-{
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  ASSERT_TRUE(service->GetControllersNum() == 0);
-
-  RefPtr<MediaController> controller1 =
-      new TabMediaController(FIRST_CONTROLLER_ID);
-  RefPtr<MediaController> controller2 =
-      new TabMediaController(SECOND_CONTROLLER_ID);
-
-  service->AddMediaController(controller1);
-  ASSERT_TRUE(service->GetControllersNum() == 1);
-
-  service->AddMediaController(controller2);
-  ASSERT_TRUE(service->GetControllersNum() == 2);
-
-  service->RemoveMediaController(controller1);
-  ASSERT_TRUE(service->GetControllersNum() == 1);
-
-  service->RemoveMediaController(controller2);
-  ASSERT_TRUE(service->GetControllersNum() == 0);
-}
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/gtest/TestMediaController.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "gtest/gtest.h"
-#include "MediaControlService.h"
-#include "MediaController.h"
-
-using namespace mozilla::dom;
-
-#define CONTROLLER_ID 0
-
-TEST(MediaController, DefaultValueCheck)
-{
-  RefPtr<MediaController> controller = new TabMediaController(CONTROLLER_ID);
-  ASSERT_TRUE(controller->ControlledMediaNum() == 0);
-  ASSERT_TRUE(controller->Id() == CONTROLLER_ID);
-  ASSERT_TRUE(!controller->IsPlaying());
-  ASSERT_TRUE(!controller->IsAudible());
-}
-
-TEST(MediaController, NotifyMediaActiveChanged)
-{
-  RefPtr<MediaController> controller = new TabMediaController(CONTROLLER_ID);
-  ASSERT_TRUE(controller->ControlledMediaNum() == 0);
-
-  controller->NotifyMediaActiveChanged(true);
-  ASSERT_TRUE(controller->ControlledMediaNum() == 1);
-
-  controller->NotifyMediaActiveChanged(true);
-  ASSERT_TRUE(controller->ControlledMediaNum() == 2);
-
-  controller->NotifyMediaActiveChanged(false);
-  ASSERT_TRUE(controller->ControlledMediaNum() == 1);
-
-  controller->NotifyMediaActiveChanged(false);
-  ASSERT_TRUE(controller->ControlledMediaNum() == 0);
-}
-
-TEST(MediaController, ActiveAndDeactiveController)
-{
-  RefPtr<MediaControlService> service = MediaControlService::GetService();
-  ASSERT_TRUE(service->GetControllersNum() == 0);
-
-  RefPtr<MediaController> controller1 =
-      new TabMediaController(FIRST_CONTROLLER_ID);
-
-  controller1->NotifyMediaActiveChanged(true);
-  ASSERT_TRUE(service->GetControllersNum() == 1);
-
-  controller1->NotifyMediaActiveChanged(false);
-  ASSERT_TRUE(service->GetControllersNum() == 0);
-}
-
-TEST(MediaController, AudibleChanged)
-{
-  RefPtr<MediaController> controller = new TabMediaController(CONTROLLER_ID);
-  controller->Play();
-  ASSERT_TRUE(!controller->IsAudible());
-
-  controller->NotifyMediaAudibleChanged(true);
-  ASSERT_TRUE(controller->IsAudible());
-
-  controller->NotifyMediaAudibleChanged(false);
-  ASSERT_TRUE(!controller->IsAudible());
-}
-
-TEST(MediaController, AlwaysInaudibleIfControllerIsNotPlaying)
-{
-  RefPtr<MediaController> controller = new TabMediaController(CONTROLLER_ID);
-  ASSERT_TRUE(!controller->IsAudible());
-
-  controller->NotifyMediaAudibleChanged(true);
-  ASSERT_TRUE(!controller->IsAudible());
-
-  controller->Play();
-  ASSERT_TRUE(controller->IsAudible());
-
-  controller->Pause();
-  ASSERT_TRUE(!controller->IsAudible());
-
-  controller->Play();
-  ASSERT_TRUE(controller->IsAudible());
-
-  controller->Stop();
-  ASSERT_TRUE(!controller->IsAudible());
-}
-
-TEST(MediaController, playingStateChanged)
-{
-  RefPtr<MediaController> controller = new TabMediaController(CONTROLLER_ID);
-  ASSERT_TRUE(!controller->IsPlaying());
-
-  controller->Play();
-  ASSERT_TRUE(controller->IsPlaying());
-
-  controller->Play();
-  controller->Pause();
-  ASSERT_TRUE(!controller->IsPlaying());
-
-  controller->Play();
-  controller->Stop();
-  ASSERT_TRUE(!controller->IsPlaying());
-}
deleted file mode 100644
--- a/dom/media/mediacontrol/tests/gtest/moz.build
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# 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/.
-
-UNIFIED_SOURCES += [
-    'TestAudioFocusManager.cpp',
-    'TestMediaController.cpp',
-    'TestMediaControlService.cpp',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-LOCAL_INCLUDES += [
-    '/dom/media/mediacontrol',
-]
-
-FINAL_LIBRARY = 'xul-gtest'
-
-if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
-    CXXFLAGS += ['-Wno-error=shadow']
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -37,17 +37,16 @@ DIRS += [
     'encoder',
     'fake-cdm',
     'flac',
     'gmp',
     'gmp-plugin-openh264',
     'imagecapture',
     'ipc',
     'mediacapabilities',
-    'mediacontrol',
     'mediasink',
     'mediasource',
     'mp3',
     'ogg',
     'platforms',
     'systemservices',
     'wave',
     'webaudio',
@@ -78,18 +77,16 @@ if CONFIG['FUZZING_INTERFACES']:
         'fuzz'
     ]
 
 MOCHITEST_MANIFESTS += [
     'test/mochitest.ini',
     'tests/mochitest/identity/mochitest.ini',
 ]
 
-BROWSER_CHROME_MANIFESTS += ['mediacontrol/tests/browser.ini']
-
 if CONFIG['MOZ_WEBRTC']:
     MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
     WEBRTC_SIGNALLING_TEST_MANIFESTS += ['tests/mochitest/steeplechase.ini']
     WEBRTC_SIGNALLING_TEST_MANIFESTS += ['tests/mochitest/steeplechase_long/steeplechase_long.ini']
 
 XPIDL_SOURCES += [
     'nsIAudioDeviceInfo.idl',
     'nsIAutoplay.idl',
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -5377,21 +5377,16 @@
   value: false
   mirror: always
 
 - name: media.useAudioChannelService.testing
   type: bool
   value: false
   mirror: always
 
-- name: media.audioFocus.management
-  type: bool
-  value: false
-  mirror: always
-
 #---------------------------------------------------------------------------
 # Prefs starting with "mousewheel."
 #---------------------------------------------------------------------------
 
 # These affect how line scrolls from wheel events will be accelerated.
 - name: mousewheel.acceleration.factor
   type: RelaxedAtomicInt32
   value: -1