static const int SLP_STATE_FAILED = 6;
static const int SLP_STATE_CANCELLED = 7;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
_DownloadManagerImpl* _DownloadManagerImpl::__pInstance = null;
class _DownloadEventArg
break;
default:
+
break;
}
}
case SLP_STATE_PAUSED:
{
+ pthread_mutex_lock(&mutex);
if (pDMImpl->__pEvent)
{
_DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
pDMImpl->__pEvent->Fire(*pEventArg);
}
+ pthread_mutex_unlock(&mutex);
break;
}
case SLP_STATE_COMPLETED:
{
+ pthread_mutex_lock(&mutex);
if (pDMImpl->__pEvent)
{
_DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
pDMImpl->__pEvent->Fire(*pEventArg);
}
+ pthread_mutex_unlock(&mutex);
// Remove the resource from url_download
pDMImpl->DestroyResources(reqId);
case SLP_STATE_FAILED:
{
+ pthread_mutex_lock(&mutex);
if (pDMImpl->__pEvent)
{
_DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
pDMImpl->__pEvent->Fire(*pEventArg);
}
+ pthread_mutex_unlock(&mutex);
// Comment out due to resume the failed request
//pDMImpl->DestroyResources(reqId);
case SLP_STATE_CANCELLED:
{
+ pthread_mutex_lock(&mutex);
if (pDMImpl->__pEvent)
{
_DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
pDMImpl->__pEvent->Fire(*pEventArg);
}
+ pthread_mutex_unlock(&mutex);
// Remove the resource from url_download
pDMImpl->DestroyResources(reqId);
_DownloadManagerImpl* pDMImpl = (_DownloadManagerImpl*)data;
+ pthread_mutex_lock(&mutex);
if (data && pDMImpl->__pEvent)
{
_DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
pDMImpl->__pEvent->Fire(*pEventArg);
}
+ pthread_mutex_unlock(&mutex);
}
void
_DownloadManagerImpl::SetDownloadListener(IDownloadListener* pListener)
{
+ pthread_mutex_lock(&mutex);
+
if (pListener != null)
{
_DownloadEvent* pEvent = new (std::nothrow) _DownloadEvent();
__pEvent = null;
}
+
+ pthread_mutex_unlock(&mutex);
}
void