Bug 1410209, part 1 - Rename OSFile's ErrorEvent to avoid name conflicts. draft
authorAndrew McCreight <continuation@gmail.com>
Thu, 26 Oct 2017 13:43:23 -0700
changeset 687825 8019c76ef87b7e09724cc565ba399e971f9ed891
parent 687824 8c30c7648356310951f2eb900374c6533443900a
child 687826 6de8fd075c71e08d06e15fd231bbea2454be3101
child 687829 13f514addb8185bf7743f945220577e5801cb31d
push id86611
push userbmo:continuation@gmail.com
push dateFri, 27 Oct 2017 20:53:14 +0000
bugs1410209
milestone58.0a1
Bug 1410209, part 1 - Rename OSFile's ErrorEvent to avoid name conflicts. ErrorEvent is also the name of a DOM event class, which causes an assertion in the XPCOM leak checking system with the second patch. MozReview-Commit-ID: 3xTHondZr9n
toolkit/components/osfile/NativeOSFileInternals.cpp
--- a/toolkit/components/osfile/NativeOSFileInternals.cpp
+++ b/toolkit/components/osfile/NativeOSFileInternals.cpp
@@ -427,39 +427,39 @@ Int32Result::GetCacheableResult(JSContex
   return NS_OK;
 }
 
 //////// Callback events
 
 /**
  * An event used to notify asynchronously of an error.
  */
-class ErrorEvent final : public Runnable {
+class OSFileErrorEvent final : public Runnable {
 public:
   /**
    * @param aOnSuccess The success callback.
    * @param aOnError The error callback.
    * @param aDiscardedResult The discarded result.
    * @param aOperation The name of the operation, used for error reporting.
    * @param aOSError The OS error of the operation, as returned by errno/
    * GetLastError().
    *
    * Note that we pass both the success callback and the error
    * callback, as well as the discarded result to ensure that they are
    * all released on the main thread, rather than on the IO thread
    * (which would hopefully segfault). Also, we pass the callbacks as
    * alread_AddRefed to ensure that we do not manipulate main-thread
    * only refcounters off the main thread.
    */
-  ErrorEvent(nsMainThreadPtrHandle<nsINativeOSFileSuccessCallback>& aOnSuccess,
-             nsMainThreadPtrHandle<nsINativeOSFileErrorCallback>& aOnError,
-             already_AddRefed<AbstractResult>& aDiscardedResult,
-             const nsACString& aOperation,
-             int32_t aOSError)
-    : Runnable("ErrorEvent")
+  OSFileErrorEvent(nsMainThreadPtrHandle<nsINativeOSFileSuccessCallback>& aOnSuccess,
+                   nsMainThreadPtrHandle<nsINativeOSFileErrorCallback>& aOnError,
+                   already_AddRefed<AbstractResult>& aDiscardedResult,
+                   const nsACString& aOperation,
+                   int32_t aOSError)
+    : Runnable("OSFileErrorEvent")
     , mOnSuccess(aOnSuccess)
     , mOnError(aOnError)
     , mDiscardedResult(aDiscardedResult)
     , mOSError(aOSError)
     , mOperation(aOperation)
   {
     MOZ_ASSERT(!NS_IsMainThread());
     }
@@ -561,39 +561,40 @@ public:
 
   /**
    * Fail, asynchronously.
    */
   void Fail(const nsACString& aOperation,
             already_AddRefed<AbstractResult>&& aDiscardedResult,
             int32_t aOSError = 0) {
     Resolve();
-    RefPtr<ErrorEvent> event = new ErrorEvent(mOnSuccess,
-                                                mOnError,
-                                                aDiscardedResult,
-                                                aOperation,
-                                                aOSError);
+
+    RefPtr<OSFileErrorEvent> event = new OSFileErrorEvent(mOnSuccess,
+                                                          mOnError,
+                                                          aDiscardedResult,
+                                                          aOperation,
+                                                          aOSError);
     nsresult rv = NS_DispatchToMainThread(event);
     if (NS_FAILED(rv)) {
       // Last ditch attempt to release on the main thread - some of
       // the members of event are not thread-safe, so letting the
       // pointer go out of scope would cause a crash.
-      NS_ReleaseOnMainThreadSystemGroup("AbstractDoEvent::ErrorEvent",
+      NS_ReleaseOnMainThreadSystemGroup("AbstractDoEvent::OSFileErrorEvent",
                                         event.forget());
     }
   }
 
   /**
    * Succeed, asynchronously.
    */
   void Succeed(already_AddRefed<nsINativeOSFileResult>&& aResult) {
     Resolve();
     RefPtr<SuccessEvent> event = new SuccessEvent(mOnSuccess,
-                                                    mOnError,
-                                                    aResult);
+                                                  mOnError,
+                                                  aResult);
     nsresult rv = NS_DispatchToMainThread(event);
     if (NS_FAILED(rv)) {
       // Last ditch attempt to release on the main thread - some of
       // the members of event are not thread-safe, so letting the
       // pointer go out of scope would cause a crash.
       NS_ReleaseOnMainThreadSystemGroup("AbstractDoEvent::SuccessEvent",
                                         event.forget());
     }