Bug 1005375 - Add an API that allows CryptoTasks to be created without being dispatched

This commit is contained in:
Richard Barnes 2014-05-03 08:50:00 +02:00
parent 8fabc5d038
commit 5f5fc30c16

View File

@ -29,6 +29,17 @@ namespace mozilla {
* except CalculateResult might be skipped if NSS is shut down before it can
* be called; in that case ReleaseNSSResources will be called and then
* CallCallback will be called with an error code.
*
* That sequence of events is what happens if you call Dispatch. If for
* some reason, you decide not to run the task (e.g., due to an error in the
* constructor), you may call Skip, in which case the task is cleaned up and
* not run. In that case, only ReleaseNSSResources is called. (So a
* subclass must be prepared for ReleaseNSSResources to be run without
* CalculateResult having been called first.)
*
* Once a CryptoTask is created, the calling code must call either
* Dispatch or Skip.
*
*/
class CryptoTask : public nsRunnable,
public nsNSSShutDownObject
@ -48,6 +59,11 @@ public:
return rv;
}
void Skip()
{
virtualDestroyNSSReference();
}
protected:
CryptoTask()
: mRv(NS_ERROR_NOT_INITIALIZED),