mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1229235 - Make RedirectChannelRegistrar thread-safe. r=jduell
This commit is contained in:
parent
86899e610d
commit
5a7f903046
@ -13,6 +13,7 @@ RedirectChannelRegistrar::RedirectChannelRegistrar()
|
||||
: mRealChannels(32)
|
||||
, mParentChannels(32)
|
||||
, mId(1)
|
||||
, mLock("RedirectChannelRegistrar")
|
||||
{
|
||||
}
|
||||
|
||||
@ -20,6 +21,8 @@ NS_IMETHODIMP
|
||||
RedirectChannelRegistrar::RegisterChannel(nsIChannel *channel,
|
||||
uint32_t *_retval)
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
mRealChannels.Put(mId, channel);
|
||||
*_retval = mId;
|
||||
|
||||
@ -36,6 +39,8 @@ NS_IMETHODIMP
|
||||
RedirectChannelRegistrar::GetRegisteredChannel(uint32_t id,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
if (!mRealChannels.Get(id, _retval))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
@ -47,6 +52,8 @@ RedirectChannelRegistrar::LinkChannels(uint32_t id,
|
||||
nsIParentChannel *channel,
|
||||
nsIChannel** _retval)
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
if (!mRealChannels.Get(id, _retval))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
@ -58,6 +65,8 @@ NS_IMETHODIMP
|
||||
RedirectChannelRegistrar::GetParentChannel(uint32_t id,
|
||||
nsIParentChannel **_retval)
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
if (!mParentChannels.Get(id, _retval))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
@ -67,6 +76,8 @@ RedirectChannelRegistrar::GetParentChannel(uint32_t id,
|
||||
NS_IMETHODIMP
|
||||
RedirectChannelRegistrar::DeregisterChannels(uint32_t id)
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
mRealChannels.Remove(id);
|
||||
mParentChannels.Remove(id);
|
||||
return NS_OK;
|
||||
|
@ -34,6 +34,7 @@ protected:
|
||||
ChannelHashtable mRealChannels;
|
||||
ParentChannelHashtable mParentChannels;
|
||||
uint32_t mId;
|
||||
Mutex mLock;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
Loading…
Reference in New Issue
Block a user