mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 675702: Call nsICertVerificationListener on the main thread, rev. 1, r=bsmith, r=mayhemer
This commit is contained in:
parent
a42b4e1ae9
commit
dee00f8b91
@ -134,9 +134,7 @@ function setWindowName()
|
||||
|
||||
if (cert instanceof nsIX509Cert3)
|
||||
{
|
||||
cert.requestUsagesArrayAsync(
|
||||
getProxyOnUIThread(new listener(),
|
||||
Components.interfaces.nsICertVerificationListener));
|
||||
cert.requestUsagesArrayAsync(new listener());
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,20 +314,6 @@ function updateCertDump()
|
||||
displaySelected();
|
||||
}
|
||||
|
||||
function getProxyOnUIThread(aObject, aInterface) {
|
||||
var mainThread = Components.
|
||||
classes["@mozilla.org/thread-manager;1"].
|
||||
getService().mainThread;
|
||||
|
||||
var proxyMgr = Components.
|
||||
classes["@mozilla.org/xpcomproxy;1"].
|
||||
getService(Components.interfaces.nsIProxyObjectManager);
|
||||
|
||||
return proxyMgr.getProxyForObject(mainThread,
|
||||
aInterface, aObject, 5);
|
||||
// 5 == NS_PROXY_ALWAYS | NS_PROXY_SYNC
|
||||
}
|
||||
|
||||
function getCurrentCert()
|
||||
{
|
||||
var realIndex;
|
||||
|
@ -57,7 +57,7 @@ interface nsIX509Cert3 : nsIX509Cert2 {
|
||||
* Async version of nsIX509Cert::getUsagesArray()
|
||||
*
|
||||
* Will not block, will request results asynchronously,
|
||||
* availability of results will be notified.
|
||||
* availability of results will be notified on the main thread.
|
||||
*/
|
||||
void requestUsagesArrayAsync(in nsICertVerificationListener cvl);
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsMemory.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCertVerificationThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -45,6 +46,30 @@ nsCertVerificationThread *nsCertVerificationThread::verification_thread_singleto
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCertVerificationResult, nsICertVerificationResult)
|
||||
|
||||
namespace {
|
||||
class DispatchCertVerificationResult : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DispatchCertVerificationResult(nsICertVerificationListener* aListener,
|
||||
nsIX509Cert3* aCert,
|
||||
nsICertVerificationResult* aResult)
|
||||
: mListener(aListener)
|
||||
, mCert(aCert)
|
||||
, mResult(aResult)
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
mListener->Notify(mCert, mResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsICertVerificationListener> mListener;
|
||||
nsCOMPtr<nsIX509Cert3> mCert;
|
||||
nsCOMPtr<nsICertVerificationResult> mResult;
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
void nsCertVerificationJob::Run()
|
||||
{
|
||||
if (!mListener || !mCert)
|
||||
@ -74,7 +99,8 @@ void nsCertVerificationJob::Run()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIX509Cert3> c3 = do_QueryInterface(mCert);
|
||||
mListener->Notify(c3, ires);
|
||||
nsCOMPtr<nsIRunnable> r = new DispatchCertVerificationResult(mListener, c3, ires);
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
|
||||
void nsSMimeVerificationJob::Run()
|
||||
|
Loading…
Reference in New Issue
Block a user