Bug 1361942 - Store ActualArgTypes instead of ArgTypes for we are sending data of ActualArgTypes types to another thread. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 03 May 2017 12:34:50 +0800
changeset 356448 3a94004edb22ee91086ce3ff14dd16a389da8f2e
parent 356447 d401cd6d2fd00771c818e80746f37a972070b11a
child 356449 a359d26695bf8fe69f41b0cf30ed55ff68e0d309
push id31767
push usercbook@mozilla.com
push dateFri, 05 May 2017 13:15:58 +0000
treeherdermozilla-central@8872ad4d52b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1361942
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1361942 - Store ActualArgTypes instead of ArgTypes for we are sending data of ActualArgTypes types to another thread. r=gerald This allows more use of the implicit version of InvokeAsync() without specifying the storage types explicitly. MozReview-Commit-ID: 40WisaVX8Jy
dom/media/gmp/GMPParent.cpp
dom/media/gmp/GMPServiceParent.cpp
xpcom/threads/MozPromise.h
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -720,17 +720,17 @@ RefPtr<GenericPromise>
 GMPParent::ReadChromiumManifestFile(nsIFile* aFile)
 {
   nsAutoCString json;
   if (!ReadIntoString(aFile, json, 5 * 1024)) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   // DOM JSON parsing needs to run on the main thread.
-  return InvokeAsync<nsString&&>(
+  return InvokeAsync(
     mMainThread, this, __func__,
     &GMPParent::ParseChromiumManifest, NS_ConvertUTF8toUTF16(json));
 }
 
 static bool
 IsCDMAPISupported(const mozilla::dom::WidevineCDMManifest& aManifest)
 {
   nsresult ignored; // Note: ToInteger returns 0 on failure.
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -637,17 +637,17 @@ GeckoMediaPluginServiceParent::AsyncAddP
 {
   RefPtr<AbstractThread> thread(GetAbstractGMPThread());
   if (!thread) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   nsString dir(aDirectory);
   RefPtr<GeckoMediaPluginServiceParent> self = this;
-  return InvokeAsync<nsString&&>(
+  return InvokeAsync(
            thread, this, __func__,
            &GeckoMediaPluginServiceParent::AddOnGMPThread, dir)
     ->Then(
       mMainThread,
       __func__,
       [dir, self]() -> void {
         LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s succeeded",
               NS_ConvertUTF16toUTF8(dir).get()));
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -1323,21 +1323,21 @@ template<typename... Storages,
          typename PromiseType, typename ThisType, typename... ArgTypes,
          typename... ActualArgTypes,
          typename EnableIf<sizeof...(Storages) == 0, int>::Type = 0>
 static RefPtr<PromiseType>
 InvokeAsync(AbstractThread* aTarget, ThisType* aThisVal, const char* aCallerName,
             RefPtr<PromiseType>(ThisType::*aMethod)(ArgTypes...),
             ActualArgTypes&&... aArgs)
 {
-  static_assert(!detail::Any(IsPointer<ArgTypes>::value...),
+  static_assert(!detail::Any(IsPointer<typename RemoveReference<ActualArgTypes>::Type>::value...),
                 "Cannot pass pointer types through InvokeAsync, Storages must be provided");
   static_assert(sizeof...(ArgTypes) == sizeof...(ActualArgTypes),
                 "Method's ArgTypes and ActualArgTypes should have equal sizes");
-  return detail::InvokeAsyncImpl<StoreCopyPassByRRef<typename Decay<ArgTypes>::Type>...>(
+  return detail::InvokeAsyncImpl<StoreCopyPassByRRef<typename Decay<ActualArgTypes>::Type>...>(
            aTarget, aThisVal, aCallerName, aMethod,
            Forward<ActualArgTypes>(aArgs)...);
 }
 
 namespace detail {
 
 template<typename Function, typename PromiseType>
 class ProxyFunctionRunnable : public CancelableRunnable