Bug 1677000 - Pass Promise* to RejectJSPromise instead of RefPtr<Promise>& r=Gijs
☠☠ backed out by 36baeb20dfe6 ☠ ☠
authorBarret Rennie <barret@brennie.ca>
Wed, 09 Dec 2020 04:30:46 +0000
changeset 559934 8e6081b0c07d5dfc6774e32b2476fb3fc22bc679
parent 559933 6592577cf0faa4657ed7a6ca7880e4227f7add1e
child 559935 a5d7845d3c0c2f34386450999ec0c5233d1b04bf
push id132355
push userbrennie@mozilla.com
push dateWed, 09 Dec 2020 04:38:04 +0000
treeherderautoland@3521334cfc38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1677000
milestone85.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 1677000 - Pass Promise* to RejectJSPromise instead of RefPtr<Promise>& r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D98998
dom/system/IOUtils.cpp
dom/system/IOUtils.h
--- a/dom/system/IOUtils.cpp
+++ b/dom/system/IOUtils.cpp
@@ -208,17 +208,16 @@ already_AddRefed<Promise> IOUtils::Read(
     toRead.emplace(aOptions.mMaxBytes.Value());
   }
 
   RunOnBackgroundThread<nsTArray<uint8_t>>(
       promise,
       [file = std::move(file), toRead, decompress = aOptions.mDecompress]() {
         return ReadSync(file, toRead, decompress);
       });
-
   return promise.forget();
 }
 
 /* static */
 already_AddRefed<Promise> IOUtils::ReadUTF8(GlobalObject& aGlobal,
                                             const nsAString& aPath,
                                             const ReadUTF8Options& aOptions) {
   MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
@@ -558,18 +557,17 @@ already_AddRefed<Promise> IOUtils::Creat
   if (er.Failed()) {
     return nullptr;
   }
   MOZ_ASSERT(promise);
   return do_AddRef(promise);
 }
 
 /* static */
-void IOUtils::RejectJSPromise(const RefPtr<Promise>& aPromise,
-                              const IOError& aError) {
+void IOUtils::RejectJSPromise(Promise* aPromise, const IOError& aError) {
   const auto& errMsg = aError.Message();
 
   switch (aError.Code()) {
     case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST:
     case NS_ERROR_FILE_NOT_FOUND:
       aPromise->MaybeRejectWithNotFoundError(errMsg.refOr("File not found"_ns));
       break;
     case NS_ERROR_FILE_ACCESS_DENIED:
--- a/dom/system/IOUtils.h
+++ b/dom/system/IOUtils.h
@@ -138,18 +138,17 @@ class IOUtils final {
   // Allow conversion of |InternalFileInfo| with |ToJSValue|.
   friend MOZ_MUST_USE bool ToJSValue(JSContext* aCx,
                                      const InternalFileInfo& aInternalFileInfo,
                                      JS::MutableHandle<JS::Value> aValue);
 
   /**
    * Rejects |aPromise| with an appropriate |DOMException| describing |aError|.
    */
-  static void RejectJSPromise(const RefPtr<Promise>& aPromise,
-                              const IOError& aError);
+  static void RejectJSPromise(Promise* aPromise, const IOError& aError);
 
   /**
    * Attempts to read the entire file at |aPath| into a buffer.
    *
    * @param aFile       The location of the file.
    * @param aMaxBytes   If |Some|, then only read up this this number of bytes,
    *                    otherwise attempt to read the whole file.
    * @param aDecompress If true, decompress the bytes read from disk before