Bug 1028588 - Fix dangerous public destructors in media/webrtc/ - r=rjesup

This commit is contained in:
Benoit Jacob 2014-06-26 09:31:20 -04:00
Родитель 7e504be6f6
Коммит 2088c4eef4
5 изменённых файлов: 26 добавлений и 18 удалений

Просмотреть файл

@ -33,7 +33,6 @@ public:
}; };
MediaStreamList(sipcc::PeerConnectionImpl* peerConnection, StreamType type); MediaStreamList(sipcc::PeerConnectionImpl* peerConnection, StreamType type);
virtual ~MediaStreamList();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamList) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamList)
@ -46,6 +45,8 @@ public:
uint32_t Length(); uint32_t Length();
private: private:
virtual ~MediaStreamList();
nsRefPtr<sipcc::PeerConnectionImpl> mPeerConnection; nsRefPtr<sipcc::PeerConnectionImpl> mPeerConnection;
StreamType mType; StreamType mType;
}; };

Просмотреть файл

@ -131,14 +131,6 @@ public:
(void) rv; (void) rv;
} }
virtual ~PeerConnectionCtxShutdown()
{
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (observerService)
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
NS_IMETHODIMP Observe(nsISupports* aSubject, const char* aTopic, NS_IMETHODIMP Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) { const char16_t* aData) {
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) { if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
@ -160,6 +152,15 @@ public:
} }
return NS_OK; return NS_OK;
} }
private:
virtual ~PeerConnectionCtxShutdown()
{
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (observerService)
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
}; };
NS_IMPL_ISUPPORTS(PeerConnectionCtxShutdown, nsIObserver); NS_IMPL_ISUPPORTS(PeerConnectionCtxShutdown, nsIObserver);

Просмотреть файл

@ -211,7 +211,6 @@ class PeerConnectionImpl MOZ_FINAL : public nsISupports,
public: public:
PeerConnectionImpl(const mozilla::dom::GlobalObject* aGlobal = nullptr); PeerConnectionImpl(const mozilla::dom::GlobalObject* aGlobal = nullptr);
virtual ~PeerConnectionImpl();
enum Error { enum Error {
kNoError = 0, kNoError = 0,
@ -566,6 +565,7 @@ public:
#endif #endif
private: private:
virtual ~PeerConnectionImpl();
PeerConnectionImpl(const PeerConnectionImpl&rhs); PeerConnectionImpl(const PeerConnectionImpl&rhs);
PeerConnectionImpl& operator=(PeerConnectionImpl); PeerConnectionImpl& operator=(PeerConnectionImpl);
NS_IMETHODIMP Initialize(PeerConnectionObserver& aObserver, NS_IMETHODIMP Initialize(PeerConnectionObserver& aObserver,

Просмотреть файл

@ -105,7 +105,6 @@ class Fake_MediaPeriodic : public nsITimerCallback {
public: public:
Fake_MediaPeriodic(Fake_MediaStream *aStream) : mStream(aStream), Fake_MediaPeriodic(Fake_MediaStream *aStream) : mStream(aStream),
mCount(0) {} mCount(0) {}
virtual ~Fake_MediaPeriodic() {}
void Detach() { void Detach() {
mStream = nullptr; mStream = nullptr;
} }
@ -116,6 +115,8 @@ Fake_MediaPeriodic(Fake_MediaStream *aStream) : mStream(aStream),
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
protected: protected:
virtual ~Fake_MediaPeriodic() {}
Fake_MediaStream *mStream; Fake_MediaStream *mStream;
int mCount; int mCount;
}; };
@ -211,16 +212,17 @@ class Fake_SourceMediaStream : public Fake_MediaStream {
class Fake_DOMMediaStream : public nsIDOMMediaStream class Fake_DOMMediaStream : public nsIDOMMediaStream
{ {
public: protected:
Fake_DOMMediaStream() : mMediaStream(new Fake_MediaStream()) {}
Fake_DOMMediaStream(Fake_MediaStream *stream) :
mMediaStream(stream) {}
virtual ~Fake_DOMMediaStream() { virtual ~Fake_DOMMediaStream() {
// Note: memory leak // Note: memory leak
mMediaStream->Stop(); mMediaStream->Stop();
} }
public:
Fake_DOMMediaStream() : mMediaStream(new Fake_MediaStream()) {}
Fake_DOMMediaStream(Fake_MediaStream *stream) :
mMediaStream(stream) {}
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
static already_AddRefed<Fake_DOMMediaStream> static already_AddRefed<Fake_DOMMediaStream>

Просмотреть файл

@ -240,6 +240,9 @@ enum mediaPipelineFlags
class TestObserver : public AFakePCObserver class TestObserver : public AFakePCObserver
{ {
protected:
~TestObserver() {}
public: public:
TestObserver(sipcc::PeerConnectionImpl *peerConnection, TestObserver(sipcc::PeerConnectionImpl *peerConnection,
const std::string &aName) : const std::string &aName) :
@ -687,13 +690,14 @@ class ParsedSDP {
// into it happen on the main thread. // into it happen on the main thread.
class PCDispatchWrapper : public nsSupportsWeakReference class PCDispatchWrapper : public nsSupportsWeakReference
{ {
protected:
virtual ~PCDispatchWrapper() {}
public: public:
PCDispatchWrapper(sipcc::PeerConnectionImpl *peerConnection) { PCDispatchWrapper(sipcc::PeerConnectionImpl *peerConnection) {
pc_ = peerConnection; pc_ = peerConnection;
} }
virtual ~PCDispatchWrapper() {}
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
sipcc::PeerConnectionImpl *pcImpl() const { sipcc::PeerConnectionImpl *pcImpl() const {