michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "PSMRunnable.h" michael@0: michael@0: namespace mozilla { namespace psm { michael@0: michael@0: SyncRunnableBase::SyncRunnableBase() michael@0: : monitor("SyncRunnableBase::monitor") michael@0: { michael@0: } michael@0: michael@0: nsresult michael@0: SyncRunnableBase::DispatchToMainThreadAndWait() michael@0: { michael@0: nsresult rv; michael@0: if (NS_IsMainThread()) { michael@0: RunOnTargetThread(); michael@0: rv = NS_OK; michael@0: } else { michael@0: mozilla::MonitorAutoLock lock(monitor); michael@0: rv = NS_DispatchToMainThread(this); michael@0: if (NS_SUCCEEDED(rv)) { michael@0: lock.Wait(); michael@0: } michael@0: } michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: SyncRunnableBase::Run() michael@0: { michael@0: RunOnTargetThread(); michael@0: mozilla::MonitorAutoLock(monitor).Notify(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: NotifyObserverRunnable::Run() michael@0: { michael@0: mObserver->Observe(nullptr, mTopic, nullptr); michael@0: return NS_OK; michael@0: } michael@0: michael@0: } } // namespace mozilla::psm