security/manager/ssl/src/PSMRunnable.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial