Bug 1510265 - P2. Don't use AllPromiseType in GMPServiceParent. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 06 Dec 2018 20:16:15 +0000
changeset 508778 25db74150dbfcb550a538f361c9c99555148374f
parent 508777 0de0365e049fea70c203850963577bbabdf88577
child 508779 6de1ea2f0c0fefd9272907491c42be398fa99e49
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1510265
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1510265 - P2. Don't use AllPromiseType in GMPServiceParent. r=gerald It's not needed, and only makes code harder to follow. Differential Revision: https://phabricator.services.mozilla.com/D13869
dom/media/gmp/GMPServiceParent.cpp
dom/media/gmp/GMPServiceParent.h
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -481,36 +481,32 @@ void GeckoMediaPluginServiceParent::Cras
   MOZ_ASSERT(mGMPThread->EventTarget()->IsOnCurrentThread());
 
   MutexAutoLock lock(mMutex);
   for (size_t i = 0; i < mPlugins.Length(); i++) {
     mPlugins[i]->Crash();
   }
 }
 
-RefPtr<GenericPromise::AllPromiseType>
-GeckoMediaPluginServiceParent::LoadFromEnvironment() {
+RefPtr<GenericPromise> GeckoMediaPluginServiceParent::LoadFromEnvironment() {
   MOZ_ASSERT(mGMPThread->EventTarget()->IsOnCurrentThread());
   RefPtr<AbstractThread> thread(GetAbstractGMPThread());
   if (!thread) {
-    return GenericPromise::AllPromiseType::CreateAndReject(NS_ERROR_FAILURE,
-                                                           __func__);
+    return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   const char* env = PR_GetEnv("MOZ_GMP_PATH");
   if (!env || !*env) {
-    return GenericPromise::AllPromiseType::CreateAndResolve(
-        nsTArray<bool>{true}, __func__);
+    return GenericPromise::CreateAndResolve(true, __func__);
   }
 
   nsString allpaths;
   if (NS_WARN_IF(NS_FAILED(
           NS_CopyNativeToUnicode(nsDependentCString(env), allpaths)))) {
-    return GenericPromise::AllPromiseType::CreateAndReject(NS_ERROR_FAILURE,
-                                                           __func__);
+    return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   nsTArray<RefPtr<GenericPromise>> promises;
   uint32_t pos = 0;
   while (pos < allpaths.Length()) {
     // Loop over multiple path entries separated by colons (*nix) or
     // semicolons (Windows)
     int32_t next = allpaths.FindChar(XPCOM_ENV_PATH_SEPARATOR[0], pos);
@@ -521,17 +517,23 @@ GeckoMediaPluginServiceParent::LoadFromE
     } else {
       promises.AppendElement(
           AddOnGMPThread(nsString(Substring(allpaths, pos, next - pos))));
       pos = next + 1;
     }
   }
 
   mScannedPluginOnDisk = true;
-  return GenericPromise::All(thread, promises);
+  return GenericPromise::All(thread, promises)
+      ->Then(thread, __func__,
+             []() { return GenericPromise::CreateAndResolve(true, __func__); },
+             []() {
+               return GenericPromise::CreateAndReject(NS_ERROR_FAILURE,
+                                                      __func__);
+             });
 }
 
 class NotifyObserversTask final : public mozilla::Runnable {
  public:
   explicit NotifyObserversTask(const char* aTopic,
                                nsString aData = EmptyString())
       : Runnable(aTopic), mTopic(aTopic), mData(aData) {}
   NS_IMETHOD Run() override {
--- a/dom/media/gmp/GMPServiceParent.h
+++ b/dom/media/gmp/GMPServiceParent.h
@@ -109,17 +109,17 @@ class GeckoMediaPluginServiceParent fina
 
   already_AddRefed<GMPParent> GetById(uint32_t aPluginId);
 
  protected:
   friend class GMPParent;
   void ReAddOnGMPThread(const RefPtr<GMPParent>& aOld);
   void PluginTerminated(const RefPtr<GMPParent>& aOld);
   void InitializePlugins(AbstractThread* aAbstractGMPThread) override;
-  RefPtr<GenericPromise::AllPromiseType> LoadFromEnvironment();
+  RefPtr<GenericPromise> LoadFromEnvironment();
   RefPtr<GenericPromise> AddOnGMPThread(nsString aDirectory);
 
   virtual RefPtr<GetGMPContentParentPromise> GetContentParent(
       GMPCrashHelper* aHelper, const nsACString& aNodeIdString,
       const nsCString& aAPI, const nsTArray<nsCString>& aTags) override;
 
   RefPtr<GetGMPContentParentPromise> GetContentParent(
       GMPCrashHelper* aHelper, const NodeId& aNodeId, const nsCString& aAPI,