Bug 1340189: P3. Fix coding style. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 16 Feb 2017 21:28:09 +0100
changeset 485632 fe97d086ea2f35000704fc16ac8feafb755ca599
parent 485631 b0535c3abf043581365af9f2470913ffd0bc0e65
child 546074 77d27022067652ee80a2bbca4ae128a29ffb19c3
push id45794
push userbmo:jyavenard@mozilla.com
push dateThu, 16 Feb 2017 23:30:50 +0000
reviewersgerald
bugs1340189
milestone54.0a1
Bug 1340189: P3. Fix coding style. r?gerald MozReview-Commit-ID: 9oA9jNZSo7m
dom/media/eme/CDMCaps.cpp
dom/media/eme/CDMCaps.h
dom/media/eme/CDMProxy.h
dom/media/eme/DecryptorProxyCallback.h
dom/media/eme/DetailedPromise.cpp
dom/media/eme/DetailedPromise.h
dom/media/eme/EMEUtils.cpp
dom/media/eme/EMEUtils.h
dom/media/eme/MediaEncryptedEvent.cpp
dom/media/eme/MediaEncryptedEvent.h
dom/media/eme/MediaKeyError.cpp
dom/media/eme/MediaKeyError.h
dom/media/eme/MediaKeyMessageEvent.cpp
dom/media/eme/MediaKeyMessageEvent.h
dom/media/eme/MediaKeySession.cpp
dom/media/eme/MediaKeySession.h
dom/media/eme/MediaKeyStatusMap.cpp
dom/media/eme/MediaKeyStatusMap.h
dom/media/eme/MediaKeySystemAccess.cpp
dom/media/eme/MediaKeySystemAccess.h
dom/media/eme/MediaKeySystemAccessManager.cpp
dom/media/eme/MediaKeySystemAccessManager.h
dom/media/eme/MediaKeys.cpp
dom/media/eme/MediaKeys.h
dom/media/eme/mediadrm/MediaDrmCDMCallbackProxy.cpp
dom/media/eme/mediadrm/MediaDrmCDMCallbackProxy.h
dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
dom/media/eme/mediadrm/MediaDrmCDMProxy.h
dom/media/eme/mediadrm/MediaDrmProxySupport.cpp
dom/media/eme/mediadrm/MediaDrmProxySupport.h
--- a/dom/media/eme/CDMCaps.cpp
+++ b/dom/media/eme/CDMCaps.cpp
@@ -1,29 +1,24 @@
 /* -*- 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 "mozilla/CDMCaps.h"
+#include "SamplesWaitingForKey.h"
 #include "mozilla/EMEUtils.h"
 #include "nsThreadUtils.h"
-#include "SamplesWaitingForKey.h"
 
 namespace mozilla {
 
-CDMCaps::CDMCaps()
-  : mMonitor("CDMCaps")
-{
-}
+CDMCaps::CDMCaps() : mMonitor("CDMCaps") { }
 
-CDMCaps::~CDMCaps()
-{
-}
+CDMCaps::~CDMCaps() { }
 
 void
 CDMCaps::Lock()
 {
   mMonitor.Lock();
 }
 
 void
@@ -44,46 +39,46 @@ CDMCaps::AutoLock::~AutoLock()
 }
 
 // Keys with MediaKeyStatus::Usable, MediaKeyStatus::Output_downscaled,
 // or MediaKeyStatus::Output_restricted status can be used by the CDM
 // to decrypt or decrypt-and-decode samples.
 static bool
 IsUsableStatus(dom::MediaKeyStatus aStatus)
 {
-  return aStatus == dom::MediaKeyStatus::Usable ||
-         aStatus == dom::MediaKeyStatus::Output_restricted ||
-         aStatus == dom::MediaKeyStatus::Output_downscaled;
+  return aStatus == dom::MediaKeyStatus::Usable
+         || aStatus == dom::MediaKeyStatus::Output_restricted
+         || aStatus == dom::MediaKeyStatus::Output_downscaled;
 }
 
 bool
 CDMCaps::AutoLock::IsKeyUsable(const CencKeyId& aKeyId)
 {
   mData.mMonitor.AssertCurrentThreadOwns();
   for (const KeyStatus& keyStatus : mData.mKeyStatuses) {
     if (keyStatus.mId == aKeyId) {
       return IsUsableStatus(keyStatus.mStatus);
     }
   }
   return false;
 }
 
 bool
-CDMCaps::AutoLock::SetKeyStatus(const CencKeyId& aKeyId,
-                                const nsString& aSessionId,
-                                const dom::Optional<dom::MediaKeyStatus>& aStatus)
+CDMCaps::AutoLock::SetKeyStatus(
+  const CencKeyId& aKeyId,
+  const nsString& aSessionId,
+  const dom::Optional<dom::MediaKeyStatus>& aStatus)
 {
   mData.mMonitor.AssertCurrentThreadOwns();
 
   if (!aStatus.WasPassed()) {
     // Called from ForgetKeyStatus.
     // Return true if the element is found to notify key changes.
-    return mData.mKeyStatuses.RemoveElement(KeyStatus(aKeyId,
-                                                      aSessionId,
-                                                      dom::MediaKeyStatus::Internal_error));
+    return mData.mKeyStatuses.RemoveElement(
+      KeyStatus(aKeyId, aSessionId, dom::MediaKeyStatus::Internal_error));
   }
 
   KeyStatus key(aKeyId, aSessionId, aStatus.Value());
   auto index = mData.mKeyStatuses.IndexOf(key);
   if (index != mData.mKeyStatuses.NoIndex) {
     if (mData.mKeyStatuses[index].mStatus == aStatus.Value()) {
       // No change.
       return false;
@@ -127,18 +122,19 @@ CDMCaps::AutoLock::NotifyWhenKeyIdUsable
 {
   mData.mMonitor.AssertCurrentThreadOwns();
   MOZ_ASSERT(!IsKeyUsable(aKey));
   MOZ_ASSERT(aListener);
   mData.mWaitForKeys.AppendElement(WaitForKeys(aKey, aListener));
 }
 
 void
-CDMCaps::AutoLock::GetKeyStatusesForSession(const nsAString& aSessionId,
-                                            nsTArray<KeyStatus>& aOutKeyStatuses)
+CDMCaps::AutoLock::GetKeyStatusesForSession(
+  const nsAString& aSessionId,
+  nsTArray<KeyStatus>& aOutKeyStatuses)
 {
   for (const KeyStatus& keyStatus : mData.mKeyStatuses) {
     if (keyStatus.mSessionId.Equals(aSessionId)) {
       aOutKeyStatuses.AppendElement(keyStatus);
     }
   }
 }
 
--- a/dom/media/eme/CDMCaps.h
+++ b/dom/media/eme/CDMCaps.h
@@ -2,62 +2,67 @@
 /* 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 CDMCaps_h_
 #define CDMCaps_h_
 
+#include "SamplesWaitingForKey.h"
 #include "gmp-decryption.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Monitor.h"
+#include "mozilla/dom/BindingDeclarations.h"      // For Optional
+#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus
 #include "nsIThread.h"
-#include "nsTArray.h"
 #include "nsString.h"
-#include "SamplesWaitingForKey.h"
-
-#include "mozilla/Monitor.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus
-#include "mozilla/dom/BindingDeclarations.h" // For Optional
+#include "nsTArray.h"
 
 namespace mozilla {
 
 // CDM capabilities; what keys a CDMProxy can use.
 // Must be locked to access state.
-class CDMCaps {
+class CDMCaps
+{
 public:
   CDMCaps();
   ~CDMCaps();
 
-  struct KeyStatus {
+  struct KeyStatus
+  {
     KeyStatus(const CencKeyId& aId,
               const nsString& aSessionId,
               dom::MediaKeyStatus aStatus)
       : mId(aId)
       , mSessionId(aSessionId)
       , mStatus(aStatus)
-    {}
+    {
+    }
     KeyStatus(const KeyStatus& aOther)
       : mId(aOther.mId)
       , mSessionId(aOther.mSessionId)
       , mStatus(aOther.mStatus)
-    {}
-    bool operator==(const KeyStatus& aOther) const {
-      return mId == aOther.mId &&
-             mSessionId == aOther.mSessionId;
+    {
+    }
+    bool operator==(const KeyStatus& aOther) const
+    {
+      return mId == aOther.mId
+             && mSessionId == aOther.mSessionId;
     };
 
     CencKeyId mId;
     nsString mSessionId;
     dom::MediaKeyStatus mStatus;
   };
 
   // Locks the CDMCaps. It must be locked to access its shared state.
   // Threadsafe when locked.
-  class MOZ_STACK_CLASS AutoLock {
+  class MOZ_STACK_CLASS AutoLock
+  {
   public:
     explicit AutoLock(CDMCaps& aKeyCaps);
     ~AutoLock();
 
     bool IsKeyUsable(const CencKeyId& aKeyId);
 
     // Returns true if key status changed,
     // i.e. the key status changed from usable to expired.
@@ -87,17 +92,18 @@ private:
   void Lock();
   void Unlock();
 
   struct WaitForKeys {
     WaitForKeys(const CencKeyId& aKeyId,
                 SamplesWaitingForKey* aListener)
       : mKeyId(aKeyId)
       , mListener(aListener)
-    {}
+    {
+    }
     CencKeyId mKeyId;
     RefPtr<SamplesWaitingForKey> mListener;
   };
 
   Monitor mMonitor;
 
   nsTArray<KeyStatus> mKeyStatuses;
 
--- a/dom/media/eme/CDMProxy.h
+++ b/dom/media/eme/CDMProxy.h
@@ -13,46 +13,53 @@
 #include "mozilla/dom/MediaKeyMessageEvent.h"
 #include "mozilla/dom/MediaKeys.h"
 
 #include "nsIThread.h"
 
 namespace mozilla {
 class MediaRawData;
 
-enum DecryptStatus {
+enum DecryptStatus
+{
   Ok = 0,
   GenericErr = 1,
   NoKeyErr = 2,
   AbortedErr = 3,
 };
 
-struct DecryptResult {
+struct DecryptResult
+{
   DecryptResult(DecryptStatus aStatus, MediaRawData* aSample)
     : mStatus(aStatus)
     , mSample(aSample)
-  {}
+  {
+  }
   DecryptStatus mStatus;
   RefPtr<MediaRawData> mSample;
 };
 
-typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
+typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true>
+  DecryptPromise;
 
-class CDMKeyInfo {
+class CDMKeyInfo
+{
 public:
   explicit CDMKeyInfo(const nsTArray<uint8_t>& aKeyId)
     : mKeyId(aKeyId)
     , mStatus()
-  {}
+  {
+  }
 
   CDMKeyInfo(const nsTArray<uint8_t>& aKeyId,
              const dom::Optional<dom::MediaKeyStatus>& aStatus)
     : mKeyId(aKeyId)
     , mStatus(aStatus.Value())
-  {}
+  {
+  }
 
   // The copy-ctor and copy-assignment operator for Optional<T> are declared as
   // delete, so override CDMKeyInfo copy-ctor for nsTArray operations.
   CDMKeyInfo(const CDMKeyInfo& aKeyInfo)
   {
     mKeyId = aKeyInfo.mKeyId;
     if (aKeyInfo.mStatus.WasPassed()) {
       mStatus.Construct(aKeyInfo.mStatus.Value());
@@ -64,44 +71,46 @@ public:
 };
 
 typedef int64_t UnixTime;
 
 // Proxies calls CDM, and proxies calls back.
 // Note: Promises are passed in via a PromiseId, so that the ID can be
 // passed via IPC to the CDM, which can then signal when to reject or
 // resolve the promise using its PromiseId.
-class CDMProxy {
+class CDMProxy
+{
 protected:
   typedef dom::PromiseId PromiseId;
   typedef dom::MediaKeySessionType MediaKeySessionType;
 public:
 
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   // Main thread only.
   CDMProxy(dom::MediaKeys* aKeys,
            const nsAString& aKeySystem,
            bool aDistinctiveIdentifierRequired,
            bool aPersistentStateRequired)
     : mKeys(aKeys)
     , mKeySystem(aKeySystem)
     , mDistinctiveIdentifierRequired(aDistinctiveIdentifierRequired)
     , mPersistentStateRequired(aPersistentStateRequired)
-  {}
+  {
+  }
 
   // Main thread only.
   // Loads the CDM corresponding to mKeySystem.
   // Calls MediaKeys::OnCDMCreated() when the CDM is created.
   virtual void Init(PromiseId aPromiseId,
                     const nsAString& aOrigin,
                     const nsAString& aTopLevelOrigin,
                     const nsAString& aName) = 0;
 
-  virtual void OnSetDecryptorId(uint32_t aId) {}
+  virtual void OnSetDecryptorId(uint32_t aId) { }
 
   // Main thread only.
   // Uses the CDM to create a key session.
   // Calls MediaKeys::OnSessionActivated() when session is created.
   // Assumes ownership of (Move()s) aInitData's contents.
   virtual void CreateSession(uint32_t aCreateSessionToken,
                              MediaKeySessionType aSessionType,
                              PromiseId aPromiseId,
@@ -217,55 +226,60 @@ public:
 
 #ifdef DEBUG
   virtual bool IsOnOwnerThread() = 0;
 #endif
 
   virtual uint32_t GetDecryptorId() { return 0; }
 
 protected:
-  virtual ~CDMProxy() {}
+  virtual ~CDMProxy() { }
 
   // Helper to enforce that a raw pointer is only accessed on the main thread.
   template<class Type>
-  class MainThreadOnlyRawPtr {
+  class MainThreadOnlyRawPtr
+  {
   public:
     explicit MainThreadOnlyRawPtr(Type* aPtr)
       : mPtr(aPtr)
     {
       MOZ_ASSERT(NS_IsMainThread());
     }
 
-    bool IsNull() const {
+    bool IsNull() const
+    {
       MOZ_ASSERT(NS_IsMainThread());
       return !mPtr;
     }
 
-    void Clear() {
+    void Clear()
+    {
       MOZ_ASSERT(NS_IsMainThread());
       mPtr = nullptr;
     }
 
-    Type* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN {
+    Type* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
+    {
       MOZ_ASSERT(NS_IsMainThread());
       return mPtr;
     }
   private:
     Type* mPtr;
   };
 
   // Our reference back to the MediaKeys object.
   // WARNING: This is a non-owning reference that is cleared by MediaKeys
   // destructor. only use on main thread, and always nullcheck before using!
   MainThreadOnlyRawPtr<dom::MediaKeys> mKeys;
 
   const nsString mKeySystem;
 
   // Onwer specified thread. e.g. Gecko Media Plugin thread.
-  // All interactions with the out-of-process EME plugin must come from this thread.
+  // All interactions with the out-of-process EME plugin must come from this
+  // thread.
   RefPtr<nsIThread> mOwnerThread;
 
   nsCString mNodeId;
 
   CDMCaps mCapabilites;
 
   const bool mDistinctiveIdentifierRequired;
   const bool mPersistentStateRequired;
--- a/dom/media/eme/DecryptorProxyCallback.h
+++ b/dom/media/eme/DecryptorProxyCallback.h
@@ -1,24 +1,25 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 DecryptorProxyCallback_h_
 #define DecryptorProxyCallback_h_
 
-#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus
+#include "mozilla/CDMProxy.h"
 #include "mozilla/dom/MediaKeyMessageEventBinding.h" // For MediaKeyMessageType
-#include "mozilla/CDMProxy.h"
+#include "mozilla/dom/MediaKeyStatusMapBinding.h"    // For MediaKeyStatus
 
-class DecryptorProxyCallback {
+class DecryptorProxyCallback
+{
 public:
 
-  virtual ~DecryptorProxyCallback() {}
+  virtual ~DecryptorProxyCallback() { }
 
   virtual void SetDecryptorId(uint32_t aId) = 0;
 
   virtual void SetSessionId(uint32_t aCreateSessionId,
                             const nsCString& aSessionId) = 0;
 
   virtual void ResolveLoadSessionPromise(uint32_t aPromiseId,
                                          bool aSuccess) = 0;
@@ -42,13 +43,14 @@ public:
                             nsresult aException,
                             uint32_t aSystemCode,
                             const nsCString& aMessage) = 0;
 
   virtual void Decrypted(uint32_t aId,
                          mozilla::DecryptStatus aResult,
                          const nsTArray<uint8_t>& aDecryptedData) = 0;
 
-  virtual void BatchedKeyStatusChanged(const nsCString& aSessionId,
-                                       const nsTArray<mozilla::CDMKeyInfo>& aKeyInfos) = 0;
+  virtual void BatchedKeyStatusChanged(
+    const nsCString& aSessionId,
+    const nsTArray<mozilla::CDMKeyInfo>& aKeyInfos) = 0;
 };
 
 #endif
--- a/dom/media/eme/DetailedPromise.cpp
+++ b/dom/media/eme/DetailedPromise.cpp
@@ -73,17 +73,18 @@ DetailedPromise::Create(nsIGlobalObject*
 
 /* static */ already_AddRefed<DetailedPromise>
 DetailedPromise::Create(nsIGlobalObject* aGlobal,
                         ErrorResult& aRv,
                         const nsACString& aName,
                         Telemetry::ID aSuccessLatencyProbe,
                         Telemetry::ID aFailureLatencyProbe)
 {
-  RefPtr<DetailedPromise> promise = new DetailedPromise(aGlobal, aName, aSuccessLatencyProbe, aFailureLatencyProbe);
+  RefPtr<DetailedPromise> promise = new DetailedPromise(
+    aGlobal, aName, aSuccessLatencyProbe, aFailureLatencyProbe);
   promise->CreateWrapper(nullptr, aRv);
   return aRv.Failed() ? nullptr : promise.forget();
 }
 
 void
 DetailedPromise::MaybeReportTelemetry(Status aStatus)
 {
   if (mResponded) {
--- a/dom/media/eme/DetailedPromise.h
+++ b/dom/media/eme/DetailedPromise.h
@@ -2,19 +2,19 @@
 /* vim: set ts=2 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 __DetailedPromise_h__
 #define __DetailedPromise_h__
 
-#include "mozilla/dom/Promise.h"
+#include "EMEUtils.h"
 #include "mozilla/Telemetry.h"
-#include "EMEUtils.h"
+#include "mozilla/dom/Promise.h"
 
 namespace mozilla {
 namespace dom {
 
 /*
  * This is pretty horrible; bug 1160445.
  * Extend Promise to add custom DOMException messages on rejection.
  * Get rid of this once we've ironed out EME errors in the wild.
--- a/dom/media/eme/EMEUtils.cpp
+++ b/dom/media/eme/EMEUtils.cpp
@@ -4,45 +4,51 @@
  * 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 "mozilla/EMEUtils.h"
 #include "mozilla/dom/UnionTypes.h"
 
 namespace mozilla {
 
-LogModule* GetEMELog() {
+LogModule* GetEMELog()
+{
   static LazyLogModule log("EME");
   return log;
 }
 
-LogModule* GetEMEVerboseLog() {
+LogModule* GetEMEVerboseLog()
+{
   static LazyLogModule log("EMEV");
   return log;
 }
 
 ArrayData
-GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView)
+GetArrayBufferViewOrArrayBufferData(
+  const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView)
 {
-  MOZ_ASSERT(aBufferOrView.IsArrayBuffer() || aBufferOrView.IsArrayBufferView());
+  MOZ_ASSERT(aBufferOrView.IsArrayBuffer()
+             || aBufferOrView.IsArrayBufferView());
   if (aBufferOrView.IsArrayBuffer()) {
     const dom::ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer();
     buffer.ComputeLengthAndData();
     return ArrayData(buffer.Data(), buffer.Length());
   } else if (aBufferOrView.IsArrayBufferView()) {
-    const dom::ArrayBufferView& bufferview = aBufferOrView.GetAsArrayBufferView();
+    const dom::ArrayBufferView& bufferview =
+      aBufferOrView.GetAsArrayBufferView();
     bufferview.ComputeLengthAndData();
     return ArrayData(bufferview.Data(), bufferview.Length());
   }
   return ArrayData(nullptr, 0);
 }
 
 void
-CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
-                                     nsTArray<uint8_t>& aOutData)
+CopyArrayBufferViewOrArrayBufferData(
+  const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
+  nsTArray<uint8_t>& aOutData)
 {
   ArrayData data = GetArrayBufferViewOrArrayBufferData(aBufferOrView);
   aOutData.Clear();
   if (!data.IsValid()) {
     return;
   }
   aOutData.AppendElements(data.mData, data.mLength);
 }
--- a/dom/media/eme/EMEUtils.h
+++ b/dom/media/eme/EMEUtils.h
@@ -15,56 +15,60 @@
 namespace mozilla {
 
 namespace dom {
 class ArrayBufferViewOrArrayBuffer;
 }
 
 #ifndef EME_LOG
   LogModule* GetEMELog();
-  #define EME_LOG(...) MOZ_LOG(GetEMELog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
-  #define EME_LOG_ENABLED() MOZ_LOG_TEST(GetEMELog(), mozilla::LogLevel::Debug)
+#define EME_LOG(...)                                                           \
+  MOZ_LOG(GetEMELog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
+#define EME_LOG_ENABLED() MOZ_LOG_TEST(GetEMELog(), mozilla::LogLevel::Debug)
+#endif
+
+#ifndef EME_VERBOSE_LOG
+  LogModule*
+  GetEMEVerboseLog();
+#define EME_VERBOSE_LOG(...)                                                   \
+  MOZ_LOG(GetEMEVerboseLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
+#else
+#ifndef EME_LOG
+#define EME_LOG(...)
 #endif
 
 #ifndef EME_VERBOSE_LOG
-  LogModule* GetEMEVerboseLog();
-  #define EME_VERBOSE_LOG(...) MOZ_LOG(GetEMEVerboseLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
-#else
-  #ifndef EME_LOG
-    #define EME_LOG(...)
-  #endif
-
-  #ifndef EME_VERBOSE_LOG
-    #define EME_VERBOSE_LOG(...)
-  #endif
+#define EME_VERBOSE_LOG(...)
+#endif
 #endif
 
-// Helper function to extract a copy of data coming in from JS in an
-// (ArrayBuffer or ArrayBufferView) IDL typed function argument.
-//
-// Only call this on a properly initialized ArrayBufferViewOrArrayBuffer.
-void
-CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
-                                     nsTArray<uint8_t>& aOutData);
+  // Helper function to extract a copy of data coming in from JS in an
+  // (ArrayBuffer or ArrayBufferView) IDL typed function argument.
+  //
+  // Only call this on a properly initialized ArrayBufferViewOrArrayBuffer.
+  void
+  CopyArrayBufferViewOrArrayBufferData(
+    const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
+    nsTArray<uint8_t>& aOutData);
 
-struct ArrayData {
-  explicit ArrayData(const uint8_t* aData, size_t aLength)
-    : mData(aData)
-    , mLength(aLength)
+  struct ArrayData
   {
-  }
-  const uint8_t* mData;
-  const size_t mLength;
-  bool IsValid() const {
-    return mData != nullptr && mLength != 0;
-  }
-  bool operator== (const nsTArray<uint8_t>& aOther) const {
-    return mLength == aOther.Length() &&
-           memcmp(mData, aOther.Elements(), mLength) == 0;
-  }
+    explicit ArrayData(const uint8_t* aData, size_t aLength)
+      : mData(aData)
+      , mLength(aLength)
+    {
+    }
+    const uint8_t* mData;
+    const size_t mLength;
+    bool IsValid() const { return mData != nullptr && mLength != 0; }
+    bool operator==(const nsTArray<uint8_t>& aOther) const
+    {
+      return mLength == aOther.Length() &&
+             memcmp(mData, aOther.Elements(), mLength) == 0;
+    }
 };
 
 // Helper function to extract data coming in from JS in an
 // (ArrayBuffer or ArrayBufferView) IDL typed function argument.
 //
 // Be *very* careful with this!
 //
 // Only use returned ArrayData inside the lifetime of the
@@ -73,31 +77,33 @@ struct ArrayData {
 //
 // And do *not* call out to anything that could call into JavaScript,
 // while the ArrayData is live, as then all bets about the data not changing
 // are off! No calls into JS, no calls into JS-implemented WebIDL or XPIDL,
 // nothing. Beware!
 //
 // Only call this on a properly initialized ArrayBufferViewOrArrayBuffer.
 ArrayData
-GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView);
+GetArrayBufferViewOrArrayBufferData(
+  const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView);
 
 nsString
 KeySystemToGMPName(const nsAString& aKeySystem);
 
 bool
 IsClearkeyKeySystem(const nsAString& aKeySystem);
 
 bool
 IsWidevineKeySystem(const nsAString& aKeySystem);
 
 // Note: Primetime is now unsupported, but we leave it in the enum so
 // that the telemetry enum values are not changed; doing so would break
 // existing telemetry probes.
-enum CDMType {
+enum CDMType
+{
   eClearKey = 0,
   ePrimetime = 1, // Note: Unsupported.
   eWidevine = 2,
   eUnknown = 3
 };
 
 CDMType
 ToCDMTypeTelemetryEnum(const nsString& aKeySystem);
--- a/dom/media/eme/MediaEncryptedEvent.cpp
+++ b/dom/media/eme/MediaEncryptedEvent.cpp
@@ -1,20 +1,20 @@
 /* -*- 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 "MediaEncryptedEvent.h"
+#include "jsfriendapi.h"
 #include "mozilla/dom/MediaEncryptedEventBinding.h"
+#include "mozilla/dom/MediaKeys.h"
 #include "nsContentUtils.h"
-#include "jsfriendapi.h"
 #include "nsINode.h"
-#include "mozilla/dom/MediaKeys.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(MediaEncryptedEvent)
 
 NS_IMPL_ADDREF_INHERITED(MediaEncryptedEvent, Event)
 NS_IMPL_RELEASE_INHERITED(MediaEncryptedEvent, Event)
@@ -42,17 +42,18 @@ MediaEncryptedEvent::MediaEncryptedEvent
 
 MediaEncryptedEvent::~MediaEncryptedEvent()
 {
   mInitData = nullptr;
   mozilla::DropJSObjects(this);
 }
 
 JSObject*
-MediaEncryptedEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+MediaEncryptedEvent::WrapObjectInternal(JSContext* aCx,
+                                        JS::Handle<JSObject*> aGivenProto)
 {
   return MediaEncryptedEventBinding::Wrap(aCx, this, aGivenProto);
 }
 
 already_AddRefed<MediaEncryptedEvent>
 MediaEncryptedEvent::Constructor(EventTarget* aOwner)
 {
   RefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(aOwner);
--- a/dom/media/eme/MediaEncryptedEvent.h
+++ b/dom/media/eme/MediaEncryptedEvent.h
@@ -2,27 +2,26 @@
 /* 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_MediaKeyNeededEvent_h__
 #define mozilla_dom_MediaKeyNeededEvent_h__
 
-#include "mozilla/dom/MediaEncryptedEventBinding.h"
+#include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/Event.h"
+#include "mozilla/dom/MediaEncryptedEventBinding.h"
+#include "mozilla/dom/TypedArray.h"
+#include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
-#include "nsCOMPtr.h"
-#include "mozilla/dom/Event.h"
-#include "mozilla/dom/TypedArray.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/dom/BindingUtils.h"
-#include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class MediaEncryptedEvent final : public Event
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
@@ -30,18 +29,18 @@ public:
 protected:
   virtual ~MediaEncryptedEvent();
   explicit MediaEncryptedEvent(EventTarget* aOwner);
 
   nsString mInitDataType;
   JS::Heap<JSObject*> mInitData;
 
 public:
-
-  JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObjectInternal(JSContext* aCx,
+                               JS::Handle<JSObject*> aGivenProto) override;
 
   static already_AddRefed<MediaEncryptedEvent>
   Constructor(EventTarget* aOwner);
 
   static already_AddRefed<MediaEncryptedEvent>
   Constructor(EventTarget* aOwner,
               const nsAString& aInitDataType,
               const nsTArray<uint8_t>& aInitData);
--- a/dom/media/eme/MediaKeyError.cpp
+++ b/dom/media/eme/MediaKeyError.cpp
@@ -24,16 +24,17 @@ MediaKeyError::~MediaKeyError()
 
 uint32_t
 MediaKeyError::SystemCode() const
 {
   return mSystemCode;
 }
 
 JSObject*
-MediaKeyError::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+MediaKeyError::WrapObjectInternal(JSContext* aCx,
+                                  JS::Handle<JSObject*> aGivenProto)
 {
   return MediaKeyErrorBinding::Wrap(aCx, this, aGivenProto);
 }
 
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/eme/MediaKeyError.h
+++ b/dom/media/eme/MediaKeyError.h
@@ -2,34 +2,35 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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_MediaKeyError_h
 #define mozilla_dom_MediaKeyError_h
 
+#include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/dom/Event.h"
 #include "nsWrapperCache.h"
-#include "mozilla/dom/Event.h"
-#include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class MediaKeyError final : public Event
 {
 public:
   NS_FORWARD_TO_EVENT
 
   MediaKeyError(EventTarget* aOwner, uint32_t aSystemCode);
   ~MediaKeyError();
 
-  JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObjectInternal(JSContext* aCx,
+                               JS::Handle<JSObject*> aGivenProto) override;
 
   uint32_t SystemCode() const;
 
 private:
   uint32_t mSystemCode;
 };
 
 } // namespace dom
--- a/dom/media/eme/MediaKeyMessageEvent.cpp
+++ b/dom/media/eme/MediaKeyMessageEvent.cpp
@@ -1,24 +1,24 @@
 /* -*- 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 "mozilla/dom/MediaKeyMessageEvent.h"
-#include "mozilla/dom/MediaKeyMessageEventBinding.h"
 #include "js/GCAPI.h"
 #include "jsfriendapi.h"
+#include "mozilla/HoldDropJSObjects.h"
+#include "mozilla/dom/MediaKeyMessageEventBinding.h"
+#include "mozilla/dom/MediaKeys.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/dom/PrimitiveConversions.h"
-#include "mozilla/HoldDropJSObjects.h"
 #include "mozilla/dom/TypedArray.h"
 #include "nsContentUtils.h"
-#include "mozilla/dom/MediaKeys.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(MediaKeyMessageEvent)
 
 NS_IMPL_ADDREF_INHERITED(MediaKeyMessageEvent, Event)
 NS_IMPL_RELEASE_INHERITED(MediaKeyMessageEvent, Event)
@@ -52,17 +52,18 @@ MediaKeyMessageEvent::~MediaKeyMessageEv
 
 MediaKeyMessageEvent*
 MediaKeyMessageEvent::AsMediaKeyMessageEvent()
 {
   return this;
 }
 
 JSObject*
-MediaKeyMessageEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+MediaKeyMessageEvent::WrapObjectInternal(JSContext* aCx,
+                                         JS::Handle<JSObject*> aGivenProto)
 {
   return MediaKeyMessageEventBinding::Wrap(aCx, this, aGivenProto);
 }
 
 already_AddRefed<MediaKeyMessageEvent>
 MediaKeyMessageEvent::Constructor(EventTarget* aOwner,
                                   MediaKeyMessageType aMessageType,
                                   const nsTArray<uint8_t>& aMessage)
@@ -71,20 +72,21 @@ MediaKeyMessageEvent::Constructor(EventT
   e->InitEvent(NS_LITERAL_STRING("message"), false, false);
   e->mMessageType = aMessageType;
   e->mRawMessage = aMessage;
   e->SetTrusted(true);
   return e.forget();
 }
 
 already_AddRefed<MediaKeyMessageEvent>
-MediaKeyMessageEvent::Constructor(const GlobalObject& aGlobal,
-                                  const nsAString& aType,
-                                  const MediaKeyMessageEventInit& aEventInitDict,
-                                  ErrorResult& aRv)
+MediaKeyMessageEvent::Constructor(
+  const GlobalObject& aGlobal,
+  const nsAString& aType,
+  const MediaKeyMessageEventInit& aEventInitDict,
+  ErrorResult& aRv)
 {
   nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
   RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner);
   bool trusted = e->Init(owner);
   e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
   aEventInitDict.mMessage.ComputeLengthAndData();
   e->mMessage = ArrayBuffer::Create(aGlobal.Context(),
                                     aEventInitDict.mMessage.Length(),
--- a/dom/media/eme/MediaKeyMessageEvent.h
+++ b/dom/media/eme/MediaKeyMessageEvent.h
@@ -2,25 +2,25 @@
 /* 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_MediaKeyMessageEvent_h__
 #define mozilla_dom_MediaKeyMessageEvent_h__
 
+#include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/dom/Event.h"
+#include "mozilla/dom/MediaKeyMessageEventBinding.h"
+#include "mozilla/dom/TypedArray.h"
+#include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
-#include "nsCOMPtr.h"
-#include "mozilla/dom/Event.h"
-#include "mozilla/dom/TypedArray.h"
-#include "js/TypeDecls.h"
-#include "mozilla/dom/MediaKeyMessageEventBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 struct MediaKeyMessageEventInit;
 
 class MediaKeyMessageEvent final : public Event
 {
@@ -32,17 +32,18 @@ protected:
   explicit MediaKeyMessageEvent(EventTarget* aOwner);
 
   MediaKeyMessageType mMessageType;
   JS::Heap<JSObject*> mMessage;
 
 public:
   virtual MediaKeyMessageEvent* AsMediaKeyMessageEvent();
 
-  JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObjectInternal(JSContext* aCx,
+                               JS::Handle<JSObject*> aGivenProto) override;
 
   static already_AddRefed<MediaKeyMessageEvent>
   Constructor(EventTarget* aOwner,
               MediaKeyMessageType aMessageType,
               const nsTArray<uint8_t>& aMessage);
 
   static already_AddRefed<MediaKeyMessageEvent>
   Constructor(const GlobalObject& aGlobal,
--- a/dom/media/eme/MediaKeySession.cpp
+++ b/dom/media/eme/MediaKeySession.cpp
@@ -1,29 +1,29 @@
 /* -*- 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 "mozilla/dom/MediaKeySession.h"
+#include "GMPUtils.h"
+#include "mozilla/AsyncEventDispatcher.h"
+#include "mozilla/CDMProxy.h"
+#include "mozilla/EMEUtils.h"
+#include "mozilla/Move.h"
 #include "mozilla/dom/HTMLMediaElement.h"
-#include "mozilla/dom/MediaKeySession.h"
+#include "mozilla/dom/KeyIdsInitDataBinding.h"
+#include "mozilla/dom/MediaEncryptedEvent.h"
 #include "mozilla/dom/MediaKeyError.h"
 #include "mozilla/dom/MediaKeyMessageEvent.h"
-#include "mozilla/dom/MediaEncryptedEvent.h"
 #include "mozilla/dom/MediaKeyStatusMap.h"
 #include "mozilla/dom/MediaKeySystemAccess.h"
-#include "mozilla/dom/KeyIdsInitDataBinding.h"
+#include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
-#include "mozilla/CDMProxy.h"
-#include "mozilla/AsyncEventDispatcher.h"
-#include "mozilla/Move.h"
-#include "nsContentUtils.h"
-#include "mozilla/EMEUtils.h"
-#include "GMPUtils.h"
 #include "nsPrintfCString.h"
 #include "psshparser/PsshParser.h"
 #include <ctime>
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(MediaKeySession,
@@ -72,31 +72,30 @@ MediaKeySession::MediaKeySession(JSConte
 
   MOZ_ASSERT(aParent);
   if (aRv.Failed()) {
     return;
   }
   mClosed = MakePromise(aRv, NS_LITERAL_CSTRING("MediaKeys.createSession"));
 }
 
-void MediaKeySession::SetSessionId(const nsAString& aSessionId)
+void
+MediaKeySession::SetSessionId(const nsAString& aSessionId)
 {
   EME_LOG("MediaKeySession[%p,'%s'] session Id set",
           this, NS_ConvertUTF16toUTF8(aSessionId).get());
 
   if (NS_WARN_IF(!mSessionId.IsEmpty())) {
     return;
   }
   mSessionId = aSessionId;
   mKeys->OnSessionIdReady(this);
 }
 
-MediaKeySession::~MediaKeySession()
-{
-}
+MediaKeySession::~MediaKeySession() { }
 
 MediaKeyError*
 MediaKeySession::GetError() const
 {
   return mMediaKeyError;
 }
 
 void
@@ -171,37 +170,41 @@ MediaKeySession::KeyStatuses() const
 // reasonable limits, and stripping irrelevant, unsupported, or unknown
 // data or fields. It is RECOMMENDED that user agents pre-parse, sanitize,
 // and/or generate a fully sanitized version of the Initialization Data.
 // If the Initialization Data format specified by initDataType supports
 // multiple entries, the user agent SHOULD remove entries that are not
 // needed by the CDM. The user agent MUST NOT re-order entries within
 // the Initialization Data.
 static bool
-ValidateInitData(const nsTArray<uint8_t>& aInitData, const nsAString& aInitDataType)
+ValidateInitData(const nsTArray<uint8_t>& aInitData,
+                 const nsAString& aInitDataType)
 {
   if (aInitDataType.LowerCaseEqualsLiteral("webm")) {
-    // WebM initData consists of a single keyId. Ensure it's of reasonable length.
+    // WebM initData consists of a single keyId. Ensure it's of reasonable
+    // length.
     return aInitData.Length() <= MAX_KEY_ID_LENGTH;
   } else if (aInitDataType.LowerCaseEqualsLiteral("cenc")) {
     // Limit initData to less than 64KB.
     if (aInitData.Length() > MAX_CENC_INIT_DATA_LENGTH) {
       return false;
     }
     std::vector<std::vector<uint8_t>> keyIds;
     return ParseCENCInitData(aInitData.Elements(), aInitData.Length(), keyIds);
   } else if (aInitDataType.LowerCaseEqualsLiteral("keyids")) {
     if (aInitData.Length() > MAX_KEY_ID_LENGTH) {
       return false;
     }
     // Ensure that init data matches the expected JSON format.
     mozilla::dom::KeyIdsInitData keyIds;
     nsString json;
-    nsDependentCSubstring raw(reinterpret_cast<const char*>(aInitData.Elements()), aInitData.Length());
-    if (NS_FAILED(nsContentUtils::ConvertStringFromEncoding(NS_LITERAL_CSTRING("UTF-8"), raw, json))) {
+    nsDependentCSubstring raw(
+      reinterpret_cast<const char*>(aInitData.Elements()), aInitData.Length());
+    if (NS_FAILED(nsContentUtils::ConvertStringFromEncoding(
+          NS_LITERAL_CSTRING("UTF-8"), raw, json))) {
       return false;
     }
     if (!keyIds.Init(json)) {
       return false;
     }
     if (keyIds.mKids.Length() == 0) {
       return false;
     }
@@ -223,89 +226,111 @@ MediaKeySession::GenerateRequest(const n
                                  ErrorResult& aRv)
 {
   RefPtr<DetailedPromise> promise(MakePromise(aRv,
     NS_LITERAL_CSTRING("MediaKeySession.generateRequest")));
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  // If this object is closed, return a promise rejected with an InvalidStateError.
+  // If this object is closed, return a promise rejected with an
+  // InvalidStateError.
   if (IsClosed()) {
     EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, closed",
             this, NS_ConvertUTF16toUTF8(mSessionId).get());
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-      NS_LITERAL_CSTRING("Session is closed in MediaKeySession.generateRequest()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "Session is closed in MediaKeySession.generateRequest()"));
     return promise.forget();
   }
 
   // If this object's uninitialized value is false, return a promise rejected
   // with an InvalidStateError.
   if (!mUninitialized) {
     EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, uninitialized",
             this, NS_ConvertUTF16toUTF8(mSessionId).get());
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-      NS_LITERAL_CSTRING("Session is already initialized in MediaKeySession.generateRequest()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "Session is already initialized in MediaKeySession.generateRequest()"));
     return promise.forget();
   }
 
   // Let this object's uninitialized value be false.
   mUninitialized = false;
 
   // If initDataType is the empty string, return a promise rejected
   // with a newly created TypeError.
   if (aInitDataType.IsEmpty()) {
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-      NS_LITERAL_CSTRING("Empty initDataType passed to MediaKeySession.generateRequest()"));
-    EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, empty initDataType",
-      this, NS_ConvertUTF16toUTF8(mSessionId).get());
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING(
+        "Empty initDataType passed to MediaKeySession.generateRequest()"));
+    EME_LOG(
+      "MediaKeySession[%p,'%s'] GenerateRequest() failed, empty initDataType",
+      this,
+      NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
 
   // If initData is an empty array, return a promise rejected with
   // a newly created TypeError.
   nsTArray<uint8_t> data;
   CopyArrayBufferViewOrArrayBufferData(aInitData, data);
   if (data.IsEmpty()) {
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-      NS_LITERAL_CSTRING("Empty initData passed to MediaKeySession.generateRequest()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING(
+        "Empty initData passed to MediaKeySession.generateRequest()"));
     EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, empty initData",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+            this,
+            NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
 
   // If the Key System implementation represented by this object's
   // cdm implementation value does not support initDataType as an
   // Initialization Data Type, return a promise rejected with a
   // NotSupportedError. String comparison is case-sensitive.
-  if (!MediaKeySystemAccess::KeySystemSupportsInitDataType(mKeySystem, aInitDataType)) {
-    promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
-      NS_LITERAL_CSTRING("Unsupported initDataType passed to MediaKeySession.generateRequest()"));
-    EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, unsupported initDataType",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+  if (!MediaKeySystemAccess::KeySystemSupportsInitDataType(mKeySystem,
+                                                           aInitDataType)) {
+    promise->MaybeReject(
+      NS_ERROR_DOM_NOT_SUPPORTED_ERR,
+      NS_LITERAL_CSTRING("Unsupported initDataType passed to "
+                         "MediaKeySession.generateRequest()"));
+    EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, unsupported "
+            "initDataType",
+            this,
+            NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
 
   // Let init data be a copy of the contents of the initData parameter.
   // Note: Handled by the CopyArrayBufferViewOrArrayBufferData call above.
 
   // Let session type be this object's session type.
 
   // Let promise be a new promise.
 
   // Run the following steps in parallel:
 
   // If the init data is not valid for initDataType, reject promise with
   // a newly created TypeError.
   if (!ValidateInitData(data, aInitDataType)) {
-    // If the preceding step failed, reject promise with a newly created TypeError.
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-      NS_LITERAL_CSTRING("initData sanitization failed in MediaKeySession.generateRequest()"));
-    EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() initData sanitization failed",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+    // If the preceding step failed, reject promise with a newly created
+    // TypeError.
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING(
+        "initData sanitization failed in MediaKeySession.generateRequest()"));
+    EME_LOG(
+      "MediaKeySession[%p,'%s'] GenerateRequest() initData sanitization failed",
+      this,
+      NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
 
   // Let sanitized init data be a validated and sanitized version of init data.
 
   // If sanitized init data is empty, reject promise with a NotSupportedError.
 
   // Note: Remaining steps of generateRequest method continue in CDM.
@@ -336,54 +361,65 @@ already_AddRefed<Promise>
 MediaKeySession::Load(const nsAString& aSessionId, ErrorResult& aRv)
 {
   RefPtr<DetailedPromise> promise(MakePromise(aRv,
     NS_LITERAL_CSTRING("MediaKeySession.load")));
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  // 1. If this object is closed, return a promise rejected with an InvalidStateError.
+  // 1. If this object is closed, return a promise rejected with an
+  // InvalidStateError.
   if (IsClosed()) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Session is closed in MediaKeySession.load()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Session is closed in MediaKeySession.load()"));
     EME_LOG("MediaKeySession[%p,'%s'] Load() failed, closed",
-      this, NS_ConvertUTF16toUTF8(aSessionId).get());
+            this,
+            NS_ConvertUTF16toUTF8(aSessionId).get());
     return promise.forget();
   }
 
   // 2.If this object's uninitialized value is false, return a promise rejected
   // with an InvalidStateError.
   if (!mUninitialized) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Session is already initialized in MediaKeySession.load()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "Session is already initialized in MediaKeySession.load()"));
     EME_LOG("MediaKeySession[%p,'%s'] Load() failed, uninitialized",
-      this, NS_ConvertUTF16toUTF8(aSessionId).get());
+            this,
+            NS_ConvertUTF16toUTF8(aSessionId).get());
     return promise.forget();
   }
 
   // 3.Let this object's uninitialized value be false.
   mUninitialized = false;
 
-  // 4. If sessionId is the empty string, return a promise rejected with a newly created TypeError.
+  // 4. If sessionId is the empty string, return a promise rejected with a newly
+  // created TypeError.
   if (aSessionId.IsEmpty()) {
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-                         NS_LITERAL_CSTRING("Trying to load a session with empty session ID"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING("Trying to load a session with empty session ID"));
     // "The sessionId parameter is empty."
     EME_LOG("MediaKeySession[%p,''] Load() failed, no sessionId", this);
     return promise.forget();
   }
 
   // 5. If the result of running the Is persistent session type? algorithm
   // on this object's session type is false, return a promise rejected with
   // a newly created TypeError.
   if (mSessionType == MediaKeySessionType::Temporary) {
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-                         NS_LITERAL_CSTRING("Trying to load() into a non-persistent session"));
-    EME_LOG("MediaKeySession[%p,''] Load() failed, can't load in a non-persistent session", this);
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING("Trying to load() into a non-persistent session"));
+    EME_LOG("MediaKeySession[%p,''] Load() failed, can't load in a "
+            "non-persistent session",
+            this);
     return promise.forget();
   }
 
   // Note: We don't support persistent sessions in any keysystem, so all calls
   // to Load() should reject with a TypeError in the preceding check. Omitting
   // implementing the rest of the specified MediaKeySession::Load() algorithm.
 
   // We now know the sessionId being loaded into this session. Remove the
@@ -399,47 +435,58 @@ MediaKeySession::Load(const nsAString& a
 
   EME_LOG("MediaKeySession[%p,'%s'] Load() sent to CDM, promiseId=%d",
     this, NS_ConvertUTF16toUTF8(mSessionId).get(), pid);
 
   return promise.forget();
 }
 
 already_AddRefed<Promise>
-MediaKeySession::Update(const ArrayBufferViewOrArrayBuffer& aResponse, ErrorResult& aRv)
+MediaKeySession::Update(const ArrayBufferViewOrArrayBuffer& aResponse,
+                        ErrorResult& aRv)
 {
   RefPtr<DetailedPromise> promise(MakePromise(aRv,
     NS_LITERAL_CSTRING("MediaKeySession.update")));
   if (aRv.Failed()) {
     return nullptr;
   }
 
   if (!IsCallable()) {
     // If this object's callable value is false, return a promise rejected
     // with a new DOMException whose name is InvalidStateError.
-    EME_LOG("MediaKeySession[%p,''] Update() called before sessionId set by CDM", this);
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-      NS_LITERAL_CSTRING("MediaKeySession.Update() called before sessionId set by CDM"));
+    EME_LOG(
+      "MediaKeySession[%p,''] Update() called before sessionId set by CDM",
+      this);
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "MediaKeySession.Update() called before sessionId set by CDM"));
     return promise.forget();
   }
 
   nsTArray<uint8_t> data;
   if (IsClosed() || !mKeys->GetCDMProxy()) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Session is closed or was not properly initialized"));
-    EME_LOG("MediaKeySession[%p,'%s'] Update() failed, session is closed or was not properly initialised.",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Session is closed or was not properly initialized"));
+    EME_LOG("MediaKeySession[%p,'%s'] Update() failed, session is closed or "
+            "was not properly initialised.",
+            this,
+            NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
   CopyArrayBufferViewOrArrayBufferData(aResponse, data);
   if (data.IsEmpty()) {
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-      NS_LITERAL_CSTRING("Empty response buffer passed to MediaKeySession.update()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING(
+        "Empty response buffer passed to MediaKeySession.update()"));
     EME_LOG("MediaKeySession[%p,'%s'] Update() failed, empty response buffer",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+            this,
+            NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
 
 
   // Convert response to hex for easier logging.
   // Note: UpdateSession() Move()s the data out of the array, so we have
   // to copy it here.
   nsAutoCString hexResponse(ToHexString(data));
@@ -473,19 +520,22 @@ MediaKeySession::Close(ErrorResult& aRv)
     EME_LOG("MediaKeySession[%p,'%s'] Close() already closed",
             this, NS_ConvertUTF16toUTF8(mSessionId).get());
     promise->MaybeResolveWithUndefined();
     return promise.forget();
   }
   // 3. If session's callable value is false, return a promise rejected
   // with an InvalidStateError.
   if (!IsCallable()) {
-    EME_LOG("MediaKeySession[%p,''] Close() called before sessionId set by CDM", this);
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-      NS_LITERAL_CSTRING("MediaKeySession.Close() called before sessionId set by CDM"));
+    EME_LOG("MediaKeySession[%p,''] Close() called before sessionId set by CDM",
+            this);
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "MediaKeySession.Close() called before sessionId set by CDM"));
     return promise.forget();
   }
   if (!mKeys->GetCDMProxy()) {
     EME_LOG("MediaKeySession[%p,'%s'] Close() null CDMProxy",
             this, NS_ConvertUTF16toUTF8(mSessionId).get());
     promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
       NS_LITERAL_CSTRING("MediaKeySession.Close() lost reference to CDM"));
     return promise.forget();
@@ -532,54 +582,66 @@ MediaKeySession::Remove(ErrorResult& aRv
   RefPtr<DetailedPromise> promise(MakePromise(aRv,
     NS_LITERAL_CSTRING("MediaKeySession.remove")));
   if (aRv.Failed()) {
     return nullptr;
   }
   if (!IsCallable()) {
     // If this object's callable value is false, return a promise rejected
     // with a new DOMException whose name is InvalidStateError.
-    EME_LOG("MediaKeySession[%p,''] Remove() called before sessionId set by CDM", this);
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-      NS_LITERAL_CSTRING("MediaKeySession.Remove() called before sessionId set by CDM"));
+    EME_LOG(
+      "MediaKeySession[%p,''] Remove() called before sessionId set by CDM",
+      this);
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "MediaKeySession.Remove() called before sessionId set by CDM"));
     return promise.forget();
   }
   if (mSessionType != MediaKeySessionType::Persistent_license) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
-                         NS_LITERAL_CSTRING("Calling MediaKeySession.remove() on non-persistent session"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_ACCESS_ERR,
+      NS_LITERAL_CSTRING(
+        "Calling MediaKeySession.remove() on non-persistent session"));
     // "The operation is not supported on session type sessions."
     EME_LOG("MediaKeySession[%p,'%s'] Remove() failed, sesion not persisrtent.",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+            this,
+            NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
   if (IsClosed() || !mKeys->GetCDMProxy()) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("MediaKeySesison.remove() called but session is not active"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "MediaKeySesison.remove() called but session is not active"));
     // "The session is closed."
     EME_LOG("MediaKeySession[%p,'%s'] Remove() failed, already session closed.",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get());
+            this,
+            NS_ConvertUTF16toUTF8(mSessionId).get());
     return promise.forget();
   }
   PromiseId pid = mKeys->StorePromise(promise);
   mKeys->GetCDMProxy()->RemoveSession(mSessionId, pid);
   EME_LOG("MediaKeySession[%p,'%s'] Remove() sent to CDM, promiseId=%d.",
           this, NS_ConvertUTF16toUTF8(mSessionId).get(), pid);
 
   return promise.forget();
 }
 
 void
 MediaKeySession::DispatchKeyMessage(MediaKeyMessageType aMessageType,
                                     const nsTArray<uint8_t>& aMessage)
 {
   if (EME_LOG_ENABLED()) {
-    EME_LOG("MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message='%s'",
-            this, NS_ConvertUTF16toUTF8(mSessionId).get(),
-            MediaKeyMessageTypeValues::strings[uint32_t(aMessageType)].value,
-            ToHexString(aMessage).get());
+    EME_LOG(
+      "MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message='%s'",
+      this,
+      NS_ConvertUTF16toUTF8(mSessionId).get(),
+      MediaKeyMessageTypeValues::strings[uint32_t(aMessageType)].value,
+      ToHexString(aMessage).get());
   }
 
   RefPtr<MediaKeyMessageEvent> event(
     MediaKeyMessageEvent::Constructor(this, aMessageType, aMessage));
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, event);
   asyncDispatcher->PostDOMEvent();
 }
@@ -600,18 +662,18 @@ void
 MediaKeySession::DispatchKeyStatusesChange()
 {
   if (IsClosed()) {
     return;
   }
 
   UpdateKeyStatusMap();
 
-  RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(this, NS_LITERAL_STRING("keystatuseschange"), false);
+  RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
+    this, NS_LITERAL_STRING("keystatuseschange"), false);
   asyncDispatcher->PostDOMEvent();
 }
 
 uint32_t
 MediaKeySession::Token() const
 {
   return mToken;
 }
--- a/dom/media/eme/MediaKeySession.h
+++ b/dom/media/eme/MediaKeySession.h
@@ -3,28 +3,28 @@
 /* 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_MediaKeySession_h
 #define mozilla_dom_MediaKeySession_h
 
 #include "mozilla/Attributes.h"
+#include "mozilla/DOMEventTargetHelper.h"
+#include "mozilla/DetailedPromise.h"
 #include "mozilla/ErrorResult.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/DOMEventTargetHelper.h"
-#include "nsCOMPtr.h"
-#include "mozilla/dom/TypedArray.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/dom/Date.h"
-#include "mozilla/dom/Promise.h"
-#include "mozilla/DetailedPromise.h"
+#include "mozilla/dom/MediaKeyMessageEventBinding.h"
 #include "mozilla/dom/MediaKeySessionBinding.h"
 #include "mozilla/dom/MediaKeysBinding.h"
-#include "mozilla/dom/MediaKeyMessageEventBinding.h"
+#include "mozilla/dom/Promise.h"
+#include "mozilla/dom/TypedArray.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
 
 struct JSContext;
 
 namespace mozilla {
 namespace dom {
 
 class ArrayBufferViewOrArrayBuffer;
 class MediaKeyError;
@@ -41,17 +41,18 @@ public:
                   nsPIDOMWindowInner* aParent,
                   MediaKeys* aKeys,
                   const nsAString& aKeySystem,
                   MediaKeySessionType aSessionType,
                   ErrorResult& aRv);
 
   void SetSessionId(const nsAString& aSessionId);
 
-  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override;
 
   // Mark this as resultNotAddRefed to return raw pointers
   MediaKeyError* GetError() const;
 
   MediaKeyStatusMap* KeyStatuses() const;
 
   void GetSessionId(nsString& aRetval) const;
 
@@ -59,19 +60,20 @@ public:
 
   // Number of ms since epoch at which expiration occurs, or NaN if unknown.
   // TODO: The type of this attribute is still under contention.
   // https://www.w3.org/Bugs/Public/show_bug.cgi?id=25902
   double Expiration() const;
 
   Promise* Closed() const;
 
-  already_AddRefed<Promise> GenerateRequest(const nsAString& aInitDataType,
-                                            const ArrayBufferViewOrArrayBuffer& aInitData,
-                                            ErrorResult& aRv);
+  already_AddRefed<Promise> GenerateRequest(
+    const nsAString& aInitDataType,
+    const ArrayBufferViewOrArrayBuffer& aInitData,
+    ErrorResult& aRv);
 
   already_AddRefed<Promise> Load(const nsAString& aSessionId,
                                  ErrorResult& aRv);
 
   already_AddRefed<Promise> Update(const ArrayBufferViewOrArrayBuffer& response,
                                    ErrorResult& aRv);
 
   already_AddRefed<Promise> Close(ErrorResult& aRv);
@@ -100,17 +102,18 @@ public:
   // Process-unique identifier.
   uint32_t Token() const;
 
 private:
   ~MediaKeySession();
 
   void UpdateKeyStatusMap();
 
-  bool IsCallable() const {
+  bool IsCallable() const
+  {
     // The EME spec sets the "callable value" to true whenever the CDM sets
     // the sessionId. When the session is initialized, sessionId is empty and
     // callable is thus false.
     return !mSessionId.IsEmpty();
   }
 
   already_AddRefed<DetailedPromise> MakePromise(ErrorResult& aRv,
                                                 const nsACString& aName);
--- a/dom/media/eme/MediaKeyStatusMap.cpp
+++ b/dom/media/eme/MediaKeyStatusMap.cpp
@@ -1,19 +1,19 @@
 /* -*- 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 "mozilla/dom/MediaKeyStatusMap.h"
-#include "nsPIDOMWindow.h"
+#include "mozilla/EMEUtils.h"
+#include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/UnionTypes.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "mozilla/EMEUtils.h"
+#include "nsPIDOMWindow.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeyStatusMap)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeyStatusMap)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaKeyStatusMap)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@@ -50,20 +50,20 @@ MediaKeyStatusMap::Get(JSContext* aCx,
 {
   ArrayData keyId = GetArrayBufferViewOrArrayBufferData(aKey);
   if (!keyId.IsValid()) {
     aOutValue.setUndefined();
     return;
   }
   for (const KeyStatus& status : mStatuses) {
     if (keyId == status.mKeyId) {
-      bool ok = ToJSValue(aCx, status.mStatus, aOutValue);
-      if (!ok) {
-        aOutRv.NoteJSContextException(aCx);
-      }
+      bool ok = ToJSValue(aCx, status.mStatus, aOutValue);
+      if (!ok) {
+        aOutRv.NoteJSContextException(aCx);
+      }
       return;
     }
   }
   aOutValue.setUndefined();
 }
 
 bool
 MediaKeyStatusMap::Has(const ArrayBufferViewOrArrayBuffer& aKey) const
--- a/dom/media/eme/MediaKeyStatusMap.h
+++ b/dom/media/eme/MediaKeyStatusMap.h
@@ -2,25 +2,24 @@
 /* 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_MediaKeyStatuses_h
 #define mozilla_dom_MediaKeyStatuses_h
 
+#include "mozilla/Attributes.h"
+#include "mozilla/CDMCaps.h"
 #include "mozilla/ErrorResult.h"
-#include "mozilla/Attributes.h"
+#include "mozilla/dom/MediaKeyStatusMapBinding.h"
+#include "mozilla/dom/TypedArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
-#include "mozilla/dom/TypedArray.h"
-#include "mozilla/dom/MediaKeyStatusMapBinding.h"
-#include "mozilla/CDMCaps.h"
-
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 namespace dom {
 
 class ArrayBufferViewOrArrayBuffer;
 
 // The MediaKeyStatusMap WebIDL interface; maps a keyId to its status.
@@ -37,17 +36,18 @@ public:
   explicit MediaKeyStatusMap(nsPIDOMWindowInner* aParent);
 
 protected:
   ~MediaKeyStatusMap();
 
 public:
   nsPIDOMWindowInner* GetParentObject() const;
 
-  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override;
 
   void Get(JSContext* aCx,
            const ArrayBufferViewOrArrayBuffer& aKey,
            JS::MutableHandle<JS::Value> aOutValue,
            ErrorResult& aOutRv) const;
   bool Has(const ArrayBufferViewOrArrayBuffer& aKey) const;
   uint32_t Size() const;
 
@@ -56,27 +56,30 @@ public:
   MediaKeyStatus GetValueAtIndex(uint32_t aIndex) const;
 
   void Update(const nsTArray<CDMCaps::KeyStatus>& keys);
 
 private:
 
   nsCOMPtr<nsPIDOMWindowInner> mParent;
 
-  struct KeyStatus {
+  struct KeyStatus
+  {
     KeyStatus(const nsTArray<uint8_t>& aKeyId,
               MediaKeyStatus aStatus)
       : mKeyId(aKeyId)
       , mStatus(aStatus)
     {
     }
-    bool operator== (const KeyStatus& aOther) const {
+    bool operator== (const KeyStatus& aOther) const
+    {
       return aOther.mKeyId == mKeyId;
     }
-    bool operator<(const KeyStatus& aOther) const {
+    bool operator<(const KeyStatus& aOther) const
+    {
       // Copy chromium and compare keys' bytes.
       // Update once https://github.com/w3c/encrypted-media/issues/69
       // is resolved.
       const nsTArray<uint8_t>& other = aOther.mKeyId;
       const nsTArray<uint8_t>& self = mKeyId;
       size_t length = std::min<size_t>(other.Length(), self.Length());
       int cmp = memcmp(self.Elements(), other.Elements(), length);
       if (cmp != 0) {
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -1,74 +1,76 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 "DecoderDoctorDiagnostics.h"
+#include "GMPUtils.h"
+#include "MediaContainerType.h"
+#include "MediaPrefs.h"
+#include "VideoUtils.h"
+#include "WebMDecoder.h"
+#include "mozIGeckoMediaPluginService.h"
+#include "mozilla/ClearOnShutdown.h"
+#include "mozilla/EMEUtils.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Services.h"
+#include "mozilla/StaticPtr.h"
 #include "mozilla/dom/MediaKeySystemAccess.h"
 #include "mozilla/dom/MediaKeySystemAccessBinding.h"
-#include "mozilla/Preferences.h"
-#include "MediaContainerType.h"
-#include "MediaPrefs.h"
+#include "mozilla/dom/MediaSource.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsContentCID.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsDirectoryServiceUtils.h"
+#include "nsIObserverService.h"
+#include "nsServiceManagerUtils.h"
+#include "nsUnicharUtils.h"
+#include "nsXULAppAPI.h"
+#ifdef MOZ_WIDGET_ANDROID
+#include "FennecJNIWrappers.h"
+#endif
 #ifdef MOZ_FMP4
 #include "MP4Decoder.h"
 #endif
 #ifdef XP_WIN
 #include "WMFDecoderModule.h"
 #endif
-#include "nsContentCID.h"
-#include "nsServiceManagerUtils.h"
-#include "mozIGeckoMediaPluginService.h"
-#include "VideoUtils.h"
-#include "mozilla/Services.h"
-#include "nsIObserverService.h"
-#include "mozilla/EMEUtils.h"
-#include "GMPUtils.h"
-#include "nsAppDirectoryServiceDefs.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsXULAppAPI.h"
-#include "DecoderDoctorDiagnostics.h"
-#include "WebMDecoder.h"
-#include "mozilla/StaticPtr.h"
-#include "mozilla/ClearOnShutdown.h"
-#include "nsUnicharUtils.h"
-#include "mozilla/dom/MediaSource.h"
-#ifdef MOZ_WIDGET_ANDROID
-#include "FennecJNIWrappers.h"
-#endif
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess,
                                       mParent)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaKeySystemAccess)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
-MediaKeySystemAccess::MediaKeySystemAccess(nsPIDOMWindowInner* aParent,
-                                           const nsAString& aKeySystem,
-                                           const MediaKeySystemConfiguration& aConfig)
+MediaKeySystemAccess::MediaKeySystemAccess(
+  nsPIDOMWindowInner* aParent,
+  const nsAString& aKeySystem,
+  const MediaKeySystemConfiguration& aConfig)
   : mParent(aParent)
   , mKeySystem(aKeySystem)
   , mConfig(aConfig)
 {
 }
 
 MediaKeySystemAccess::~MediaKeySystemAccess()
 {
 }
 
 JSObject*
-MediaKeySystemAccess::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+MediaKeySystemAccess::WrapObject(JSContext* aCx,
+                                 JS::Handle<JSObject*> aGivenProto)
 {
   return MediaKeySystemAccessBinding::Wrap(aCx, this, aGivenProto);
 }
 
 nsPIDOMWindowInner*
 MediaKeySystemAccess::GetParentObject() const
 {
   return mParent;
@@ -135,24 +137,27 @@ MediaKeySystemAccess::GetKeySystemStatus
   if (IsWidevineKeySystem(aKeySystem)) {
     if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
       if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
         aOutMessage = NS_LITERAL_CSTRING("Widevine EME disabled");
         return MediaKeySystemStatus::Cdm_disabled;
       }
       return EnsureCDMInstalled(aKeySystem, aOutMessage);
 #ifdef MOZ_WIDGET_ANDROID
-    } else if (Preferences::GetBool("media.mediadrm-widevinecdm.visible", false)) {
-        nsCString keySystem = NS_ConvertUTF16toUTF8(aKeySystem);
-        bool supported = mozilla::java::MediaDrmProxy::IsSchemeSupported(keySystem);
-        if (!supported) {
-          aOutMessage = NS_LITERAL_CSTRING("KeySystem or Minimum API level not met for Widevine EME");
-          return MediaKeySystemStatus::Cdm_not_supported;
-        }
-        return MediaKeySystemStatus::Available;
+    } else if (Preferences::GetBool("media.mediadrm-widevinecdm.visible",
+                                    false)) {
+      nsCString keySystem = NS_ConvertUTF16toUTF8(aKeySystem);
+      bool supported =
+        mozilla::java::MediaDrmProxy::IsSchemeSupported(keySystem);
+      if (!supported) {
+        aOutMessage = NS_LITERAL_CSTRING(
+          "KeySystem or Minimum API level not met for Widevine EME");
+        return MediaKeySystemStatus::Cdm_not_supported;
+      }
+      return MediaKeySystemStatus::Available;
 #endif
     }
   }
 
   return MediaKeySystemStatus::Cdm_not_supported;
 }
 
 typedef nsCString EMECodecString;
@@ -239,18 +244,20 @@ enum class KeySystemFeatureSupport
   Requestable = 2,
   Required = 3,
 };
 
 struct KeySystemConfig
 {
   nsString mKeySystem;
   nsTArray<nsString> mInitDataTypes;
-  KeySystemFeatureSupport mPersistentState = KeySystemFeatureSupport::Prohibited;
-  KeySystemFeatureSupport mDistinctiveIdentifier = KeySystemFeatureSupport::Prohibited;
+  KeySystemFeatureSupport mPersistentState =
+    KeySystemFeatureSupport::Prohibited;
+  KeySystemFeatureSupport mDistinctiveIdentifier =
+    KeySystemFeatureSupport::Prohibited;
   nsTArray<MediaKeySessionType> mSessionTypes;
   nsTArray<nsString> mVideoRobustness;
   nsTArray<nsString> mAudioRobustness;
   KeySystemContainerSupport mMP4;
   KeySystemContainerSupport mWebM;
 };
 
 static nsTArray<KeySystemConfig>
@@ -264,17 +271,18 @@ GetSupportedKeySystems()
       clearkey.mKeySystem = NS_ConvertUTF8toUTF16(kEMEKeySystemClearkey);
       clearkey.mInitDataTypes.AppendElement(NS_LITERAL_STRING("cenc"));
       clearkey.mInitDataTypes.AppendElement(NS_LITERAL_STRING("keyids"));
       clearkey.mInitDataTypes.AppendElement(NS_LITERAL_STRING("webm"));
       clearkey.mPersistentState = KeySystemFeatureSupport::Requestable;
       clearkey.mDistinctiveIdentifier = KeySystemFeatureSupport::Prohibited;
       clearkey.mSessionTypes.AppendElement(MediaKeySessionType::Temporary);
       if (MediaPrefs::ClearKeyPersistentLicenseEnabled()) {
-        clearkey.mSessionTypes.AppendElement(MediaKeySessionType::Persistent_license);
+        clearkey.mSessionTypes.AppendElement(
+          MediaKeySessionType::Persistent_license);
       }
 #if defined(XP_WIN)
       // Clearkey CDM uses WMF decoders on Windows.
       if (WMFDecoderModule::HasAAC()) {
         clearkey.mMP4.SetCanDecryptAndDecode(EME_CODEC_AAC);
       } else {
         clearkey.mMP4.SetCanDecrypt(EME_CODEC_AAC);
       }
@@ -303,20 +311,23 @@ GetSupportedKeySystems()
       widevine.mKeySystem = NS_ConvertUTF8toUTF16(kEMEKeySystemWidevine);
       widevine.mInitDataTypes.AppendElement(NS_LITERAL_STRING("cenc"));
       widevine.mInitDataTypes.AppendElement(NS_LITERAL_STRING("keyids"));
       widevine.mInitDataTypes.AppendElement(NS_LITERAL_STRING("webm"));
       widevine.mPersistentState = KeySystemFeatureSupport::Requestable;
       widevine.mDistinctiveIdentifier = KeySystemFeatureSupport::Prohibited;
       widevine.mSessionTypes.AppendElement(MediaKeySessionType::Temporary);
 #ifdef MOZ_WIDGET_ANDROID
-      widevine.mSessionTypes.AppendElement(MediaKeySessionType::Persistent_license);
+      widevine.mSessionTypes.AppendElement(
+        MediaKeySessionType::Persistent_license);
 #endif
-      widevine.mAudioRobustness.AppendElement(NS_LITERAL_STRING("SW_SECURE_CRYPTO"));
-      widevine.mVideoRobustness.AppendElement(NS_LITERAL_STRING("SW_SECURE_DECODE"));
+      widevine.mAudioRobustness.AppendElement(
+        NS_LITERAL_STRING("SW_SECURE_CRYPTO"));
+      widevine.mVideoRobustness.AppendElement(
+        NS_LITERAL_STRING("SW_SECURE_DECODE"));
 #if defined(XP_WIN)
       // Widevine CDM doesn't include an AAC decoder. So if WMF can't
       // decode AAC, and a codec wasn't specified, be conservative
       // and reject the MediaKeys request, since we assume Widevine
       // will be used with AAC.
       if (WMFDecoderModule::HasAAC()) {
         widevine.mMP4.SetCanDecrypt(EME_CODEC_AAC);
       }
@@ -325,17 +336,18 @@ GetSupportedKeySystems()
 #endif
 
 #if defined(MOZ_WIDGET_ANDROID)
       using namespace mozilla::java;
       // MediaDrm.isCryptoSchemeSupported only allows passing
       // "video/mp4" or "video/webm" for mimetype string.
       // See https://developer.android.com/reference/android/media/MediaDrm.html#isCryptoSchemeSupported(java.util.UUID, java.lang.String)
       // for more detail.
-      typedef struct {
+      typedef struct
+      {
         const nsCString& mMimeType;
         const nsCString& mEMECodecType;
         const char16_t* mCodecType;
         KeySystemContainerSupport* mSupportType;
       } DataForValidation;
 
       DataForValidation validationList[] = {
         { nsCString("video/mp4"), EME_CODEC_H264, MediaDrmProxy::AVC, &widevine.mMP4 },
@@ -370,36 +382,37 @@ GetSupportedKeySystems()
       keySystemConfigs.AppendElement(Move(widevine));
     }
   }
 
   return keySystemConfigs;
 }
 
 static bool
-GetKeySystemConfig(const nsAString& aKeySystem, KeySystemConfig& aOutKeySystemConfig)
+GetKeySystemConfig(const nsAString& aKeySystem,
+                   KeySystemConfig& aOutKeySystemConfig)
 {
   for (auto&& config : GetSupportedKeySystems()) {
     if (config.mKeySystem.Equals(aKeySystem)) {
       aOutKeySystemConfig = mozilla::Move(config);
       return true;
     }
   }
   // No matching key system found.
   return false;
 }
 
-/* static */
-bool
-MediaKeySystemAccess::KeySystemSupportsInitDataType(const nsAString& aKeySystem,
-                                                    const nsAString& aInitDataType)
+/* static */ bool
+MediaKeySystemAccess::KeySystemSupportsInitDataType(
+  const nsAString& aKeySystem,
+  const nsAString& aInitDataType)
 {
   KeySystemConfig implementation;
-  return GetKeySystemConfig(aKeySystem, implementation) &&
-         implementation.mInitDataTypes.Contains(aInitDataType);
+  return GetKeySystemConfig(aKeySystem, implementation)
+         && implementation.mInitDataTypes.Contains(aInitDataType);
 }
 
 enum CodecType
 {
   Audio,
   Video,
   Invalid
 };
@@ -416,34 +429,35 @@ CanDecryptAndDecode(const nsString& aKey
   for (const EMECodecString& codec : aCodecs) {
     MOZ_ASSERT(!codec.IsEmpty());
 
     if (aContainerSupport.DecryptsAndDecodes(codec)) {
       // GMP can decrypt-and-decode this codec.
       continue;
     }
 
-    if (aContainerSupport.Decrypts(codec) &&
-        NS_SUCCEEDED(MediaSource::IsTypeSupported(aContentType, aDiagnostics))) {
+    if (aContainerSupport.Decrypts(codec)
+        && NS_SUCCEEDED(
+             MediaSource::IsTypeSupported(aContentType, aDiagnostics))) {
       // GMP can decrypt and is allowed to return compressed samples to
       // Gecko to decode, and Gecko has a decoder.
       continue;
     }
 
     // Neither the GMP nor Gecko can both decrypt and decode. We don't
     // support this codec.
 
 #if defined(XP_WIN)
     // Widevine CDM doesn't include an AAC decoder. So if WMF can't
     // decode AAC, and a codec wasn't specified, be conservative
     // and reject the MediaKeys request, since we assume Widevine
     // will be used with AAC.
-    if (codec == EME_CODEC_AAC &&
-        IsWidevineKeySystem(aKeySystem) &&
-        !WMFDecoderModule::HasAAC()) {
+    if (codec == EME_CODEC_AAC
+        && IsWidevineKeySystem(aKeySystem)
+        && !WMFDecoderModule::HasAAC()) {
       if (aDiagnostics) {
         aDiagnostics->SetKeySystemIssue(
           DecoderDoctorDiagnostics::eWidevineWithNoWMF);
       }
     }
 #endif
     return false;
   }
@@ -456,17 +470,18 @@ ToSessionType(const nsAString& aSessionT
   using MediaKeySessionTypeValues::strings;
   const char* temporary =
     strings[static_cast<uint32_t>(MediaKeySessionType::Temporary)].value;
   if (aSessionType.EqualsASCII(temporary)) {
     aOutType = MediaKeySessionType::Temporary;
     return true;
   }
   const char* persistentLicense =
-    strings[static_cast<uint32_t>(MediaKeySessionType::Persistent_license)].value;
+    strings[static_cast<uint32_t>(MediaKeySessionType::Persistent_license)]
+      .value;
   if (aSessionType.EqualsASCII(persistentLicense)) {
     aOutType = MediaKeySessionType::Persistent_license;
     return true;
   }
   return false;
 }
 
 // 5.2.1 Is persistent session type?
@@ -486,31 +501,32 @@ GetMajorType(const MediaMIMEType& aMIMET
     return Video;
   }
   return Invalid;
 }
 
 static CodecType
 GetCodecType(const EMECodecString& aCodec)
 {
-  if (aCodec.Equals(EME_CODEC_AAC) ||
-      aCodec.Equals(EME_CODEC_OPUS) ||
-      aCodec.Equals(EME_CODEC_VORBIS)) {
+  if (aCodec.Equals(EME_CODEC_AAC)
+      || aCodec.Equals(EME_CODEC_OPUS)
+      || aCodec.Equals(EME_CODEC_VORBIS)) {
     return Audio;
   }
-  if (aCodec.Equals(EME_CODEC_H264) ||
-      aCodec.Equals(EME_CODEC_VP8) ||
-      aCodec.Equals(EME_CODEC_VP9)) {
+  if (aCodec.Equals(EME_CODEC_H264)
+      || aCodec.Equals(EME_CODEC_VP8)
+      || aCodec.Equals(EME_CODEC_VP9)) {
     return Video;
   }
   return Invalid;
 }
 
 static bool
-AllCodecsOfType(const nsTArray<EMECodecString>& aCodecs, const CodecType aCodecType)
+AllCodecsOfType(const nsTArray<EMECodecString>& aCodecs,
+                const CodecType aCodecType)
 {
   for (const EMECodecString& codec : aCodecs) {
     if (GetCodecType(codec) != aCodecType) {
       return false;
     }
   }
   return true;
 }
@@ -533,43 +549,46 @@ IsParameterUnrecognized(const nsAString&
       if (FindCharInReadable('=', equalSign, end)) {
         params.AppendElement(Substring(semicolon, equalSign));
         semicolon = equalSign;
       }
     }
   }
 
   for (auto param : params) {
-    if (!param.LowerCaseEqualsLiteral("codecs") &&
-        !param.LowerCaseEqualsLiteral("profiles")) {
+    if (!param.LowerCaseEqualsLiteral("codecs")
+        && !param.LowerCaseEqualsLiteral("profiles")) {
       return true;
     }
   }
   return false;
 }
 
 // 3.1.2.3 Get Supported Capabilities for Audio/Video Type
 static Sequence<MediaKeySystemMediaCapability>
-GetSupportedCapabilities(const CodecType aCodecType,
-                         const nsTArray<MediaKeySystemMediaCapability>& aRequestedCapabilities,
-                         const MediaKeySystemConfiguration& aPartialConfig,
-                         const KeySystemConfig& aKeySystem,
-                         DecoderDoctorDiagnostics* aDiagnostics)
+GetSupportedCapabilities(
+  const CodecType aCodecType,
+  const nsTArray<MediaKeySystemMediaCapability>& aRequestedCapabilities,
+  const MediaKeySystemConfiguration& aPartialConfig,
+  const KeySystemConfig& aKeySystem,
+  DecoderDoctorDiagnostics* aDiagnostics)
 {
-  // Let local accumulated configuration be a local copy of partial configuration.
+  // Let local accumulated configuration be a local copy of partial
+  // configuration.
   // (Note: It's not necessary for us to maintain a local copy, as we don't need
   // to test whether capabilites from previous calls to this algorithm work with
   // the capabilities currently being considered in this call. )
 
   // Let supported media capabilities be an empty sequence of
   // MediaKeySystemMediaCapability dictionaries.
   Sequence<MediaKeySystemMediaCapability> supportedCapabilities;
 
   // For each requested media capability in requested media capabilities:
-  for (const MediaKeySystemMediaCapability& capabilities : aRequestedCapabilities) {
+  for (const MediaKeySystemMediaCapability& capabilities :
+       aRequestedCapabilities) {
     // Let content type be requested media capability's contentType member.
     const nsString& contentTypeString = capabilities.mContentType;
     // Let robustness be requested media capability's robustness member.
     const nsString& robustness = capabilities.mRobustness;
     // If content type is the empty string, return null.
     if (contentTypeString.IsEmpty()) {
       EME_LOG("MediaKeySystemConfiguration (label='%s') "
               "MediaKeySystemMediaCapability('%s','%s') rejected; "
@@ -590,17 +609,18 @@ GetSupportedCapabilities(const CodecType
               NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
               NS_ConvertUTF16toUTF8(contentTypeString).get(),
               NS_ConvertUTF16toUTF8(robustness).get());
       continue;
     }
     const MediaContainerType& containerType = *maybeContainerType;
     bool invalid = false;
     nsTArray<EMECodecString> codecs;
-    for (const auto& codecString : containerType.ExtendedType().Codecs().Range()) {
+    for (const auto& codecString :
+         containerType.ExtendedType().Codecs().Range()) {
       EMECodecString emeCodec = ToEMEAPICodecString(nsString(codecString));
       if (emeCodec.IsEmpty()) {
         invalid = true;
         EME_LOG("MediaKeySystemConfiguration (label='%s') "
                 "MediaKeySystemMediaCapability('%s','%s') unsupported; "
                 "'%s' is an invalid codec string.",
                 NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
                 NS_ConvertUTF16toUTF8(contentTypeString).get(),
@@ -660,33 +680,33 @@ GetSupportedCapabilities(const CodecType
 
     // Let media types be the set of codecs and codec constraints specified by
     // parameters. The case-sensitivity of string comparisons is determined by
     // the appropriate RFC or other specification.
     // (Note: codecs array is 'parameter').
 
     // If media types is empty:
     if (codecs.IsEmpty()) {
-      // If container normatively implies a specific set of codecs and codec constraints:
-      // Let parameters be that set.
+      // If container normatively implies a specific set of codecs and codec
+      // constraints: Let parameters be that set.
       if (isMP4) {
         if (aCodecType == Audio) {
           codecs.AppendElement(EME_CODEC_AAC);
         } else if (aCodecType == Video) {
           codecs.AppendElement(EME_CODEC_H264);
         }
       } else if (isWebM) {
         if (aCodecType == Audio) {
           codecs.AppendElement(EME_CODEC_VORBIS);
         } else if (aCodecType == Video) {
           codecs.AppendElement(EME_CODEC_VP8);
         }
       }
-      // Otherwise: Continue to the next iteration.
-      // (Note: all containers we support have implied codecs, so don't continue here.)
+      // Otherwise: Continue to the next iteration. (Note: all containers we
+      // support have implied codecs, so don't continue here.)
     }
 
     // If container type is not strictly a audio/video type, continue to the next iteration.
     const auto majorType = GetMajorType(containerType.Type());
     if (majorType == Invalid) {
       EME_LOG("MediaKeySystemConfiguration (label='%s') "
               "MediaKeySystemMediaCapability('%s','%s') unsupported; "
               "MIME type is not an audio or video MIME type.",
@@ -704,26 +724,28 @@ GetSupportedCapabilities(const CodecType
               NS_ConvertUTF16toUTF8(contentTypeString).get(),
               NS_ConvertUTF16toUTF8(robustness).get());
       continue;
     }
     // If robustness is not the empty string and contains an unrecognized
     // value or a value not supported by implementation, continue to the
     // next iteration. String comparison is case-sensitive.
     if (!robustness.IsEmpty()) {
-      if (majorType == Audio && !aKeySystem.mAudioRobustness.Contains(robustness)) {
+      if (majorType
+          == Audio && !aKeySystem.mAudioRobustness.Contains(robustness)) {
         EME_LOG("MediaKeySystemConfiguration (label='%s') "
                 "MediaKeySystemMediaCapability('%s','%s') unsupported; "
                 "unsupported robustness string.",
                 NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
                 NS_ConvertUTF16toUTF8(contentTypeString).get(),
                 NS_ConvertUTF16toUTF8(robustness).get());
         continue;
       }
-      if (majorType == Video && !aKeySystem.mVideoRobustness.Contains(robustness)) {
+      if (majorType
+          == Video && !aKeySystem.mVideoRobustness.Contains(robustness)) {
         EME_LOG("MediaKeySystemConfiguration (label='%s') "
                 "MediaKeySystemMediaCapability('%s','%s') unsupported; "
                 "unsupported robustness string.",
                 NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
                 NS_ConvertUTF16toUTF8(contentTypeString).get(),
                 NS_ConvertUTF16toUTF8(robustness).get());
         continue;
       }
@@ -778,18 +800,19 @@ CheckRequirement(const MediaKeysRequirem
   if (aRequirement == MediaKeysRequirement::Optional &&
       aFeatureSupport == KeySystemFeatureSupport::Prohibited) {
     requirement = MediaKeysRequirement::Not_allowed;
   }
 
   // Follow the steps for requirement from the following list:
   switch (requirement) {
     case MediaKeysRequirement::Required: {
-      // If the implementation does not support use of requirement in combination
-      // with accumulated configuration and restrictions, return NotSupported.
+      // If the implementation does not support use of requirement in
+      // combination with accumulated configuration and restrictions, return
+      // NotSupported.
       if (aFeatureSupport == KeySystemFeatureSupport::Prohibited) {
         return false;
       }
       break;
     }
     case MediaKeysRequirement::Optional: {
       // Continue with the following steps.
       break;
@@ -823,58 +846,62 @@ CheckRequirement(const MediaKeysRequirem
 static Sequence<nsString>
 UnboxSessionTypes(const Optional<Sequence<nsString>>& aSessionTypes)
 {
   Sequence<nsString> sessionTypes;
   if (aSessionTypes.WasPassed()) {
     sessionTypes = aSessionTypes.Value();
   } else {
     using MediaKeySessionTypeValues::strings;
-    const char* temporary = strings[static_cast<uint32_t>(MediaKeySessionType::Temporary)].value;
+    const char* temporary =
+      strings[static_cast<uint32_t>(MediaKeySessionType::Temporary)].value;
     // Note: fallible. Results in an empty array.
-    sessionTypes.AppendElement(NS_ConvertUTF8toUTF16(nsDependentCString(temporary)), mozilla::fallible);
+    sessionTypes.AppendElement(
+      NS_ConvertUTF8toUTF16(nsDependentCString(temporary)), mozilla::fallible);
   }
   return sessionTypes;
 }
 
 // 3.1.2.2 Get Supported Configuration and Consent
 static bool
 GetSupportedConfig(const KeySystemConfig& aKeySystem,
                    const MediaKeySystemConfiguration& aCandidate,
                    MediaKeySystemConfiguration& aOutConfig,
                    DecoderDoctorDiagnostics* aDiagnostics)
 {
-  // Let accumulated configuration be a new MediaKeySystemConfiguration dictionary.
+  // Let accumulated configuration be a new MediaKeySystemConfiguration
+  // dictionary.
   MediaKeySystemConfiguration config;
-  // Set the label member of accumulated configuration to equal the label member of
-  // candidate configuration.
+  // Set the label member of accumulated configuration to equal the label member
+  // of candidate configuration.
   config.mLabel = aCandidate.mLabel;
-  // If the initDataTypes member of candidate configuration is non-empty, run the
-  // following steps:
+  // If the initDataTypes member of candidate configuration is non-empty, run
+  // the following steps:
   if (!aCandidate.mInitDataTypes.IsEmpty()) {
     // Let supported types be an empty sequence of DOMStrings.
     nsTArray<nsString> supportedTypes;
     // For each value in candidate configuration's initDataTypes member:
     for (const nsString& initDataType : aCandidate.mInitDataTypes) {
-      // Let initDataType be the value.
-      // If the implementation supports generating requests based on initDataType,
-      // add initDataType to supported types. String comparison is case-sensitive.
-      // The empty string is never supported.
+      // Let initDataType be the value. If the implementation supports
+      // generating requests based on initDataType, add initDataType to
+      // supported types. String comparison is case-sensitive. The empty string
+      // is never supported.
       if (aKeySystem.mInitDataTypes.Contains(initDataType)) {
         supportedTypes.AppendElement(initDataType);
       }
     }
     // If supported types is empty, return NotSupported.
     if (supportedTypes.IsEmpty()) {
       EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
               "no supported initDataTypes provided.",
               NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
       return false;
     }
-    // Set the initDataTypes member of accumulated configuration to supported types.
+    // Set the initDataTypes member of accumulated configuration to supported
+    // types.
     if (!config.mInitDataTypes.Assign(supportedTypes)) {
       return false;
     }
   }
 
   if (!CheckRequirement(aCandidate.mDistinctiveIdentifier,
                         aKeySystem.mDistinctiveIdentifier,
                         config.mDistinctiveIdentifier)) {
@@ -908,18 +935,18 @@ GetSupportedConfig(const KeySystemConfig
       EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
               "invalid session type specified.",
               NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
       return false;
     }
     // If accumulated configuration's persistentState value is "not-allowed"
     // and the Is persistent session type? algorithm returns true for session
     // type return NotSupported.
-    if (config.mPersistentState == MediaKeysRequirement::Not_allowed &&
-        IsPersistentSessionType(sessionType)) {
+    if (config.mPersistentState == MediaKeysRequirement::Not_allowed
+        && IsPersistentSessionType(sessionType)) {
       EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
               "persistent session requested but keysystem doesn't"
               "support persistent state.",
               NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
       return false;
     }
     // If the implementation does not support session type in combination
     // with accumulated configuration and restrictions for other reasons,
@@ -930,18 +957,18 @@ GetSupportedConfig(const KeySystemConfig
               NS_ConvertUTF16toUTF8(aCandidate.mLabel).get(),
               NS_ConvertUTF16toUTF8(sessionTypeString).get());
       return false;
     }
     // If accumulated configuration's persistentState value is "optional"
     // and the result of running the Is persistent session type? algorithm
     // on session type is true, change accumulated configuration's
     // persistentState value to "required".
-    if (config.mPersistentState == MediaKeysRequirement::Optional &&
-        IsPersistentSessionType(sessionType)) {
+    if (config.mPersistentState == MediaKeysRequirement::Optional
+        && IsPersistentSessionType(sessionType)) {
       config.mPersistentState = MediaKeysRequirement::Required;
     }
   }
   // Set the sessionTypes member of accumulated configuration to session types.
   config.mSessionTypes.Construct(Move(sessionTypes));
 
   // If the videoCapabilities and audioCapabilities members in candidate
   // configuration are both empty, return NotSupported.
@@ -962,88 +989,94 @@ GetSupportedConfig(const KeySystemConfig
                                aDiagnostics);
     // If video capabilities is null, return NotSupported.
     if (caps.IsEmpty()) {
       EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
               "no supported video capabilities.",
               NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
       return false;
     }
-    // Set the videoCapabilities member of accumulated configuration to video capabilities.
+    // Set the videoCapabilities member of accumulated configuration to video
+    // capabilities.
     config.mVideoCapabilities = Move(caps);
   } else {
     // Otherwise:
-    // Set the videoCapabilities member of accumulated configuration to an empty sequence.
+    // Set the videoCapabilities member of accumulated configuration to an empty
+    // sequence.
   }
 
   // If the audioCapabilities member in candidate configuration is non-empty:
   if (!aCandidate.mAudioCapabilities.IsEmpty()) {
-    // Let audio capabilities be the result of executing the Get Supported Capabilities
-    // for Audio/Video Type algorithm on Audio, candidate configuration's audioCapabilities
-    // member, accumulated configuration, and restrictions.
+    // Let audio capabilities be the result of executing the Get Supported
+    // Capabilities for Audio/Video Type algorithm on Audio, candidate
+    // configuration's audioCapabilities member, accumulated configuration, and
+    // restrictions.
     Sequence<MediaKeySystemMediaCapability> caps =
       GetSupportedCapabilities(Audio,
                                aCandidate.mAudioCapabilities,
                                config,
                                aKeySystem,
                                aDiagnostics);
     // If audio capabilities is null, return NotSupported.
     if (caps.IsEmpty()) {
       EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
               "no supported audio capabilities.",
               NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
       return false;
     }
-    // Set the audioCapabilities member of accumulated configuration to audio capabilities.
+    // Set the audioCapabilities member of accumulated configuration to audio
+    // capabilities.
     config.mAudioCapabilities = Move(caps);
   } else {
     // Otherwise:
-    // Set the audioCapabilities member of accumulated configuration to an empty sequence.
+    // Set the audioCapabilities member of accumulated configuration to an empty
+    // sequence.
   }
 
-  // If accumulated configuration's distinctiveIdentifier value is "optional", follow the
-  // steps for the first matching condition from the following list:
+  // If accumulated configuration's distinctiveIdentifier value is "optional",
+  // follow the steps for the first matching condition from the following list:
   if (config.mDistinctiveIdentifier == MediaKeysRequirement::Optional) {
     // If the implementation requires use Distinctive Identifier(s) or
     // Distinctive Permanent Identifier(s) for any of the combinations
     // in accumulated configuration
     if (aKeySystem.mDistinctiveIdentifier == KeySystemFeatureSupport::Required) {
-      // Change accumulated configuration's distinctiveIdentifier value to "required".
+      // Change accumulated configuration's distinctiveIdentifier value to
+      // "required".
       config.mDistinctiveIdentifier = MediaKeysRequirement::Required;
     } else {
       // Otherwise, change accumulated configuration's distinctiveIdentifier
       // value to "not-allowed".
       config.mDistinctiveIdentifier = MediaKeysRequirement::Not_allowed;
     }
   }
 
-  // If accumulated configuration's persistentState value is "optional", follow the
-  // steps for the first matching condition from the following list:
+  // If accumulated configuration's persistentState value is "optional", follow
+  // the steps for the first matching condition from the following list:
   if (config.mPersistentState == MediaKeysRequirement::Optional) {
-    // If the implementation requires persisting state for any of the combinations
-    // in accumulated configuration
+    // If the implementation requires persisting state for any of the
+    // combinations in accumulated configuration
     if (aKeySystem.mPersistentState == KeySystemFeatureSupport::Required) {
       // Change accumulated configuration's persistentState value to "required".
       config.mPersistentState = MediaKeysRequirement::Required;
     } else {
       // Otherwise, change accumulated configuration's persistentState
       // value to "not-allowed".
       config.mPersistentState = MediaKeysRequirement::Not_allowed;
     }
   }
 
   // Note: Omitting steps 20-22. We don't ask for consent.
 
 #if defined(XP_WIN)
   // Widevine CDM doesn't include an AAC decoder. So if WMF can't decode AAC,
   // and a codec wasn't specified, be conservative and reject the MediaKeys request.
-  if (IsWidevineKeySystem(aKeySystem.mKeySystem) &&
-      (aCandidate.mAudioCapabilities.IsEmpty() ||
-       aCandidate.mVideoCapabilities.IsEmpty()) &&
-     !WMFDecoderModule::HasAAC()) {
+  if (IsWidevineKeySystem(aKeySystem.mKeySystem)
+      && (aCandidate.mAudioCapabilities.IsEmpty()
+          || aCandidate.mVideoCapabilities.IsEmpty())
+      && !WMFDecoderModule::HasAAC()) {
     if (aDiagnostics) {
       aDiagnostics->SetKeySystemIssue(
         DecoderDoctorDiagnostics::eWidevineWithNoWMF);
     }
     EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
             "WMF required for Widevine decoding, but it's not available.",
             NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
     return false;
@@ -1053,20 +1086,21 @@ GetSupportedConfig(const KeySystemConfig
   // Return accumulated configuration.
   aOutConfig = config;
 
   return true;
 }
 
 /* static */
 bool
-MediaKeySystemAccess::GetSupportedConfig(const nsAString& aKeySystem,
-                                         const Sequence<MediaKeySystemConfiguration>& aConfigs,
-                                         MediaKeySystemConfiguration& aOutConfig,
-                                         DecoderDoctorDiagnostics* aDiagnostics)
+MediaKeySystemAccess::GetSupportedConfig(
+  const nsAString& aKeySystem,
+  const Sequence<MediaKeySystemConfiguration>& aConfigs,
+  MediaKeySystemConfiguration& aOutConfig,
+  DecoderDoctorDiagnostics* aDiagnostics)
 {
   KeySystemConfig implementation;
   if (!GetKeySystemConfig(aKeySystem, implementation)) {
     return false;
   }
   for (const MediaKeySystemConfiguration& candidate : aConfigs) {
     if (mozilla::dom::GetSupportedConfig(implementation,
                                          candidate,
@@ -1086,17 +1120,18 @@ MediaKeySystemAccess::NotifyObservers(ns
                                       const nsAString& aKeySystem,
                                       MediaKeySystemStatus aStatus)
 {
   RequestMediaKeySystemAccessNotification data;
   data.mKeySystem = aKeySystem;
   data.mStatus = aStatus;
   nsAutoString json;
   data.ToJSON(json);
-  EME_LOG("MediaKeySystemAccess::NotifyObservers() %s", NS_ConvertUTF16toUTF8(json).get());
+  EME_LOG("MediaKeySystemAccess::NotifyObservers() %s",
+          NS_ConvertUTF16toUTF8(json).get());
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   if (obs) {
     obs->NotifyObservers(aWindow, "mediakeys-request", json.get());
   }
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/eme/MediaKeySystemAccess.h
+++ b/dom/media/eme/MediaKeySystemAccess.h
@@ -2,27 +2,25 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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_MediaKeySystemAccess_h
 #define mozilla_dom_MediaKeySystemAccess_h
 
+#include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/dom/MediaKeySystemAccessBinding.h"
+#include "mozilla/dom/MediaKeysRequestStatusBinding.h"
+#include "mozilla/dom/Promise.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
-#include "mozilla/dom/Promise.h"
-#include "mozilla/dom/MediaKeySystemAccessBinding.h"
-#include "mozilla/dom/MediaKeysRequestStatusBinding.h"
-
-#include "js/TypeDecls.h"
-
 namespace mozilla {
 
 class DecoderDoctorDiagnostics;
 
 namespace dom {
 
 class MediaKeySystemAccess final : public nsISupports,
                                    public nsWrapperCache
@@ -37,39 +35,42 @@ public:
                                 const MediaKeySystemConfiguration& aConfig);
 
 protected:
   ~MediaKeySystemAccess();
 
 public:
   nsPIDOMWindowInner* GetParentObject() const;
 
-  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override;
 
   void GetKeySystem(nsString& aRetVal) const;
 
   void GetConfiguration(MediaKeySystemConfiguration& aConfig);
 
   already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);
 
-  static MediaKeySystemStatus GetKeySystemStatus(const nsAString& aKeySystem,
-                                                 nsACString& aOutExceptionMessage);
+  static MediaKeySystemStatus GetKeySystemStatus(
+    const nsAString& aKeySystem,
+    nsACString& aOutExceptionMessage);
 
   static bool IsSupported(const nsAString& aKeySystem,
                           const Sequence<MediaKeySystemConfiguration>& aConfigs,
                           DecoderDoctorDiagnostics* aDiagnostics);
 
   static void NotifyObservers(nsPIDOMWindowInner* aWindow,
                               const nsAString& aKeySystem,
                               MediaKeySystemStatus aStatus);
 
-  static bool GetSupportedConfig(const nsAString& aKeySystem,
-                                 const Sequence<MediaKeySystemConfiguration>& aConfigs,
-                                 MediaKeySystemConfiguration& aOutConfig,
-                                 DecoderDoctorDiagnostics* aDiagnostics);
+  static bool GetSupportedConfig(
+    const nsAString& aKeySystem,
+    const Sequence<MediaKeySystemConfiguration>& aConfigs,
+    MediaKeySystemConfiguration& aOutConfig,
+    DecoderDoctorDiagnostics* aDiagnostics);
 
   static bool KeySystemSupportsInitDataType(const nsAString& aKeySystem,
                                             const nsAString& aInitDataType);
 
 private:
   nsCOMPtr<nsPIDOMWindowInner> mParent;
   const nsString mKeySystem;
   const MediaKeySystemConfiguration mConfig;
--- a/dom/media/eme/MediaKeySystemAccessManager.cpp
+++ b/dom/media/eme/MediaKeySystemAccessManager.cpp
@@ -1,28 +1,28 @@
 /* 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 "MediaKeySystemAccessManager.h"
 #include "DecoderDoctorDiagnostics.h"
 #include "MediaPrefs.h"
+#include "mozilla/DetailedPromise.h"
 #include "mozilla/EMEUtils.h"
-#include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIObserverService.h"
-#include "mozilla/Services.h"
-#include "mozilla/DetailedPromise.h"
+#include "nsPrintfCString.h"
+#include "nsServiceManagerUtils.h"
 #ifdef XP_WIN
 #include "mozilla/WindowsVersion.h"
 #endif
 #ifdef XP_MACOSX
 #include "nsCocoaFeatures.h"
 #endif
-#include "nsPrintfCString.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaKeySystemAccessManager)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END
@@ -30,67 +30,73 @@ NS_INTERFACE_MAP_END
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccessManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccessManager)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(MediaKeySystemAccessManager)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaKeySystemAccessManager)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
   for (size_t i = 0; i < tmp->mRequests.Length(); i++) {
-    tmp->mRequests[i].RejectPromise(NS_LITERAL_CSTRING("Promise still outstanding at MediaKeySystemAccessManager GC"));
+    tmp->mRequests[i].RejectPromise(NS_LITERAL_CSTRING(
+      "Promise still outstanding at MediaKeySystemAccessManager GC"));
     tmp->mRequests[i].CancelTimer();
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mRequests[i].mPromise)
   }
   tmp->mRequests.Clear();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MediaKeySystemAccessManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
   for (size_t i = 0; i < tmp->mRequests.Length(); i++) {
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRequests[i].mPromise)
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-MediaKeySystemAccessManager::MediaKeySystemAccessManager(nsPIDOMWindowInner* aWindow)
+MediaKeySystemAccessManager::MediaKeySystemAccessManager(
+  nsPIDOMWindowInner* aWindow)
   : mWindow(aWindow)
   , mAddedObservers(false)
 {
 }
 
 MediaKeySystemAccessManager::~MediaKeySystemAccessManager()
 {
   Shutdown();
 }
 
 void
-MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
-                                     const nsAString& aKeySystem,
-                                     const Sequence<MediaKeySystemConfiguration>& aConfigs)
+MediaKeySystemAccessManager::Request(
+  DetailedPromise* aPromise,
+  const nsAString& aKeySystem,
+  const Sequence<MediaKeySystemConfiguration>& aConfigs)
 {
   Request(aPromise, aKeySystem, aConfigs, RequestType::Initial);
 }
 
 void
-MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
-                                     const nsAString& aKeySystem,
-                                     const Sequence<MediaKeySystemConfiguration>& aConfigs,
-                                     RequestType aType)
+MediaKeySystemAccessManager::Request(
+  DetailedPromise* aPromise,
+  const nsAString& aKeySystem,
+  const Sequence<MediaKeySystemConfiguration>& aConfigs,
+  RequestType aType)
 {
-  EME_LOG("MediaKeySystemAccessManager::Request %s", NS_ConvertUTF16toUTF8(aKeySystem).get());
+  EME_LOG("MediaKeySystemAccessManager::Request %s",
+          NS_ConvertUTF16toUTF8(aKeySystem).get());
 
   if (aKeySystem.IsEmpty()) {
     aPromise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
                           NS_LITERAL_CSTRING("Key system string is empty"));
     // Don't notify DecoderDoctor, as there's nothing we or the user can
     // do to fix this situation; the site is using the API wrong.
     return;
   }
   if (aConfigs.IsEmpty()) {
-    aPromise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-                          NS_LITERAL_CSTRING("Candidate MediaKeySystemConfigs is empty"));
+    aPromise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING("Candidate MediaKeySystemConfigs is empty"));
     // Don't notify DecoderDoctor, as there's nothing we or the user can
     // do to fix this situation; the site is using the API wrong.
     return;
   }
 
   DecoderDoctorDiagnostics diagnostics;
 
   // Ensure keysystem is supported.
@@ -144,62 +150,67 @@ MediaKeySystemAccessManager::Request(Det
       // Note: If we're re-trying, we don't re-send the notification,
       // as chrome is already displaying the "we can't play, updating"
       // notification.
       MediaKeySystemAccess::NotifyObservers(mWindow, aKeySystem, status);
     } else {
       // We waited or can't wait for an update and we still can't service
       // the request. Give up. Chrome will still be showing a "I can't play,
       // updating" notification.
-      aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
-                            NS_LITERAL_CSTRING("Gave up while waiting for a CDM update"));
+      aPromise->MaybeReject(
+        NS_ERROR_DOM_NOT_SUPPORTED_ERR,
+        NS_LITERAL_CSTRING("Gave up while waiting for a CDM update"));
     }
     diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
                                           aKeySystem, false, __func__);
     return;
   }
   if (status != MediaKeySystemStatus::Available) {
     // Failed due to user disabling something, send a notification to
     // chrome, so we can show some UI to explain how the user can rectify
     // the situation.
     MediaKeySystemAccess::NotifyObservers(mWindow, aKeySystem, status);
     aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR, message);
     return;
   }
 
   MediaKeySystemConfiguration config;
-  if (MediaKeySystemAccess::GetSupportedConfig(aKeySystem, aConfigs, config, &diagnostics)) {
+  if (MediaKeySystemAccess::GetSupportedConfig(
+        aKeySystem, aConfigs, config, &diagnostics)) {
     RefPtr<MediaKeySystemAccess> access(
       new MediaKeySystemAccess(mWindow, aKeySystem, config));
     aPromise->MaybeResolve(access);
     diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
                                           aKeySystem, true, __func__);
     return;
   }
   // Not to inform user, because nothing to do if the corresponding keySystem
   // configuration is not supported.
-  aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
-                        NS_LITERAL_CSTRING("Key system configuration is not supported"));
-  diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
-                                        aKeySystem, false, __func__);
+  aPromise->MaybeReject(
+    NS_ERROR_DOM_NOT_SUPPORTED_ERR,
+    NS_LITERAL_CSTRING("Key system configuration is not supported"));
+  diagnostics.StoreMediaKeySystemAccess(
+    mWindow->GetExtantDoc(), aKeySystem, false, __func__);
 }
 
-MediaKeySystemAccessManager::PendingRequest::PendingRequest(DetailedPromise* aPromise,
-                                                            const nsAString& aKeySystem,
-                                                            const Sequence<MediaKeySystemConfiguration>& aConfigs,
-                                                            nsITimer* aTimer)
+MediaKeySystemAccessManager::PendingRequest::PendingRequest(
+  DetailedPromise* aPromise,
+  const nsAString& aKeySystem,
+  const Sequence<MediaKeySystemConfiguration>& aConfigs,
+  nsITimer* aTimer)
   : mPromise(aPromise)
   , mKeySystem(aKeySystem)
   , mConfigs(aConfigs)
   , mTimer(aTimer)
 {
   MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest);
 }
 
-MediaKeySystemAccessManager::PendingRequest::PendingRequest(const PendingRequest& aOther)
+MediaKeySystemAccessManager::PendingRequest::PendingRequest(
+  const PendingRequest& aOther)
   : mPromise(aOther.mPromise)
   , mKeySystem(aOther.mKeySystem)
   , mConfigs(aOther.mConfigs)
   , mTimer(aOther.mTimer)
 {
   MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest);
 }
 
@@ -212,50 +223,58 @@ void
 MediaKeySystemAccessManager::PendingRequest::CancelTimer()
 {
   if (mTimer) {
     mTimer->Cancel();
   }
 }
 
 void
-MediaKeySystemAccessManager::PendingRequest::RejectPromise(const nsCString& aReason)
+MediaKeySystemAccessManager::PendingRequest::RejectPromise(
+  const nsCString& aReason)
 {
   if (mPromise) {
     mPromise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR, aReason);
   }
 }
 
 bool
-MediaKeySystemAccessManager::AwaitInstall(DetailedPromise* aPromise,
-                                          const nsAString& aKeySystem,
-                                          const Sequence<MediaKeySystemConfiguration>& aConfigs)
+MediaKeySystemAccessManager::AwaitInstall(
+  DetailedPromise* aPromise,
+  const nsAString& aKeySystem,
+  const Sequence<MediaKeySystemConfiguration>& aConfigs)
 {
-  EME_LOG("MediaKeySystemAccessManager::AwaitInstall %s", NS_ConvertUTF16toUTF8(aKeySystem).get());
+  EME_LOG("MediaKeySystemAccessManager::AwaitInstall %s",
+          NS_ConvertUTF16toUTF8(aKeySystem).get());
 
   if (!EnsureObserversAdded()) {
     NS_WARNING("Failed to add pref observer");
     return false;
   }
 
   nsCOMPtr<nsITimer> timer(do_CreateInstance("@mozilla.org/timer;1"));
-  if (!timer || NS_FAILED(timer->Init(this, 60 * 1000, nsITimer::TYPE_ONE_SHOT))) {
+  if (!timer
+      || NS_FAILED(timer->Init(this, 60 * 1000, nsITimer::TYPE_ONE_SHOT))) {
     NS_WARNING("Failed to create timer to await CDM install.");
     return false;
   }
 
-  mRequests.AppendElement(PendingRequest(aPromise, aKeySystem, aConfigs, timer));
+  mRequests.AppendElement(
+    PendingRequest(aPromise, aKeySystem, aConfigs, timer));
   return true;
 }
 
 void
 MediaKeySystemAccessManager::RetryRequest(PendingRequest& aRequest)
 {
   aRequest.CancelTimer();
-  Request(aRequest.mPromise, aRequest.mKeySystem, aRequest.mConfigs, RequestType::Subsequent);
+  Request(aRequest.mPromise,
+          aRequest.mKeySystem,
+          aRequest.mConfigs,
+          RequestType::Subsequent);
 }
 
 nsresult
 MediaKeySystemAccessManager::Observe(nsISupports* aSubject,
                                      const char* aTopic,
                                      const char16_t* aData)
 {
   EME_LOG("MediaKeySystemAccessManager::Observe %s", aTopic);
@@ -275,17 +294,18 @@ MediaKeySystemAccessManager::Observe(nsI
       if (status == MediaKeySystemStatus::Cdm_not_installed) {
         // Not yet installed, don't retry. Keep waiting until timeout.
         continue;
       }
       // Status has changed, retry request.
       requests.AppendElement(Move(request));
       mRequests.RemoveElementAt(i);
     }
-    // Retry all pending requests, but this time fail if the CDM is not installed.
+    // Retry all pending requests, but this time fail if the CDM is not
+    // installed.
     for (PendingRequest& request : requests) {
       RetryRequest(request);
     }
   } else if (!strcmp(aTopic, "timer-callback")) {
     // Find the timer that expired and re-run the request for it.
     nsCOMPtr<nsITimer> timer(do_QueryInterface(aSubject));
     for (size_t i = 0; i < mRequests.Length(); i++) {
       if (mRequests[i].mTimer == timer) {
@@ -302,36 +322,40 @@ MediaKeySystemAccessManager::Observe(nsI
 
 bool
 MediaKeySystemAccessManager::EnsureObserversAdded()
 {
   if (mAddedObservers) {
     return true;
   }
 
-  nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
+  nsCOMPtr<nsIObserverService> obsService =
+    mozilla::services::GetObserverService();
   if (NS_WARN_IF(!obsService)) {
     return false;
   }
-  mAddedObservers = NS_SUCCEEDED(obsService->AddObserver(this, "gmp-changed", false));
+  mAddedObservers =
+    NS_SUCCEEDED(obsService->AddObserver(this, "gmp-changed", false));
   return mAddedObservers;
 }
 
 void
 MediaKeySystemAccessManager::Shutdown()
 {
   EME_LOG("MediaKeySystemAccessManager::Shutdown");
   nsTArray<PendingRequest> requests(Move(mRequests));
   for (PendingRequest& request : requests) {
     // Cancel all requests; we're shutting down.
     request.CancelTimer();
-    request.RejectPromise(NS_LITERAL_CSTRING("Promise still outstanding at MediaKeySystemAccessManager shutdown"));
+    request.RejectPromise(NS_LITERAL_CSTRING(
+      "Promise still outstanding at MediaKeySystemAccessManager shutdown"));
   }
   if (mAddedObservers) {
-    nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
+    nsCOMPtr<nsIObserverService> obsService =
+      mozilla::services::GetObserverService();
     if (obsService) {
       obsService->RemoveObserver(this, "gmp-changed");
       mAddedObservers = false;
     }
   }
 }
 
 } // namespace dom
--- a/dom/media/eme/MediaKeySystemAccessManager.h
+++ b/dom/media/eme/MediaKeySystemAccessManager.h
@@ -1,18 +1,18 @@
 /* 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_MediaKeySystemAccessManager_h
 #define mozilla_dom_MediaKeySystemAccessManager_h
 
 #include "mozilla/dom/MediaKeySystemAccess.h"
+#include "nsCycleCollectionParticipant.h"
 #include "nsIObserver.h"
-#include "nsCycleCollectionParticipant.h"
 #include "nsISupportsImpl.h"
 #include "nsITimer.h"
 
 namespace mozilla {
 namespace dom {
 
 class DetailedPromise;
 class TestGMPVideoDecoder;
@@ -28,17 +28,18 @@ public:
   NS_DECL_NSIOBSERVER
 
   void Request(DetailedPromise* aPromise,
                const nsAString& aKeySystem,
                const Sequence<MediaKeySystemConfiguration>& aConfig);
 
   void Shutdown();
 
-  struct PendingRequest {
+  struct PendingRequest
+  {
     PendingRequest(DetailedPromise* aPromise,
                    const nsAString& aKeySystem,
                    const Sequence<MediaKeySystemConfiguration>& aConfig,
                    nsITimer* aTimer);
     PendingRequest(const PendingRequest& aOther);
     ~PendingRequest();
     void CancelTimer();
     void RejectPromise(const nsCString& aReason);
@@ -46,17 +47,18 @@ public:
     RefPtr<DetailedPromise> mPromise;
     const nsString mKeySystem;
     const Sequence<MediaKeySystemConfiguration> mConfigs;
     nsCOMPtr<nsITimer> mTimer;
   };
 
 private:
 
-  enum RequestType {
+  enum RequestType
+  {
     Initial,
     Subsequent
   };
 
   void Request(DetailedPromise* aPromise,
                const nsAString& aKeySystem,
                const Sequence<MediaKeySystemConfiguration>& aConfig,
                RequestType aType);
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -1,42 +1,42 @@
 /* -*- 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 "mozilla/dom/MediaKeys.h"
+#include "GMPCDMProxy.h"
 #include "GMPCrashHelper.h"
-#include "mozilla/dom/HTMLMediaElement.h"
-#include "mozilla/dom/MediaKeysBinding.h"
-#include "mozilla/dom/MediaKeyMessageEvent.h"
-#include "mozilla/dom/MediaKeyError.h"
-#include "mozilla/dom/MediaKeySession.h"
-#include "mozilla/dom/DOMException.h"
-#include "mozilla/dom/UnionTypes.h"
-#include "mozilla/Telemetry.h"
-#include "GMPCDMProxy.h"
+#ifdef MOZ_FMP4
+#include "MP4Decoder.h"
+#endif
 #ifdef MOZ_WIDGET_ANDROID
 #include "mozilla/MediaDrmCDMProxy.h"
 #endif
-#include "mozilla/EMEUtils.h"
-#include "nsContentUtils.h"
-#include "nsIScriptObjectPrincipal.h"
-#include "nsContentTypeParser.h"
-#ifdef MOZ_FMP4
-#include "MP4Decoder.h"
-#endif
+#include "mozilla/Telemetry.h"
 #ifdef XP_WIN
 #include "mozilla/WindowsVersion.h"
 #endif
+#include "mozilla/EMEUtils.h"
+#include "mozilla/dom/DOMException.h"
+#include "mozilla/dom/HTMLMediaElement.h"
+#include "mozilla/dom/MediaKeyError.h"
+#include "mozilla/dom/MediaKeyMessageEvent.h"
+#include "mozilla/dom/MediaKeySession.h"
+#include "mozilla/dom/MediaKeySystemAccess.h"
+#include "mozilla/dom/MediaKeysBinding.h"
+#include "mozilla/dom/UnionTypes.h"
 #include "nsContentCID.h"
+#include "nsContentTypeParser.h"
+#include "nsContentUtils.h"
+#include "nsIScriptObjectPrincipal.h"
+#include "nsPrintfCString.h"
 #include "nsServiceManagerUtils.h"
-#include "mozilla/dom/MediaKeySystemAccess.h"
-#include "nsPrintfCString.h"
 
 namespace mozilla {
 
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeys,
                                       mElement,
                                       mParent,
@@ -101,18 +101,19 @@ MediaKeys::Shutdown()
     mProxy->Shutdown();
     mProxy = nullptr;
   }
 
   RefPtr<MediaKeys> kungFuDeathGrip = this;
 
   for (auto iter = mPromises.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<dom::DetailedPromise>& promise = iter.Data();
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Promise still outstanding at MediaKeys shutdown"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Promise still outstanding at MediaKeys shutdown"));
     Release();
   }
   mPromises.Clear();
 }
 
 nsPIDOMWindowInner*
 MediaKeys::GetParentObject() const
 {
@@ -127,36 +128,40 @@ MediaKeys::WrapObject(JSContext* aCx, JS
 
 void
 MediaKeys::GetKeySystem(nsString& aOutKeySystem) const
 {
   aOutKeySystem.Assign(mKeySystem);
 }
 
 already_AddRefed<DetailedPromise>
-MediaKeys::SetServerCertificate(const ArrayBufferViewOrArrayBuffer& aCert, ErrorResult& aRv)
+MediaKeys::SetServerCertificate(const ArrayBufferViewOrArrayBuffer& aCert,
+                                ErrorResult& aRv)
 {
-  RefPtr<DetailedPromise> promise(MakePromise(aRv,
-    NS_LITERAL_CSTRING("MediaKeys.setServerCertificate")));
+  RefPtr<DetailedPromise> promise(
+    MakePromise(aRv, NS_LITERAL_CSTRING("MediaKeys.setServerCertificate")));
   if (aRv.Failed()) {
     return nullptr;
   }
 
   if (!mProxy) {
     NS_WARNING("Tried to use a MediaKeys without a CDM");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Null CDM in MediaKeys.setServerCertificate()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Null CDM in MediaKeys.setServerCertificate()"));
     return promise.forget();
   }
 
   nsTArray<uint8_t> data;
   CopyArrayBufferViewOrArrayBufferData(aCert, data);
   if (data.IsEmpty()) {
-    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
-      NS_LITERAL_CSTRING("Empty certificate passed to MediaKeys.setServerCertificate()"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_TYPE_ERR,
+      NS_LITERAL_CSTRING(
+        "Empty certificate passed to MediaKeys.setServerCertificate()"));
     return promise.forget();
   }
 
   mProxy->SetServerCertificate(StorePromise(promise), data);
   return promise.forget();
 }
 
 already_AddRefed<DetailedPromise>
@@ -203,17 +208,19 @@ MediaKeys::ConnectPendingPromiseIdWithTo
   EME_LOG("MediaKeys[%p]::ConnectPendingPromiseIdWithToken() id=%u => token(%u)",
           this, aId, aToken);
 }
 
 already_AddRefed<DetailedPromise>
 MediaKeys::RetrievePromise(PromiseId aId)
 {
   if (!mPromises.Contains(aId)) {
-    NS_WARNING(nsPrintfCString("Tried to retrieve a non-existent promise id=%d", aId).get());
+    NS_WARNING(
+      nsPrintfCString("Tried to retrieve a non-existent promise id=%d", aId)
+        .get());
     return nullptr;
   }
   RefPtr<DetailedPromise> promise;
   mPromises.Remove(aId, getter_AddRefs(promise));
   Release();
   return promise.forget();
 }
 
@@ -359,58 +366,66 @@ MediaKeys::Init(ErrorResult& aRv)
     return nullptr;
   }
 
   mProxy = CreateCDMProxy();
 
   // Determine principal (at creation time) of the MediaKeys object.
   nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(GetParentObject());
   if (!sop) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Couldn't get script principal in MediaKeys::Init"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Couldn't get script principal in MediaKeys::Init"));
     return promise.forget();
   }
   mPrincipal = sop->GetPrincipal();
 
   // Determine principal of the "top-level" window; the principal of the
   // page that will display in the URL bar.
   nsCOMPtr<nsPIDOMWindowInner> window = GetParentObject();
   if (!window) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Couldn't get top-level window in MediaKeys::Init"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Couldn't get top-level window in MediaKeys::Init"));
     return promise.forget();
   }
   nsCOMPtr<nsPIDOMWindowOuter> top = window->GetOuterWindow()->GetTop();
   if (!top || !top->GetExtantDoc()) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Couldn't get document in MediaKeys::Init"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Couldn't get document in MediaKeys::Init"));
     return promise.forget();
   }
 
   mTopLevelPrincipal = top->GetExtantDoc()->NodePrincipal();
 
   if (!mPrincipal || !mTopLevelPrincipal) {
     NS_WARNING("Failed to get principals when creating MediaKeys");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Couldn't get principal(s) in MediaKeys::Init"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING("Couldn't get principal(s) in MediaKeys::Init"));
     return promise.forget();
   }
 
   nsAutoCString origin;
   nsresult rv = mPrincipal->GetOrigin(origin);
   if (NS_FAILED(rv)) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Couldn't get principal origin string in MediaKeys::Init"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "Couldn't get principal origin string in MediaKeys::Init"));
     return promise.forget();
   }
   nsAutoCString topLevelOrigin;
   rv = mTopLevelPrincipal->GetOrigin(topLevelOrigin);
   if (NS_FAILED(rv)) {
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
-                         NS_LITERAL_CSTRING("Couldn't get top-level principal origin string in MediaKeys::Init"));
+    promise->MaybeReject(
+      NS_ERROR_DOM_INVALID_STATE_ERR,
+      NS_LITERAL_CSTRING(
+        "Couldn't get top-level principal origin string in MediaKeys::Init"));
     return promise.forget();
   }
 
   EME_LOG("MediaKeys[%p]::Create() (%s, %s)",
           this,
           origin.get(),
           topLevelOrigin.get());
 
@@ -446,17 +461,18 @@ MediaKeys::OnCDMCreated(PromiseId aId, c
   if (mCreatePromiseId == aId) {
     Release();
   }
 
   MediaKeySystemAccess::NotifyObservers(mParent,
                                         mKeySystem,
                                         MediaKeySystemStatus::Cdm_created);
 
-  Telemetry::Accumulate(Telemetry::VIDEO_CDM_CREATED, ToCDMTypeTelemetryEnum(mKeySystem));
+  Telemetry::Accumulate(Telemetry::VIDEO_CDM_CREATED,
+                        ToCDMTypeTelemetryEnum(mKeySystem));
 }
 
 static bool
 IsSessionTypeSupported(const MediaKeySessionType aSessionType,
                        const MediaKeySystemConfiguration& aConfig)
 {
   if (aSessionType == MediaKeySessionType::Temporary) {
     // Temporary is always supported.
@@ -477,35 +493,33 @@ IsSessionTypeSupported(const MediaKeySes
 }
 
 already_AddRefed<MediaKeySession>
 MediaKeys::CreateSession(JSContext* aCx,
                          MediaKeySessionType aSessionType,
                          ErrorResult& aRv)
 {
   if (!IsSessionTypeSupported(aSessionType, mConfig)) {
-    EME_LOG("MediaKeys[%p,'%s'] CreateSession() failed, unsupported session type", this);
+    EME_LOG(
+      "MediaKeys[%p,'%s'] CreateSession() failed, unsupported session type",
+      this);
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return nullptr;
   }
 
   if (!mProxy) {
     NS_WARNING("Tried to use a MediaKeys which lost its CDM");
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   EME_LOG("MediaKeys[%p] Creating session", this);
 
-  RefPtr<MediaKeySession> session = new MediaKeySession(aCx,
-                                                        GetParentObject(),
-                                                        this,
-                                                        mKeySystem,
-                                                        aSessionType,
-                                                        aRv);
+  RefPtr<MediaKeySession> session = new MediaKeySession(
+    aCx, GetParentObject(), this, mKeySystem, aSessionType, aRv);
 
   if (aRv.Failed()) {
     return nullptr;
   }
 
   // Add session to the set of sessions awaiting their sessionId being ready.
   mPendingSessions.Put(session->Token(), session);
 
--- a/dom/media/eme/MediaKeys.h
+++ b/dom/media/eme/MediaKeys.h
@@ -2,43 +2,44 @@
 /* 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_mediakeys_h__
 #define mozilla_dom_mediakeys_h__
 
-#include "nsWrapperCache.h"
-#include "nsISupports.h"
+#include "mozIGeckoMediaPluginService.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/DetailedPromise.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/WeakPtr.h"
+#include "mozilla/dom/MediaKeySystemAccessBinding.h"
+#include "mozilla/dom/MediaKeysBinding.h"
+#include "mozilla/dom/Promise.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsISupports.h"
 #include "nsRefPtrHashtable.h"
-#include "mozilla/dom/Promise.h"
-#include "mozilla/dom/MediaKeysBinding.h"
-#include "mozilla/dom/MediaKeySystemAccessBinding.h"
-#include "mozIGeckoMediaPluginService.h"
-#include "mozilla/DetailedPromise.h"
-#include "mozilla/WeakPtr.h"
+#include "nsWrapperCache.h"
 
 namespace mozilla {
 
 class CDMProxy;
 
 namespace dom {
 
 class ArrayBufferViewOrArrayBuffer;
 class MediaKeySession;
 class HTMLMediaElement;
 
 typedef nsRefPtrHashtable<nsStringHashKey, MediaKeySession> KeySessionHashMap;
 typedef nsRefPtrHashtable<nsUint32HashKey, dom::DetailedPromise> PromiseHashMap;
-typedef nsRefPtrHashtable<nsUint32HashKey, MediaKeySession> PendingKeySessionsHashMap;
+typedef nsRefPtrHashtable<nsUint32HashKey, MediaKeySession>
+  PendingKeySessionsHashMap;
 typedef nsDataHashtable<nsUint32HashKey, uint32_t> PendingPromiseIdTokenHashMap;
 typedef uint32_t PromiseId;
 
 // This class is used on the main thread only.
 // Note: its addref/release is not (and can't be) thread safe!
 class MediaKeys final : public nsISupports,
                         public nsWrapperCache,
                         public SupportsWeakPtr<MediaKeys>
@@ -53,33 +54,35 @@ public:
   MediaKeys(nsPIDOMWindowInner* aParentWindow,
             const nsAString& aKeySystem,
             const MediaKeySystemConfiguration& aConfig);
 
   already_AddRefed<DetailedPromise> Init(ErrorResult& aRv);
 
   nsPIDOMWindowInner* GetParentObject() const;
 
-  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override;
 
   nsresult Bind(HTMLMediaElement* aElement);
   void Unbind();
 
   // Javascript: readonly attribute DOMString keySystem;
   void GetKeySystem(nsString& retval) const;
 
   // JavaScript: MediaKeys.createSession()
-  already_AddRefed<MediaKeySession> CreateSession(JSContext* aCx,
-                                                  MediaKeySessionType aSessionType,
-                                                  ErrorResult& aRv);
+  already_AddRefed<MediaKeySession> CreateSession(
+    JSContext* aCx,
+    MediaKeySessionType aSessionType,
+    ErrorResult& aRv);
 
   // JavaScript: MediaKeys.SetServerCertificate()
-  already_AddRefed<DetailedPromise>
-    SetServerCertificate(const ArrayBufferViewOrArrayBuffer& aServerCertificate,
-                         ErrorResult& aRv);
+  already_AddRefed<DetailedPromise> SetServerCertificate(
+    const ArrayBufferViewOrArrayBuffer& aServerCertificate,
+    ErrorResult& aRv);
 
   already_AddRefed<MediaKeySession> GetSession(const nsAString& aSessionId);
 
   // Removes and returns MediaKeySession from the set of sessions awaiting
   // their sessionId to be assigned.
   already_AddRefed<MediaKeySession> GetPendingSession(uint32_t aToken);
 
   // Called once a Init() operation succeeds.
--- a/dom/media/eme/mediadrm/MediaDrmCDMCallbackProxy.cpp
+++ b/dom/media/eme/mediadrm/MediaDrmCDMCallbackProxy.cpp
@@ -1,31 +1,30 @@
 /* -*- 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 "MediaDrmCDMCallbackProxy.h"
+#include "MainThreadUtils.h"
+#include "mozIGeckoMediaPluginService.h"
 #include "mozilla/CDMProxy.h"
-#include "nsString.h"
+#include "mozilla/EMEUtils.h"
+#include "mozilla/dom/MediaKeySession.h"
 #include "mozilla/dom/MediaKeys.h"
-#include "mozilla/dom/MediaKeySession.h"
-#include "mozIGeckoMediaPluginService.h"
 #include "nsContentCID.h"
 #include "nsServiceManagerUtils.h"
-#include "MainThreadUtils.h"
-#include "mozilla/EMEUtils.h"
+#include "nsString.h"
 
 namespace mozilla {
 
 MediaDrmCDMCallbackProxy::MediaDrmCDMCallbackProxy(CDMProxy* aProxy)
   : mProxy(aProxy)
 {
-
 }
 
 void
 MediaDrmCDMCallbackProxy::SetSessionId(uint32_t aToken,
                                        const nsCString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   mProxy->OnSetSessionId(aToken, NS_ConvertUTF8toUTF16(aSessionId));
@@ -58,17 +57,18 @@ MediaDrmCDMCallbackProxy::RejectPromise(
 void
 MediaDrmCDMCallbackProxy::SessionMessage(const nsCString& aSessionId,
                                          dom::MediaKeyMessageType aMessageType,
                                          const nsTArray<uint8_t>& aMessage)
 {
   MOZ_ASSERT(NS_IsMainThread());
   // For removing constness
   nsTArray<uint8_t> message(aMessage);
-  mProxy->OnSessionMessage(NS_ConvertUTF8toUTF16(aSessionId), aMessageType, message);
+  mProxy->OnSessionMessage(
+    NS_ConvertUTF8toUTF16(aSessionId), aMessageType, message);
 }
 
 void
 MediaDrmCDMCallbackProxy::ExpirationChange(const nsCString& aSessionId,
                                            UnixTime aExpiryTime)
 {
   MOZ_ASSERT(NS_IsMainThread());
   mProxy->OnExpirationChange(NS_ConvertUTF8toUTF16(aSessionId), aExpiryTime);
@@ -76,17 +76,18 @@ MediaDrmCDMCallbackProxy::ExpirationChan
 
 void
 MediaDrmCDMCallbackProxy::SessionClosed(const nsCString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   bool keyStatusesChange = false;
   {
     CDMCaps::AutoLock caps(mProxy->Capabilites());
-    keyStatusesChange = caps.RemoveKeysForSession(NS_ConvertUTF8toUTF16(aSessionId));
+    keyStatusesChange =
+      caps.RemoveKeysForSession(NS_ConvertUTF8toUTF16(aSessionId));
   }
   if (keyStatusesChange) {
     mProxy->OnKeyStatusesChange(NS_ConvertUTF8toUTF16(aSessionId));
   }
   mProxy->OnSessionClosed(NS_ConvertUTF8toUTF16(aSessionId));
 }
 
 void
@@ -98,35 +99,35 @@ MediaDrmCDMCallbackProxy::SessionError(c
   MOZ_ASSERT(NS_IsMainThread());
   mProxy->OnSessionError(NS_ConvertUTF8toUTF16(aSessionId),
                          aException,
                          aSystemCode,
                          NS_ConvertUTF8toUTF16(aMessage));
 }
 
 void
-MediaDrmCDMCallbackProxy::BatchedKeyStatusChanged(const nsCString& aSessionId,
-                                                  const nsTArray<CDMKeyInfo>& aKeyInfos)
+MediaDrmCDMCallbackProxy::BatchedKeyStatusChanged(
+  const nsCString& aSessionId,
+  const nsTArray<CDMKeyInfo>& aKeyInfos)
 {
   MOZ_ASSERT(NS_IsMainThread());
   BatchedKeyStatusChangedInternal(aSessionId, aKeyInfos);
 }
 
 void
-MediaDrmCDMCallbackProxy::BatchedKeyStatusChangedInternal(const nsCString& aSessionId,
-                                                          const nsTArray<CDMKeyInfo>& aKeyInfos)
+MediaDrmCDMCallbackProxy::BatchedKeyStatusChangedInternal(
+  const nsCString& aSessionId,
+  const nsTArray<CDMKeyInfo>& aKeyInfos)
 {
   bool keyStatusesChange = false;
   {
     CDMCaps::AutoLock caps(mProxy->Capabilites());
-    for (size_t i = 0; i < aKeyInfos.Length(); i++) {
-      keyStatusesChange |=
-        caps.SetKeyStatus(aKeyInfos[i].mKeyId,
-                          NS_ConvertUTF8toUTF16(aSessionId),
-                          aKeyInfos[i].mStatus);
+    for (const auto& key : aKeyInfos.Length() {
+      keyStatusesChange |= caps.SetKeyStatus(
+        key.mKeyId, NS_ConvertUTF8toUTF16(aSessionId), key.mStatus);
     }
   }
   if (keyStatusesChange) {
     mProxy->OnKeyStatusesChange(NS_ConvertUTF8toUTF16(aSessionId));
   }
 }
 
 void
--- a/dom/media/eme/mediadrm/MediaDrmCDMCallbackProxy.h
+++ b/dom/media/eme/mediadrm/MediaDrmCDMCallbackProxy.h
@@ -7,22 +7,22 @@
 #ifndef MediaDrmCDMCallbackProxy_h_
 #define MediaDrmCDMCallbackProxy_h_
 
 #include "mozilla/CDMProxy.h"
 #include "mozilla/DecryptorProxyCallback.h"
 
 namespace mozilla {
 class CDMProxy;
-// Proxies call backs from the MediaDrmProxy -> MediaDrmProxySupport back to the MediaKeys
-// object on the main thread.
-// We used annotation calledFrom = "gecko" to ensure running on main thread.
-class MediaDrmCDMCallbackProxy : public DecryptorProxyCallback {
+// Proxies call backs from the MediaDrmProxy -> MediaDrmProxySupport back to the
+// MediaKeys object on the main thread. We used annotation calledFrom = "gecko"
+// to ensure running on main thread.
+class MediaDrmCDMCallbackProxy : public DecryptorProxyCallback
+{
 public:
-
   void SetDecryptorId(uint32_t aId) override {}
 
   void SetSessionId(uint32_t aCreateSessionToken,
                     const nsCString& aSessionId) override;
 
   void ResolveLoadSessionPromise(uint32_t aPromiseId,
                                  bool aSuccess) override;
 
@@ -48,17 +48,17 @@ public:
 
   void Decrypted(uint32_t aId,
                  DecryptStatus aResult,
                  const nsTArray<uint8_t>& aDecryptedData) override;
 
   void BatchedKeyStatusChanged(const nsCString& aSessionId,
                                const nsTArray<CDMKeyInfo>& aKeyInfos) override;
 
-   ~MediaDrmCDMCallbackProxy() {}
+   ~MediaDrmCDMCallbackProxy() { }
 
 private:
   friend class MediaDrmCDMProxy;
   explicit MediaDrmCDMCallbackProxy(CDMProxy* aProxy);
 
   void BatchedKeyStatusChangedInternal(const nsCString& aSessionId,
                                        const nsTArray<CDMKeyInfo>& aKeyInfos);
   // Warning: Weak ref.
--- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
+++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp
@@ -52,28 +52,30 @@ MediaDrmCDMProxy::Init(PromiseId aPromis
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   EME_LOG("MediaDrmCDMProxy::Init (%s, %s) %s",
           NS_ConvertUTF16toUTF8(aOrigin).get(),
           NS_ConvertUTF16toUTF8(aTopLevelOrigin).get());
 
   // Create a thread to work with cdm.
   if (!mOwnerThread) {
-    nsresult rv = NS_NewNamedThread("MDCDMThread", getter_AddRefs(mOwnerThread));
+    nsresult rv =
+      NS_NewNamedThread("MDCDMThread", getter_AddRefs(mOwnerThread));
     if (NS_FAILED(rv)) {
-      RejectPromise(aPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR,
-                    NS_LITERAL_CSTRING("Couldn't create CDM thread MediaDrmCDMProxy::Init"));
+      RejectPromise(aPromiseId,
+                    NS_ERROR_DOM_INVALID_STATE_ERR,
+                    NS_LITERAL_CSTRING(
+                      "Couldn't create CDM thread MediaDrmCDMProxy::Init"));
       return;
     }
   }
 
   mCDM = mozilla::MakeUnique<MediaDrmProxySupport>(mKeySystem);
-  nsCOMPtr<nsIRunnable> task(NewRunnableMethod<uint32_t>(this,
-                                                         &MediaDrmCDMProxy::md_Init,
-                                                         aPromiseId));
+  nsCOMPtr<nsIRunnable> task(
+    NewRunnableMethod<uint32_t>(this, &MediaDrmCDMProxy::md_Init, aPromiseId));
   mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 MediaDrmCDMProxy::CreateSession(uint32_t aCreateSessionToken,
                                 MediaKeySessionType aSessionType,
                                 PromiseId aPromiseId,
                                 const nsAString& aInitDataType,
@@ -84,88 +86,88 @@ MediaDrmCDMProxy::CreateSession(uint32_t
 
   UniquePtr<CreateSessionData> data(new CreateSessionData());
   data->mSessionType = aSessionType;
   data->mCreateSessionToken = aCreateSessionToken;
   data->mPromiseId = aPromiseId;
   data->mInitDataType = NS_ConvertUTF16toUTF8(aInitDataType);
   data->mInitData = Move(aInitData);
 
-  nsCOMPtr<nsIRunnable> task(
-    NewRunnableMethod<UniquePtr<CreateSessionData>&&>(this,
-                                                      &MediaDrmCDMProxy::md_CreateSession,
-                                                      Move(data)));
+  nsCOMPtr<nsIRunnable> task(NewRunnableMethod<UniquePtr<CreateSessionData>&&>(
+    this, &MediaDrmCDMProxy::md_CreateSession, Move(data)));
   mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 MediaDrmCDMProxy::LoadSession(PromiseId aPromiseId,
                               const nsAString& aSessionId)
 {
   // TODO: Implement LoadSession.
-  RejectPromise(aPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR,
-                NS_LITERAL_CSTRING("Currently Fennec did not support LoadSession"));
+  RejectPromise(
+    aPromiseId,
+    NS_ERROR_DOM_INVALID_STATE_ERR,
+    NS_LITERAL_CSTRING("Currently Fennec did not support LoadSession"));
 }
 
 void
 MediaDrmCDMProxy::SetServerCertificate(PromiseId aPromiseId,
                                      nsTArray<uint8_t>& aCert)
 {
   // TODO: Implement SetServerCertificate.
-  RejectPromise(aPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR,
-                NS_LITERAL_CSTRING("Currently Fennec did not support SetServerCertificate"));
+  RejectPromise(aPromiseId,
+                NS_ERROR_DOM_INVALID_STATE_ERR,
+                NS_LITERAL_CSTRING(
+                  "Currently Fennec did not support SetServerCertificate"));
 }
 
 void
 MediaDrmCDMProxy::UpdateSession(const nsAString& aSessionId,
                               PromiseId aPromiseId,
                               nsTArray<uint8_t>& aResponse)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mOwnerThread);
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   UniquePtr<UpdateSessionData> data(new UpdateSessionData());
   data->mPromiseId = aPromiseId;
   data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId);
   data->mResponse = Move(aResponse);
 
-  nsCOMPtr<nsIRunnable> task(
-    NewRunnableMethod<UniquePtr<UpdateSessionData>&&>(this,
-                                                      &MediaDrmCDMProxy::md_UpdateSession,
-                                                      Move(data)));
+  nsCOMPtr<nsIRunnable> task(NewRunnableMethod<UniquePtr<UpdateSessionData>&&>(
+    this, &MediaDrmCDMProxy::md_UpdateSession, Move(data)));
   mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 MediaDrmCDMProxy::CloseSession(const nsAString& aSessionId,
                              PromiseId aPromiseId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mOwnerThread);
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   UniquePtr<SessionOpData> data(new SessionOpData());
   data->mPromiseId = aPromiseId;
   data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId);
 
-  nsCOMPtr<nsIRunnable> task(
-    NewRunnableMethod<UniquePtr<SessionOpData>&&>(this,
-                                                  &MediaDrmCDMProxy::md_CloseSession,
-                                                  Move(data)));
+  nsCOMPtr<nsIRunnable> task(NewRunnableMethod<UniquePtr<SessionOpData>&&>(
+    this, &MediaDrmCDMProxy::md_CloseSession, Move(data)));
   mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 MediaDrmCDMProxy::RemoveSession(const nsAString& aSessionId,
                               PromiseId aPromiseId)
 {
   // TODO: Implement RemoveSession.
-  RejectPromise(aPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR,
-                NS_LITERAL_CSTRING("Currently Fennec did not support RemoveSession"));
+  RejectPromise(
+    aPromiseId,
+    NS_ERROR_DOM_INVALID_STATE_ERR,
+    NS_LITERAL_CSTRING("Currently Fennec did not support RemoveSession"));
 }
 
 void
 MediaDrmCDMProxy::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mOwnerThread);
   nsCOMPtr<nsIRunnable> task(
@@ -193,24 +195,26 @@ void
 MediaDrmCDMProxy::OnSetSessionId(uint32_t aCreateSessionToken,
                                  const nsAString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mKeys.IsNull()) {
     return;
   }
 
-  RefPtr<dom::MediaKeySession> session(mKeys->GetPendingSession(aCreateSessionToken));
+  RefPtr<dom::MediaKeySession> session(
+    mKeys->GetPendingSession(aCreateSessionToken));
   if (session) {
     session->SetSessionId(aSessionId);
   }
 }
 
 void
-MediaDrmCDMProxy::OnResolveLoadSessionPromise(uint32_t aPromiseId, bool aSuccess)
+MediaDrmCDMProxy::OnResolveLoadSessionPromise(uint32_t aPromiseId,
+                                              bool aSuccess)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mKeys.IsNull()) {
     return;
   }
   mKeys->OnSessionLoaded(aPromiseId, aSuccess);
 }
 
@@ -300,36 +304,35 @@ void
 MediaDrmCDMProxy::RejectPromise(PromiseId aId, nsresult aCode,
                                 const nsCString& aReason)
 {
   if (NS_IsMainThread()) {
     if (!mKeys.IsNull()) {
       mKeys->RejectPromise(aId, aCode, aReason);
     }
   } else {
-    nsCOMPtr<nsIRunnable> task(new RejectPromiseTask(this, aId, aCode,
-                                                     aReason));
+    nsCOMPtr<nsIRunnable> task(
+      new RejectPromiseTask(this, aId, aCode, aReason));
     NS_DispatchToMainThread(task);
   }
 }
 
 void
 MediaDrmCDMProxy::ResolvePromise(PromiseId aId)
 {
   if (NS_IsMainThread()) {
     if (!mKeys.IsNull()) {
       mKeys->ResolvePromise(aId);
     } else {
       NS_WARNING("MediaDrmCDMProxy unable to resolve promise!");
     }
   } else {
     nsCOMPtr<nsIRunnable> task;
-    task = NewRunnableMethod<PromiseId>(this,
-                                        &MediaDrmCDMProxy::ResolvePromise,
-                                        aId);
+    task = NewRunnableMethod<PromiseId>(
+      this, &MediaDrmCDMProxy::ResolvePromise, aId);
     NS_DispatchToMainThread(task);
   }
 }
 
 const nsString&
 MediaDrmCDMProxy::KeySystem() const
 {
   return mKeySystem;
@@ -351,17 +354,17 @@ MediaDrmCDMProxy::OnKeyStatusesChange(co
   RefPtr<dom::MediaKeySession> session(mKeys->GetSession(aSessionId));
   if (session) {
     session->DispatchKeyStatusesChange();
   }
 }
 
 void
 MediaDrmCDMProxy::GetSessionIdsForKeyId(const nsTArray<uint8_t>& aKeyId,
-                                      nsTArray<nsCString>& aSessionIds)
+                                        nsTArray<nsCString>& aSessionIds)
 {
   CDMCaps::AutoLock caps(Capabilites());
   caps.GetSessionIdsForKeyId(aKeyId, aSessionIds);
 }
 
 #ifdef DEBUG
 bool
 MediaDrmCDMProxy::IsOnOwnerThread()
@@ -398,20 +401,18 @@ MediaDrmCDMProxy::OnCDMCreated(uint32_t 
 void
 MediaDrmCDMProxy::md_Init(uint32_t aPromiseId)
 {
   MOZ_ASSERT(IsOnOwnerThread());
   MOZ_ASSERT(mCDM);
 
   mCallback.reset(new MediaDrmCDMCallbackProxy(this));
   mCDM->Init(mCallback.get());
-  nsCOMPtr<nsIRunnable> task(
-    NewRunnableMethod<uint32_t>(this,
-                                &MediaDrmCDMProxy::OnCDMCreated,
-                                aPromiseId));
+  nsCOMPtr<nsIRunnable> task(NewRunnableMethod<uint32_t>(
+    this, &MediaDrmCDMProxy::OnCDMCreated, aPromiseId));
   NS_DispatchToMainThread(task);
 }
 
 void
 MediaDrmCDMProxy::md_CreateSession(UniquePtr<CreateSessionData>&& aData)
 {
   MOZ_ASSERT(IsOnOwnerThread());
 
--- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.h
+++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.h
@@ -2,34 +2,34 @@
 /* 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 MediaDrmCDMProxy_h_
 #define MediaDrmCDMProxy_h_
 
-#include <jni.h>
-#include "mozilla/jni/Types.h"
 #include "GeneratedJNINatives.h"
-#include "mozilla/CDMProxy.h"
+#include "MediaCodec.h"
 #include "mozilla/CDMCaps.h"
-#include "mozilla/dom/MediaKeys.h"
+#include "mozilla/CDMProxy.h"
 #include "mozilla/MediaDrmProxySupport.h"
 #include "mozilla/UniquePtr.h"
-
-#include "MediaCodec.h"
+#include "mozilla/dom/MediaKeys.h"
+#include "mozilla/jni/Types.h"
 #include "nsString.h"
+#include <jni.h>
 
 using namespace mozilla::java;
 
 namespace mozilla {
 
 class MediaDrmCDMCallbackProxy;
-class MediaDrmCDMProxy : public CDMProxy {
+class MediaDrmCDMProxy : public CDMProxy
+{
 public:
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDrmCDMProxy)
 
   MediaDrmCDMProxy(dom::MediaKeys* aKeys,
                    const nsAString& aKeySystem,
                    bool aDistinctiveIdentifierRequired,
                    bool aPersistentStateRequired);
@@ -118,68 +118,73 @@ public:
 
   const nsString& GetMediaDrmStubId() const;
 
 private:
   virtual ~MediaDrmCDMProxy();
 
   void OnCDMCreated(uint32_t aPromiseId);
 
-  struct CreateSessionData {
+  struct CreateSessionData
+  {
     MediaKeySessionType mSessionType;
     uint32_t mCreateSessionToken;
     PromiseId mPromiseId;
     nsCString mInitDataType;
     nsTArray<uint8_t> mInitData;
   };
 
-  struct UpdateSessionData {
+  struct UpdateSessionData
+  {
     PromiseId mPromiseId;
     nsCString mSessionId;
     nsTArray<uint8_t> mResponse;
   };
 
-  struct SessionOpData {
+  struct SessionOpData
+  {
     PromiseId mPromiseId;
     nsCString mSessionId;
   };
 
-  class RejectPromiseTask : public Runnable {
+  class RejectPromiseTask : public Runnable
+  {
   public:
     RejectPromiseTask(MediaDrmCDMProxy* aProxy,
                       PromiseId aId,
                       nsresult aCode,
                       const nsCString& aReason)
       : mProxy(aProxy)
       , mId(aId)
       , mCode(aCode)
       , mReason(aReason)
     {
     }
-    NS_IMETHOD Run() override {
+    NS_IMETHOD Run() override
+    {
       mProxy->RejectPromise(mId, mCode, mReason);
       return NS_OK;
     }
   private:
     RefPtr<MediaDrmCDMProxy> mProxy;
     PromiseId mId;
     nsresult mCode;
     nsCString mReason;
   };
 
   nsCString mNodeId;
   UniquePtr<MediaDrmProxySupport> mCDM;
   UniquePtr<MediaDrmCDMCallbackProxy> mCallback;
   bool mShutdownCalled;
 
-// =====================================================================
-// For MediaDrmProxySupport
+  // =====================================================================
+  // For MediaDrmProxySupport
   void md_Init(uint32_t aPromiseId);
   void md_CreateSession(UniquePtr<CreateSessionData>&& aData);
   void md_UpdateSession(UniquePtr<UpdateSessionData>&& aData);
   void md_CloseSession(UniquePtr<SessionOpData>&& aData);
   void md_Shutdown();
-// =====================================================================
+  // =====================================================================
 };
 
 } // namespace mozilla
 
 #endif // MediaDrmCDMProxy_h_
--- a/dom/media/eme/mediadrm/MediaDrmProxySupport.cpp
+++ b/dom/media/eme/mediadrm/MediaDrmProxySupport.cpp
@@ -1,34 +1,38 @@
 /* -*- 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 "MediaDrmProxySupport.h"
-#include "mozilla/EMEUtils.h"
 #include "FennecJNINatives.h"
 #include "MediaCodec.h" // For MediaDrm::KeyStatus
 #include "MediaPrefs.h"
+#include "mozilla/EMEUtils.h"
 
 using namespace mozilla::java;
 
 namespace mozilla {
 
-LogModule* GetMDRMNLog() {
+LogModule* GetMDRMNLog()
+{
   static LazyLogModule log("MediaDrmProxySupport");
   return log;
 }
 
 class MediaDrmJavaCallbacksSupport
-  : public MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives<MediaDrmJavaCallbacksSupport>
+  : public MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives<
+      MediaDrmJavaCallbacksSupport>
 {
 public:
-  typedef MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives<MediaDrmJavaCallbacksSupport> MediaDrmProxyNativeCallbacks;
+  typedef MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives<
+    MediaDrmJavaCallbacksSupport>
+    MediaDrmProxyNativeCallbacks;
   using MediaDrmProxyNativeCallbacks::DisposeNative;
   using MediaDrmProxyNativeCallbacks::AttachNative;
 
   MediaDrmJavaCallbacksSupport(DecryptorProxyCallback* aDecryptorProxyCallback)
     : mDecryptorProxyCallback(aDecryptorProxyCallback)
   {
     MOZ_ASSERT(aDecryptorProxyCallback);
   }
@@ -39,19 +43,20 @@ public:
                         int aPromiseId,
                         jni::ByteArray::Param aSessionId,
                         jni::ByteArray::Param aRequest);
 
   void OnSessionUpdated(int aPromiseId, jni::ByteArray::Param aSessionId);
 
   void OnSessionClosed(int aPromiseId, jni::ByteArray::Param aSessionId);
 
-  void OnSessionMessage(jni::ByteArray::Param aSessionId,
-                        int /*mozilla::dom::MediaKeyMessageType*/ aSessionMessageType,
-                        jni::ByteArray::Param aRequest);
+  void OnSessionMessage(
+    jni::ByteArray::Param aSessionId,
+    int /*mozilla::dom::MediaKeyMessageType*/ aSessionMessageType,
+    jni::ByteArray::Param aRequest);
 
   void OnSessionError(jni::ByteArray::Param aSessionId,
                       jni::String::Param aMessage);
 
   void OnSessionBatchedKeyChanged(jni::ByteArray::Param,
                                   jni::ObjectArray::Param);
 
   void OnRejectPromise(int aPromiseId, jni::String::Param aMessage);
@@ -63,64 +68,69 @@ private:
 void
 MediaDrmJavaCallbacksSupport::OnSessionCreated(int aCreateSessionToken,
                                                int aPromiseId,
                                                jni::ByteArray::Param aSessionId,
                                                jni::ByteArray::Param aRequest)
 {
   MOZ_ASSERT(NS_IsMainThread());
   auto reqDataArray = aRequest->GetElements();
-  nsCString sessionId(reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
-                      aSessionId->Length());
+  nsCString sessionId(
+    reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
+    aSessionId->Length());
   MDRMN_LOG("SessionId(%s) closed", sessionId.get());
 
   mDecryptorProxyCallback->SetSessionId(aCreateSessionToken, sessionId);
   mDecryptorProxyCallback->ResolvePromise(aPromiseId);
 }
 
 void
 MediaDrmJavaCallbacksSupport::OnSessionUpdated(int aPromiseId,
                                                jni::ByteArray::Param aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MDRMN_LOG("SessionId(%s) closed",
-            nsCString(reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
-                      aSessionId->Length()).get());
+  MDRMN_LOG(
+    "SessionId(%s) closed",
+    nsCString(reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
+              aSessionId->Length())
+      .get());
   mDecryptorProxyCallback->ResolvePromise(aPromiseId);
 }
 
 void
 MediaDrmJavaCallbacksSupport::OnSessionClosed(int aPromiseId,
                                               jni::ByteArray::Param aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  nsCString sessionId(reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
-                      aSessionId->Length());
+  nsCString sessionId(
+    reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
+    aSessionId->Length());
   MDRMN_LOG("SessionId(%s) closed", sessionId.get());
   mDecryptorProxyCallback->ResolvePromise(aPromiseId);
   mDecryptorProxyCallback->SessionClosed(sessionId);
 }
 
 void
-MediaDrmJavaCallbacksSupport::OnSessionMessage(jni::ByteArray::Param aSessionId,
-                                               int /*mozilla::dom::MediaKeyMessageType*/ aMessageType,
-                                               jni::ByteArray::Param aRequest)
+MediaDrmJavaCallbacksSupport::OnSessionMessage(
+  jni::ByteArray::Param aSessionId,
+  int /*mozilla::dom::MediaKeyMessageType*/ aMessageType,
+  jni::ByteArray::Param aRequest)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  nsCString sessionId(reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
-                      aSessionId->Length());
+  nsCString sessionId(
+    reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
+    aSessionId->Length());
   auto reqDataArray = aRequest->GetElements();
 
   nsTArray<uint8_t> retRequest;
   retRequest.AppendElements(reinterpret_cast<uint8_t*>(reqDataArray.Elements()),
                             reqDataArray.Length());
 
-  mDecryptorProxyCallback->SessionMessage(sessionId,
-                                          static_cast<dom::MediaKeyMessageType>(aMessageType),
-                                          retRequest);
+  mDecryptorProxyCallback->SessionMessage(
+    sessionId, static_cast<dom::MediaKeyMessageType>(aMessageType), retRequest);
 }
 
 void
 MediaDrmJavaCallbacksSupport::OnSessionError(jni::ByteArray::Param aSessionId,
                                              jni::String::Param aMessage)
 {
   MOZ_ASSERT(NS_IsMainThread());
   nsCString sessionId(reinterpret_cast<char*>(aSessionId->GetElements().Elements()),
--- a/dom/media/eme/mediadrm/MediaDrmProxySupport.h
+++ b/dom/media/eme/mediadrm/MediaDrmProxySupport.h
@@ -2,34 +2,37 @@
 /* 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 MediaDrmProxySupport_H
 #define MediaDrmProxySupport_H
 
+#include "FennecJNIWrappers.h"
 #include "mozilla/DecryptorProxyCallback.h"
 #include "mozilla/Logging.h"
-#include "FennecJNIWrappers.h"
 #include "nsString.h"
 
-
 namespace mozilla {
 
-enum MediaDrmSessionType {
+enum MediaDrmSessionType
+{
   kKeyStreaming = 1,
   kKeyOffline = 2,
   kKeyRelease = 3,
 };
 
 #ifndef MDRMN_LOG
-  LogModule* GetMDRMNLog();
-  #define MDRMN_LOG(x, ...) MOZ_LOG(GetMDRMNLog(), mozilla::LogLevel::Debug,\
-    ("[MediaDrmProxySupport][%s]" x, __FUNCTION__, ##__VA_ARGS__))
+LogModule*
+GetMDRMNLog();
+#define MDRMN_LOG(x, ...)                                                      \
+  MOZ_LOG(GetMDRMNLog(),                                                       \
+          mozilla::LogLevel::Debug,                                            \
+          ("[MediaDrmProxySupport][%s]" x, __FUNCTION__, ##__VA_ARGS__))
 #endif
 
 class MediaDrmProxySupport final
 {
 public:
 
   MediaDrmProxySupport(const nsAString& aKeySystem);
   ~MediaDrmProxySupport();