2012-05-31 09:33:35 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-10-07 00:46:41 +00:00
|
|
|
|
|
|
|
#include "PSMRunnable.h"
|
|
|
|
|
|
|
|
namespace mozilla { namespace psm {
|
|
|
|
|
|
|
|
SyncRunnableBase::SyncRunnableBase()
|
|
|
|
: monitor("SyncRunnableBase::monitor")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
SyncRunnableBase::DispatchToMainThreadAndWait()
|
|
|
|
{
|
2012-01-31 16:04:53 +00:00
|
|
|
nsresult rv;
|
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
RunOnTargetThread();
|
|
|
|
rv = NS_OK;
|
|
|
|
} else {
|
|
|
|
mozilla::MonitorAutoLock lock(monitor);
|
|
|
|
rv = NS_DispatchToMainThread(this);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
lock.Wait();
|
|
|
|
}
|
2011-10-07 00:46:41 +00:00
|
|
|
}
|
2012-01-31 16:04:53 +00:00
|
|
|
|
2011-10-07 00:46:41 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
SyncRunnableBase::Run()
|
|
|
|
{
|
|
|
|
RunOnTargetThread();
|
|
|
|
mozilla::MonitorAutoLock(monitor).Notify();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-03 04:14:33 +00:00
|
|
|
nsresult
|
|
|
|
NotifyObserverRunnable::Run()
|
|
|
|
{
|
|
|
|
mObserver->Observe(nsnull, mTopic, nsnull);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-07 00:46:41 +00:00
|
|
|
} } // namespace mozilla::psm
|