tor-browser

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

GMPPlatform.h (2061B)


      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
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef GMPPlatform_h_
      7 #define GMPPlatform_h_
      8 
      9 #include <functional>
     10 
     11 #include "gmp-platform.h"
     12 #include "mozilla/RefPtr.h"
     13 #include "mozilla/gmp/PGMPChild.h"
     14 
     15 namespace mozilla {
     16 #ifdef XP_WIN
     17 struct ModulePaths;
     18 #endif
     19 
     20 namespace ipc {
     21 class ByteBuf;
     22 }  // namespace ipc
     23 
     24 namespace gmp {
     25 
     26 class GMPChild;
     27 
     28 void InitPlatformAPI(GMPPlatformAPI& aPlatformAPI, GMPChild* aChild);
     29 void ShutdownPlatformAPI();
     30 
     31 GMPErr RunOnMainThread(GMPTask* aTask);
     32 
     33 GMPTask* NewGMPTask(std::function<void()>&& aFunction);
     34 
     35 GMPErr SetTimerOnMainThread(GMPTask* aTask, int64_t aTimeoutMS);
     36 
     37 /**
     38 * This is intended to be used by encoders/decoders that will make a GMP call
     39 * that is a synchronous post to the GMP worker thread. Because the GMP worker
     40 * threads can synchronously callback to the main thread, this has the potential
     41 * for a deadlock. If the encoder/decoder tracks any outstanding requests that
     42 * will result in a synchronous callback to the main thread, we can simply spin
     43 * the event loop on those callbacks until they are completed. Then we can
     44 * safefully make our own synchronous call to the GMP worker thread without fear
     45 * of a deadlock.
     46 *
     47 * Note that each encoder/decoder has its own worker thread, so assuming we
     48 * drain the synchronous events for that specific encoder/decoder, we know there
     49 * are no more forthcoming to cause us to deadlock.
     50 */
     51 using SpinPendingPredicate = std::function<bool()>;
     52 bool SpinPendingGmpEventsUntil(const SpinPendingPredicate& aPred,
     53                               uint32_t aTimeoutMs);
     54 
     55 void SendFOGData(ipc::ByteBuf&& buf);
     56 
     57 #ifdef XP_WIN
     58 RefPtr<PGMPChild::GetModulesTrustPromise> SendGetModulesTrust(
     59    ModulePaths&& aModules, bool aRunNormal);
     60 #endif
     61 
     62 }  // namespace gmp
     63 }  // namespace mozilla
     64 
     65 #endif  // GMPPlatform_h_