Bug 1480281 - part2 : move exist log to autoplay log module.
MozReview-Commit-ID: EtBRTjYG8k3
--- a/dom/html/AutoplayPermissionManager.cpp
+++ b/dom/html/AutoplayPermissionManager.cpp
@@ -7,20 +7,20 @@
#include "mozilla/AutoplayPermissionManager.h"
#include "mozilla/AutoplayPermissionRequest.h"
#include "nsGlobalWindowInner.h"
#include "nsISupportsImpl.h"
#include "mozilla/Logging.h"
#include "nsContentPermissionHelper.h"
-extern mozilla::LazyLogModule gMediaElementLog;
+extern mozilla::LazyLogModule gAutoplayPermissionLog;
#define PLAY_REQUEST_LOG(msg, ...) \
- MOZ_LOG(gMediaElementLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
+ MOZ_LOG(gAutoplayPermissionLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
namespace mozilla {
RefPtr<GenericPromise>
AutoplayPermissionManager::RequestWithPrompt()
{
// If we've already requested permission, we'll just return the promise,
// as we don't want to show multiple permission requests at once.
--- a/dom/html/AutoplayPermissionRequest.cpp
+++ b/dom/html/AutoplayPermissionRequest.cpp
@@ -4,20 +4,20 @@
* 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/. */
#include "mozilla/AutoplayPermissionRequest.h"
#include "mozilla/AutoplayPermissionManager.h"
#include "mozilla/Logging.h"
-extern mozilla::LazyLogModule gMediaElementLog;
+extern mozilla::LazyLogModule gAutoplayPermissionLog;
#define PLAY_REQUEST_LOG(msg, ...) \
- MOZ_LOG(gMediaElementLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
+ MOZ_LOG(gAutoplayPermissionLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
namespace mozilla {
NS_IMPL_ISUPPORTS(AutoplayPermissionRequest, nsIContentPermissionRequest)
AutoplayPermissionRequest::AutoplayPermissionRequest(
AutoplayPermissionManager* aManager,
nsGlobalWindowInner* aWindow,
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4097,17 +4097,17 @@ HTMLMediaElement::Play(ErrorResult& aRv)
switch (AutoplayPolicy::IsAllowedToPlay(*this)) {
case nsIAutoplay::ALLOWED: {
mPendingPlayPromises.AppendElement(promise);
PlayInternal(handlingUserInput);
UpdateCustomPolicyAfterPlayed();
break;
}
case nsIAutoplay::BLOCKED: {
- LOG(LogLevel::Debug, ("%p play not blocked.", this));
+ AUTOPLAY_LOG("%p play blocked.", this);
promise->MaybeReject(NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR);
if (StaticPrefs::MediaBlockEventEnabled()) {
DispatchAsyncEvent(NS_LITERAL_STRING("blocked"));
}
break;
}
case nsIAutoplay::PROMPT: {
// Prompt the user for permission to play.
@@ -4122,47 +4122,44 @@ HTMLMediaElement::Play(ErrorResult& aRv)
void
HTMLMediaElement::EnsureAutoplayRequested(bool aHandlingUserInput)
{
if (mAutoplayPermissionRequest.Exists()) {
// Autoplay has already been requested in a previous play() call.
// Await for the previous request to be approved or denied. This
// play request's promise will be fulfilled with all other pending
// promises when the permission prompt is resolved.
- LOG(LogLevel::Debug,
- ("%p EnsureAutoplayRequested() existing request, bailing.", this));
+ AUTOPLAY_LOG("%p EnsureAutoplayRequested() existing request, bailing.", this);
return;
}
RefPtr<AutoplayPermissionManager> request =
AutoplayPolicy::RequestFor(*OwnerDoc());
if (!request) {
AsyncRejectPendingPlayPromises(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
RefPtr<HTMLMediaElement> self = this;
request->RequestWithPrompt()
->Then(mAbstractMainThread,
__func__,
[ self, handlingUserInput = aHandlingUserInput, request ](
bool aApproved) {
self->mAutoplayPermissionRequest.Complete();
- LOG(LogLevel::Debug,
- ("%p Autoplay request approved request=%p",
- self.get(),
- request.get()));
+ AUTOPLAY_LOG("%p Autoplay request approved request=%p",
+ self.get(),
+ request.get());
self->PlayInternal(handlingUserInput);
self->UpdateCustomPolicyAfterPlayed();
},
[self, request](nsresult aError) {
self->mAutoplayPermissionRequest.Complete();
- LOG(LogLevel::Debug,
- ("%p Autoplay request denied request=%p",
- self.get(),
- request.get()));
+ AUTOPLAY_LOG("%p Autoplay request denied request=%p",
+ self.get(),
+ request.get());
LOG(LogLevel::Debug, ("%s rejecting play promimses", __func__));
self->AsyncRejectPendingPlayPromises(
NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR);
})
->Track(mAutoplayPermissionRequest);
}
void