Bug 1159209: Remove template parameters from |SocketIODeleteInstanceRunnable|, r=kmachulis
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 29 Apr 2015 11:19:28 +0200
changeset 271512 a2fe03686c0d53e76f44647b06500b068f999e56
parent 271511 65cd149078f9db420a8cb36c136524a97645b5a7
child 271513 3d372dd3a14486cfaf163a0b2bc222614b30b7c2
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmachulis
bugs1159209
milestone40.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 1159209: Remove template parameters from |SocketIODeleteInstanceRunnable|, r=kmachulis This patch removes the template parameters from |SocketIODeleteInstanceRunnable| and moves its methods into the C++ source file. All users have been adapted.
ipc/unixsocket/ListenSocket.cpp
ipc/unixsocket/SocketBase.cpp
ipc/unixsocket/SocketBase.h
--- a/ipc/unixsocket/ListenSocket.cpp
+++ b/ipc/unixsocket/ListenSocket.cpp
@@ -15,17 +15,17 @@
 namespace mozilla {
 namespace ipc {
 
 //
 // ListenSocketIO
 //
 
 class ListenSocketIO final : public UnixSocketWatcher
-                           , protected SocketIOBase
+                           , public SocketIOBase
 {
 public:
   class ListenTask;
 
   ListenSocketIO(MessageLoop* mIOLoop,
                  ListenSocket* aListenSocket,
                  UnixSocketConnector* aConnector,
                  const nsACString& aAddress);
--- a/ipc/unixsocket/SocketBase.cpp
+++ b/ipc/unixsocket/SocketBase.cpp
@@ -340,10 +340,27 @@ SocketIORequestClosingRunnable::Run()
   SocketBase* socketBase = io->GetSocketBase();
   MOZ_ASSERT(socketBase);
 
   socketBase->CloseSocket();
 
   return NS_OK;
 }
 
+//
+// SocketIODeleteInstanceRunnable
+//
+
+SocketIODeleteInstanceRunnable::SocketIODeleteInstanceRunnable(
+  SocketIOBase* aIO)
+  : mIO(aIO)
+{ }
+
+NS_METHOD
+SocketIODeleteInstanceRunnable::Run()
+{
+  mIO = nullptr; // delete instance
+
+  return NS_OK;
+}
+
 }
 }
--- a/ipc/unixsocket/SocketBase.h
+++ b/ipc/unixsocket/SocketBase.h
@@ -402,35 +402,28 @@ class SocketIORequestClosingRunnable fin
   : public SocketIORunnable<SocketIOBase>
 {
 public:
   SocketIORequestClosingRunnable(SocketIOBase* aIO);
 
   NS_IMETHOD Run() override;
 };
 
-/* |SocketIODeleteInstanceRunnable| deletes an object on the main thread.
+/**
+ * |SocketIODeleteInstanceRunnable| deletes an object on the main thread.
  */
-template<class T>
 class SocketIODeleteInstanceRunnable final : public nsRunnable
 {
 public:
-  SocketIODeleteInstanceRunnable(T* aInstance)
-  : mInstance(aInstance)
-  { }
+  SocketIODeleteInstanceRunnable(SocketIOBase* aIO);
 
-  NS_IMETHOD Run() override
-  {
-    mInstance = nullptr; // delete instance
-
-    return NS_OK;
-  }
+  NS_IMETHOD Run() override;
 
 private:
-  nsAutoPtr<T> mInstance;
+  nsAutoPtr<SocketIOBase> mIO;
 };
 
 //
 // Socket I/O tasks
 //
 
 /* |SocketIOTask| holds a reference to a Socket I/O object. It's
  * supposed to run on the I/O thread.
@@ -487,18 +480,16 @@ public:
 
     // At this point, there should be no new events on the I/O thread
     // after this one with the possible exception of an accept task,
     // which ShutdownOnIOThread will cancel for us. We are now fully
     // shut down, so we can send a message to the main thread to delete
     // |io| safely knowing that it's not reference any longer.
     io->ShutdownOnIOThread();
 
-    nsRefPtr<nsRunnable> r = new SocketIODeleteInstanceRunnable<Tio>(io);
-    nsresult rv = NS_DispatchToMainThread(r);
-    NS_ENSURE_SUCCESS_VOID(rv);
+    NS_DispatchToMainThread(new SocketIODeleteInstanceRunnable(io));
   }
 };
 
 }
 }
 
 #endif