2017-12-06 01:22:36 +03:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#if !defined(BackgroundVideoDecodingPermissionObserver_h_)
|
|
|
|
# define BackgroundVideoDecodingPermissionObserver_h_
|
|
|
|
|
|
|
|
# include "nsIObserver.h"
|
|
|
|
# include "nsISupportsImpl.h"
|
|
|
|
|
|
|
|
class nsISupports;
|
|
|
|
class nsPIDOMWindowOuter;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
namespace dom {
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2017-12-06 01:22:36 +03:00
|
|
|
class MediaDecoder;
|
|
|
|
|
|
|
|
class BackgroundVideoDecodingPermissionObserver final : public nsIObserver {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2018-11-19 16:25:37 +03:00
|
|
|
|
2017-12-06 01:22:36 +03:00
|
|
|
explicit BackgroundVideoDecodingPermissionObserver(MediaDecoder* aDecoder);
|
2018-11-19 16:25:37 +03:00
|
|
|
|
2017-12-06 01:22:36 +03:00
|
|
|
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const char16_t* aData) override;
|
|
|
|
void RegisterEvent();
|
|
|
|
void UnregisterEvent();
|
2018-11-19 16:25:37 +03:00
|
|
|
|
2017-12-06 01:22:36 +03:00
|
|
|
private:
|
|
|
|
~BackgroundVideoDecodingPermissionObserver();
|
|
|
|
void EnableEvent() const;
|
|
|
|
void DisableEvent() const;
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetOwnerWindow() const;
|
2019-01-02 16:05:23 +03:00
|
|
|
dom::Document* GetOwnerDoc() const;
|
2017-12-06 01:22:36 +03:00
|
|
|
bool IsValidEventSender(nsISupports* aSubject) const;
|
2018-11-19 16:25:37 +03:00
|
|
|
|
2017-12-06 01:22:36 +03:00
|
|
|
// The life cycle of observer would always be shorter than decoder, so we
|
|
|
|
// use raw pointer here.
|
|
|
|
MediaDecoder* mDecoder;
|
|
|
|
bool mIsRegisteredForEvent;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // BackgroundVideoDecodingPermissionObserver_h_
|