security/manager/ssl/src/PSMRunnable.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef PSMRunnable_h
michael@0 6 #define PSMRunnable_h
michael@0 7
michael@0 8 #include "mozilla/Monitor.h"
michael@0 9 #include "nsThreadUtils.h"
michael@0 10 #include "nsIObserver.h"
michael@0 11 #include "nsProxyRelease.h"
michael@0 12
michael@0 13 namespace mozilla { namespace psm {
michael@0 14
michael@0 15 // Wait for the event to run on the target thread without spinning the event
michael@0 16 // loop on the calling thread. (Dispatching events to a thread using
michael@0 17 // NS_DISPATCH_SYNC would cause the event loop on the calling thread to spin.)
michael@0 18 class SyncRunnableBase : public nsRunnable
michael@0 19 {
michael@0 20 public:
michael@0 21 NS_DECL_NSIRUNNABLE
michael@0 22 nsresult DispatchToMainThreadAndWait();
michael@0 23 protected:
michael@0 24 SyncRunnableBase();
michael@0 25 virtual void RunOnTargetThread() = 0;
michael@0 26 private:
michael@0 27 mozilla::Monitor monitor;
michael@0 28 };
michael@0 29
michael@0 30 class NotifyObserverRunnable : public nsRunnable
michael@0 31 {
michael@0 32 public:
michael@0 33 NotifyObserverRunnable(nsIObserver * observer,
michael@0 34 const char * topicStringLiteral)
michael@0 35 : mObserver(), mTopic(topicStringLiteral) {
michael@0 36 mObserver = new nsMainThreadPtrHolder<nsIObserver>(observer);
michael@0 37 }
michael@0 38 NS_DECL_NSIRUNNABLE
michael@0 39 private:
michael@0 40 nsMainThreadPtrHandle<nsIObserver> mObserver;
michael@0 41 const char * const mTopic;
michael@0 42 };
michael@0 43
michael@0 44 } } // namespace mozilla::psm
michael@0 45
michael@0 46 #endif

mercurial