tor-browser

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

GPUChild.h (5344B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 #ifndef _include_mozilla_gfx_ipc_GPUChild_h_
      7 #define _include_mozilla_gfx_ipc_GPUChild_h_
      8 
      9 #include "mozilla/RefPtr.h"
     10 #include "mozilla/UniquePtr.h"
     11 #include "mozilla/ipc/CrashReporterHelper.h"
     12 #include "mozilla/gfx/PGPUChild.h"
     13 #include "mozilla/gfx/gfxVarReceiver.h"
     14 
     15 namespace mozilla {
     16 
     17 namespace dom {
     18 class MemoryReportRequestHost;
     19 }  // namespace dom
     20 namespace gfx {
     21 
     22 class GPUProcessHost;
     23 
     24 class GPUChild final : public mozilla::ipc::CrashReporterHelper<GPUChild>,
     25                       public PGPUChild,
     26                       public gfxVarReceiver {
     27  typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
     28 
     29 public:
     30  static constexpr GeckoProcessType PROCESS_TYPE = GeckoProcessType_GPU;
     31 
     32  NS_INLINE_DECL_REFCOUNTING(GPUChild, final)
     33 
     34  explicit GPUChild(GPUProcessHost* aHost);
     35 
     36  using InitPromiseType = MozPromise<Ok, Ok, true>;
     37  RefPtr<InitPromiseType> Init();
     38 
     39  bool IsGPUReady() const { return mGPUReady; }
     40 
     41  bool EnsureGPUReady(bool aForceSync = false);
     42 
     43  // Notifies that an unexpected GPU process shutdown has been noticed by a
     44  // different IPDL actor, and the GPU process is being torn down as a result.
     45  // ActorDestroy may receive either NormalShutdown or AbnormalShutdown as a
     46  // reason, depending on timings, but either way we treat the shutdown as
     47  // abnormal.
     48  void OnUnexpectedShutdown();
     49 
     50  // Generates a minidump for the GPU process paired with one for the main
     51  // process. Called prior to force-killing the process.
     52  void GeneratePairedMinidump();
     53 
     54  // Deletes a minidump created with GeneratePairedMinidump(). Should be called
     55  // if killing the process fails after generating the minidump.
     56  void DeletePairedMinidump();
     57 
     58  // gfxVarReceiver overrides.
     59  void OnVarChanged(const nsTArray<GfxVarUpdate>& aVar) override;
     60 
     61  // PGPUChild overrides.
     62  mozilla::ipc::IPCResult RecvDeclareStable();
     63  mozilla::ipc::IPCResult RecvReportCheckerboard(const uint32_t& aSeverity,
     64                                                 const nsCString& aLog);
     65  mozilla::ipc::IPCResult RecvCreateVRProcess();
     66  mozilla::ipc::IPCResult RecvShutdownVRProcess();
     67 
     68  mozilla::ipc::IPCResult RecvAccumulateChildHistograms(
     69      nsTArray<HistogramAccumulation>&& aAccumulations);
     70  mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistograms(
     71      nsTArray<KeyedHistogramAccumulation>&& aAccumulations);
     72  mozilla::ipc::IPCResult RecvUpdateChildScalars(
     73      nsTArray<ScalarAction>&& aScalarActions);
     74  mozilla::ipc::IPCResult RecvUpdateChildKeyedScalars(
     75      nsTArray<KeyedScalarAction>&& aScalarActions);
     76  mozilla::ipc::IPCResult RecvRecordChildEvents(
     77      nsTArray<ChildEventData>&& events);
     78  mozilla::ipc::IPCResult RecvRecordDiscardedData(
     79      const DiscardedData& aDiscardedData);
     80 
     81  void ActorDestroy(ActorDestroyReason aWhy) override;
     82  mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError);
     83  mozilla::ipc::IPCResult RecvNotifyUiObservers(const nsCString& aTopic);
     84  mozilla::ipc::IPCResult RecvNotifyDeviceReset(
     85      const GPUDeviceData& aData, const DeviceResetReason& aReason,
     86      const DeviceResetDetectPlace& aPlace);
     87  mozilla::ipc::IPCResult RecvNotifyOverlayInfo(const OverlayInfo aInfo);
     88  mozilla::ipc::IPCResult RecvNotifySwapChainInfo(const SwapChainInfo aInfo);
     89  mozilla::ipc::IPCResult RecvNotifyDisableRemoteCanvas();
     90  mozilla::ipc::IPCResult RecvFlushMemory(const nsString& aReason);
     91  mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport);
     92  mozilla::ipc::IPCResult RecvUpdateFeature(const Feature& aFeature,
     93                                            const FeatureFailure& aChange);
     94  mozilla::ipc::IPCResult RecvUsedFallback(const Fallback& aFallback,
     95                                           const nsCString& aMessage);
     96  mozilla::ipc::IPCResult RecvBHRThreadHang(const HangDetails& aDetails);
     97  mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported(
     98      const media::MediaCodecsSupported& aSupported);
     99  mozilla::ipc::IPCResult RecvFOGData(ByteBuf&& aBuf);
    100 
    101  bool SendRequestMemoryReport(const uint32_t& aGeneration,
    102                               const bool& aAnonymize,
    103                               const bool& aMinimizeMemoryUsage,
    104                               const Maybe<ipc::FileDescriptor>& aDMDFile);
    105 
    106  static void Destroy(RefPtr<GPUChild>&& aChild);
    107 
    108 private:
    109  virtual ~GPUChild();
    110 
    111  void OnInitComplete(const GPUDeviceData& aData);
    112 
    113  GPUProcessHost* mHost;
    114  UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;
    115  bool mGPUReady;
    116  bool mUnexpectedShutdown = false;
    117  // Whether a paired minidump has already been generated, meaning we do not
    118  // need to create a crash report in ActorDestroy().
    119  bool mCreatedPairedMinidumps = false;
    120  // The number of paired minidumps that have been created during this session.
    121  // Used to ensure we do not accumulate a large number of minidumps on disk
    122  // that may never be submitted.
    123  int mNumPairedMinidumpsCreated = 0;
    124 };
    125 
    126 }  // namespace gfx
    127 }  // namespace mozilla
    128 
    129 #endif  // _include_mozilla_gfx_ipc_GPUChild_h_