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.
This commit is contained in:
Thomas Zimmermann 2015-04-29 11:19:28 +02:00
parent f1e1ede770
commit bc3ec66d73
3 changed files with 24 additions and 16 deletions

View File

@ -20,7 +20,7 @@ namespace ipc {
// //
class ListenSocketIO final : public UnixSocketWatcher class ListenSocketIO final : public UnixSocketWatcher
, protected SocketIOBase , public SocketIOBase
{ {
public: public:
class ListenTask; class ListenTask;

View File

@ -345,5 +345,22 @@ SocketIORequestClosingRunnable::Run()
return NS_OK; return NS_OK;
} }
//
// SocketIODeleteInstanceRunnable
//
SocketIODeleteInstanceRunnable::SocketIODeleteInstanceRunnable(
SocketIOBase* aIO)
: mIO(aIO)
{ }
NS_METHOD
SocketIODeleteInstanceRunnable::Run()
{
mIO = nullptr; // delete instance
return NS_OK;
}
} }
} }

View File

@ -407,25 +407,18 @@ public:
NS_IMETHOD Run() override; 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 class SocketIODeleteInstanceRunnable final : public nsRunnable
{ {
public: public:
SocketIODeleteInstanceRunnable(T* aInstance) SocketIODeleteInstanceRunnable(SocketIOBase* aIO);
: mInstance(aInstance)
{ }
NS_IMETHOD Run() override NS_IMETHOD Run() override;
{
mInstance = nullptr; // delete instance
return NS_OK;
}
private: private:
nsAutoPtr<T> mInstance; nsAutoPtr<SocketIOBase> mIO;
}; };
// //
@ -492,9 +485,7 @@ public:
// |io| safely knowing that it's not reference any longer. // |io| safely knowing that it's not reference any longer.
io->ShutdownOnIOThread(); io->ShutdownOnIOThread();
nsRefPtr<nsRunnable> r = new SocketIODeleteInstanceRunnable<Tio>(io); NS_DispatchToMainThread(new SocketIODeleteInstanceRunnable(io));
nsresult rv = NS_DispatchToMainThread(r);
NS_ENSURE_SUCCESS_VOID(rv);
} }
}; };