BackgroundVideoDecodingPermissionObserver.h (1439B)
1 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 #if !defined(BackgroundVideoDecodingPermissionObserver_h_) 7 # define BackgroundVideoDecodingPermissionObserver_h_ 8 9 # include "nsIObserver.h" 10 # include "nsISupportsImpl.h" 11 12 class nsISupports; 13 class nsPIDOMWindowOuter; 14 15 namespace mozilla { 16 17 namespace dom { 18 class Document; 19 class BrowsingContext; 20 } // namespace dom 21 22 class MediaDecoder; 23 24 class BackgroundVideoDecodingPermissionObserver final : public nsIObserver { 25 public: 26 NS_DECL_ISUPPORTS 27 28 explicit BackgroundVideoDecodingPermissionObserver(MediaDecoder* aDecoder); 29 30 NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic, 31 const char16_t* aData) override; 32 void RegisterEvent(); 33 void UnregisterEvent(); 34 35 private: 36 ~BackgroundVideoDecodingPermissionObserver(); 37 void EnableEvent() const; 38 void DisableEvent() const; 39 dom::BrowsingContext* GetOwnerBC() const; 40 dom::Document* GetOwnerDoc() const; 41 bool IsValidEventSender(nsISupports* aSubject) const; 42 43 // The life cycle of observer would always be shorter than decoder, so we 44 // use raw pointer here. 45 MediaDecoder* mDecoder; 46 bool mIsRegisteredForEvent; 47 }; 48 49 } // namespace mozilla 50 51 #endif // BackgroundVideoDecodingPermissionObserver_h_