Bug 1309162 - part7 : wrap custom policy function. r=jwwang
☠☠ backed out by eb95159069bb ☠ ☠
authorAlastor Wu <alwu@mozilla.com>
Mon, 28 Nov 2016 10:23:14 +0800
changeset 324530 3f0ad2d2c5941e532a934eeb9a04c248ab01e450
parent 324529 17c744162fbe53642a4d88848098d12c80f97bd4
child 324531 2348f42371f9b1384392bbdaf956f6d53fdcc3f6
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1309162
milestone53.0a1
Bug 1309162 - part7 : wrap custom policy function. r=jwwang MozReview-Commit-ID: EdjzMi90ukx
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3568,20 +3568,17 @@ HTMLMediaElement::Play(ErrorResult& aRv)
     return;
   }
 
   nsresult rv = PlayInternal();
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 
-  OpenUnsupportedMediaWithExternalAppIfNeeded();
-  if (mAudioChannelWrapper) {
-    mAudioChannelWrapper->NotifyPlayStarted();
-  }
+  UpdateCustomPolicyAfterPlayed();
 }
 
 nsresult
 HTMLMediaElement::PlayInternal()
 {
   // Play was not blocked so assume user interacted with the element.
   mHasUserInteraction = true;
 
@@ -3660,20 +3657,17 @@ NS_IMETHODIMP HTMLMediaElement::Play()
     return NS_OK;
   }
 
   nsresult rv = PlayInternal();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  OpenUnsupportedMediaWithExternalAppIfNeeded();
-  if (mAudioChannelWrapper) {
-    mAudioChannelWrapper->NotifyPlayStarted();
-  }
+  UpdateCustomPolicyAfterPlayed();
   return NS_OK;
 }
 
 HTMLMediaElement::WakeLockBoolWrapper&
 HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val)
 {
   if (mValue == val) {
     return *this;
@@ -6858,10 +6852,19 @@ HTMLMediaElement::MarkAsContentSource(Ca
     }
   }
 
   LOG(LogLevel::Debug,
       ("%p Log VIDEO_AS_CONTENT_SOURCE: visibility = %u, API: '%d' and 'All'",
        this, isVisible, aAPI));
 }
 
+void
+HTMLMediaElement::UpdateCustomPolicyAfterPlayed()
+{
+  OpenUnsupportedMediaWithExternalAppIfNeeded();
+  if (mAudioChannelWrapper) {
+    mAudioChannelWrapper->NotifyPlayStarted();
+  }
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1222,16 +1222,19 @@ protected:
   void AudioCaptureStreamChange(bool aCapture);
 
   // A method to check whether the media element is allowed to start playback.
   bool IsAllowedToPlay();
 
   // If the network state is empty and then we would trigger DoLoad().
   void MaybeDoLoad();
 
+  // Anything we need to check after played success and not related with spec.
+  void UpdateCustomPolicyAfterPlayed();
+
   class nsAsyncEventRunner;
   using nsGenericHTMLElement::DispatchEvent;
   // For nsAsyncEventRunner.
   nsresult DispatchEvent(const nsAString& aName);
 
   // Open unsupported types media with the external app when the media element
   // triggers play() after loaded fail. eg. preload the data before start play.
   void OpenUnsupportedMediaWithExternalAppIfNeeded() const;