Bug 1309162 - part7 : wrap custom policy function. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 29 Nov 2016 12:40:47 +0800
changeset 445139 bbf2982658ca1c6c10438f0e6011b6d5a1968d1c
parent 445138 51b51a9f9fe4fb1ad9823dd6f50f5b8883bbb821
child 538444 90aa46a55b50e9da8fe68375f191c0786a20359d
push id37425
push useralwu@mozilla.com
push dateTue, 29 Nov 2016 05:50:50 +0000
bugs1309162
milestone53.0a1
Bug 1309162 - part7 : wrap custom policy function. 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;