tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WebrtcTaskQueueWrapper.h (2633B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef DOM_MEDIA_WEBRTC_LIBWEBRTCGLUE_TASKQUEUEWRAPPER_H_
      7 #define DOM_MEDIA_WEBRTC_LIBWEBRTCGLUE_TASKQUEUEWRAPPER_H_
      8 
      9 #include "mozilla/AlreadyAddRefed.h"
     10 #include "mozilla/RefPtr.h"
     11 #include "mozilla/UniquePtr.h"
     12 #include "nsStringFwd.h"
     13 
     14 class nsIEventTarget;
     15 
     16 namespace webrtc {
     17 class TaskQueueBase;
     18 struct TaskQueueDeleter;
     19 class TaskQueueFactory;
     20 }  // namespace webrtc
     21 
     22 namespace mozilla {
     23 class TaskQueue;
     24 
     25 /**
     26 * Creates a libwebrtc task queue backed by a mozilla::TaskQueue.
     27 *
     28 * While in a task running on the returned task queue, both
     29 * webrtc::TaskQueueBase::Current() and mozilla::AbstractThread::GetCurrent()
     30 * will work as expected.
     31 *
     32 * Releasing the returned task queue will synchronously shut down the underlying
     33 * mozilla::TaskQueue. Execution will be blocked until the underlying task queue
     34 * has finished running any pending tasks. The returned task queue must not be
     35 * released while on itself, or a deadlock will occur.
     36 */
     37 std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter>
     38 CreateWebrtcTaskQueue(already_AddRefed<nsIEventTarget> aTarget,
     39                      const nsACString& aName, bool aSupportsTailDispatch);
     40 
     41 /**
     42 * Creates a mozilla task queue that also exposes a webrtc::TaskQueueBase.
     43 *
     44 * While in a task running on the returned task queue, both
     45 * webrtc::TaskQueueBase::Current() and mozilla::AbstractThread::GetCurrent()
     46 * will work as expected.
     47 *
     48 * webrtc::TaskQueueBase is not refcounted and the representation here is only
     49 * accessible through webrtc::TaskQueueBase::Current(). The returned task queue
     50 * controls the lifetime of the webrtc::TaskQueueBase instance, which will be
     51 * destroyed as the returned task queue finishes shutdown. The thread on which
     52 * it is destroyed is not guaranteed.
     53 *
     54 * Shutdown of the returned task queue is asynchronous, either through
     55 * BeginShutdown(), or through releasing all references to it. See
     56 * mozilla::TaskQueue.
     57 */
     58 RefPtr<TaskQueue> CreateWebrtcTaskQueueWrapper(
     59    already_AddRefed<nsIEventTarget> aTarget, const nsACString& aName,
     60    bool aSupportsTailDispatch);
     61 
     62 /**
     63 * Creates a libwebrtc task queue factory that returns webrtc::TaskQueueBase
     64 * instances backed by mozilla::TaskQueues. See CreateWebrtcTaskQueue above.
     65 */
     66 UniquePtr<webrtc::TaskQueueFactory> CreateWebrtcTaskQueueFactory();
     67 
     68 }  // namespace mozilla
     69 
     70 #endif