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