Bug 1639837 - make CloseFileRunnable use mozilla::Runnable; r=jld
authorNathan Froyd <froydnj@mozilla.com>
Fri, 22 May 2020 22:36:59 +0000
changeset 531801 1b74ac33bb2e4dbf2cd2d0926262a50b2a8720c0
parent 531800 9a2f741cef6ae4ae568a17fd3ffe52599f0a574f
child 531802 59cfc02045fd5adde7f37ddd1872722ca324cd21
push id116881
push usernfroyd@mozilla.com
push dateSat, 23 May 2020 16:48:14 +0000
treeherderautoland@1b74ac33bb2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1639837
milestone78.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 1639837 - make CloseFileRunnable use mozilla::Runnable; r=jld Differential Revision: https://phabricator.services.mozilla.com/D76300
ipc/glue/FileDescriptorUtils.cpp
ipc/glue/FileDescriptorUtils.h
--- a/ipc/glue/FileDescriptorUtils.cpp
+++ b/ipc/glue/FileDescriptorUtils.cpp
@@ -7,47 +7,43 @@
 #include "FileDescriptorUtils.h"
 
 #include "nsIEventTarget.h"
 
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
-#include "nsThreadUtils.h"
 #include "prio.h"
 #include "private/pprio.h"
 
 #include <errno.h>
 #ifdef XP_WIN
 #  include <io.h>
 #else
 #  include <unistd.h>
 #endif
 
 using mozilla::ipc::CloseFileRunnable;
 
-#ifdef DEBUG
-
 CloseFileRunnable::CloseFileRunnable(const FileDescriptor& aFileDescriptor)
-    : mFileDescriptor(aFileDescriptor) {
+    : Runnable("CloseFileRunnable"),
+      mFileDescriptor(aFileDescriptor) {
   MOZ_ASSERT(aFileDescriptor.IsValid());
 }
 
-#endif  // DEBUG
-
 CloseFileRunnable::~CloseFileRunnable() {
   if (mFileDescriptor.IsValid()) {
     // It's probably safer to take the main thread IO hit here rather than leak
     // the file descriptor.
     CloseFile();
   }
 }
 
-NS_IMPL_ISUPPORTS(CloseFileRunnable, nsIRunnable)
+NS_IMPL_ISUPPORTS_INHERITED0(CloseFileRunnable, Runnable)
 
 void CloseFileRunnable::Dispatch() {
   nsCOMPtr<nsIEventTarget> eventTarget =
       do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
   NS_ENSURE_TRUE_VOID(eventTarget);
 
   nsresult rv = eventTarget->Dispatch(this, NS_DISPATCH_NORMAL);
   NS_ENSURE_SUCCESS_VOID(rv);
--- a/ipc/glue/FileDescriptorUtils.h
+++ b/ipc/glue/FileDescriptorUtils.h
@@ -4,40 +4,34 @@
  * 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_ipc_FileDescriptorUtils_h
 #define mozilla_ipc_FileDescriptorUtils_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ipc/FileDescriptor.h"
-#include "nsIRunnable.h"
+#include "nsThreadUtils.h"
 #include <stdio.h>
 
 namespace mozilla {
 namespace ipc {
 
 // When Dispatch() is called (from main thread) this class arranges to close the
 // provided FileDescriptor on one of the socket transport service threads (to
 // avoid main thread I/O).
-class CloseFileRunnable final : public nsIRunnable {
+class CloseFileRunnable final : public Runnable {
   typedef mozilla::ipc::FileDescriptor FileDescriptor;
 
   FileDescriptor mFileDescriptor;
 
  public:
-  explicit CloseFileRunnable(const FileDescriptor& aFileDescriptor)
-#ifdef DEBUG
-      ;
-#else
-      : mFileDescriptor(aFileDescriptor) {
-  }
-#endif
+  explicit CloseFileRunnable(const FileDescriptor& aFileDescriptor);
 
-  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIRUNNABLE
 
   void Dispatch();
 
  private:
   ~CloseFileRunnable();
 
   void CloseFile();