tor-browser

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

GMPCrashHelperHolder.h (2793B)


      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 GMPCrashHelperHolder_h_
      7 #define GMPCrashHelperHolder_h_
      8 
      9 #include "GMPCrashHelper.h"
     10 #include "mozilla/RefPtr.h"
     11 
     12 namespace mozilla {
     13 
     14 // Disconnecting the GMPCrashHelpers at the right time is hard. We need to
     15 // ensure that in the crashing case that we stay connected until the
     16 // "gmp-plugin-crashed" message is processed in the content process.
     17 //
     18 // We have two channels connecting to the GMP; PGMP which connects from
     19 // chrome to GMP process, and PGMPContent, which bridges between the content
     20 // and GMP process. If the GMP crashes both PGMP and PGMPContent receive
     21 // ActorDestroy messages and begin to shutdown at the same time.
     22 //
     23 // However the crash report mini dump must be generated in the chrome
     24 // process' ActorDestroy, before the "gmp-plugin-crashed" message can be sent
     25 // to the content process. We fire the "PluginCrashed" event when we handle
     26 // the "gmp-plugin-crashed" message in the content process, and we need the
     27 // crash helpers to do that.
     28 //
     29 // The PGMPContent's managed actors' ActorDestroy messages are the only shutdown
     30 // notification we get in the content process, but we can't disconnect the
     31 // crash handlers there in the crashing case, as ActorDestroy happens before
     32 // we've received the "gmp-plugin-crashed" message and had a chance for the
     33 // crash helpers to generate the window to dispatch PluginCrashed to initiate
     34 // the crash report submission notification box.
     35 //
     36 // So we need to ensure that in the content process, the GMPCrashHelpers stay
     37 // connected to the GMPService until after ActorDestroy messages are received
     38 // if there's an abnormal shutdown. In the case where the GMP doesn't crash,
     39 // we do actually want to disconnect GMPCrashHandlers in ActorDestroy, since
     40 // we don't have any other signal that a GMP actor is shutting down. If we don't
     41 // disconnect the crash helper there in the normal shutdown case, the helper
     42 // will stick around forever and leak.
     43 //
     44 // In the crashing case, the GMPCrashHelpers are deallocated when the crash
     45 // report is processed in GeckoMediaPluginService::RunPluginCrashCallbacks().
     46 //
     47 // It's a bit yuck that we have to have two paths for disconnecting the crash
     48 // helpers, but there aren't really any better options.
     49 class GMPCrashHelperHolder {
     50 public:
     51  void SetCrashHelper(GMPCrashHelper* aHelper);
     52 
     53  GMPCrashHelper* GetCrashHelper();
     54 
     55  void MaybeDisconnect(bool aAbnormalShutdown);
     56 
     57 private:
     58  RefPtr<GMPCrashHelper> mCrashHelper;
     59 };
     60 
     61 }  // namespace mozilla
     62 
     63 #endif  // GMPCrashHelperHolder_h_