1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/manager/ssl/src/PSMRunnable.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 +* License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "PSMRunnable.h" 1.9 + 1.10 +namespace mozilla { namespace psm { 1.11 + 1.12 +SyncRunnableBase::SyncRunnableBase() 1.13 + : monitor("SyncRunnableBase::monitor") 1.14 +{ 1.15 +} 1.16 + 1.17 +nsresult 1.18 +SyncRunnableBase::DispatchToMainThreadAndWait() 1.19 +{ 1.20 + nsresult rv; 1.21 + if (NS_IsMainThread()) { 1.22 + RunOnTargetThread(); 1.23 + rv = NS_OK; 1.24 + } else { 1.25 + mozilla::MonitorAutoLock lock(monitor); 1.26 + rv = NS_DispatchToMainThread(this); 1.27 + if (NS_SUCCEEDED(rv)) { 1.28 + lock.Wait(); 1.29 + } 1.30 + } 1.31 + 1.32 + return rv; 1.33 +} 1.34 + 1.35 +NS_IMETHODIMP 1.36 +SyncRunnableBase::Run() 1.37 +{ 1.38 + RunOnTargetThread(); 1.39 + mozilla::MonitorAutoLock(monitor).Notify(); 1.40 + return NS_OK; 1.41 +} 1.42 + 1.43 +nsresult 1.44 +NotifyObserverRunnable::Run() 1.45 +{ 1.46 + mObserver->Observe(nullptr, mTopic, nullptr); 1.47 + return NS_OK; 1.48 +} 1.49 + 1.50 +} } // namespace mozilla::psm