Bug 1302001. Move some code to WaitForCDMState. r=kaku
authorJW Wang <jwwang@mozilla.com>
Tue, 06 Sep 2016 15:01:30 +0800
changeset 313481 3d667f260feb3f7f30fca84f608b92e330aa349c
parent 313480 3c226fecfb2c1ec6dcc8cb21cb54139660b66be4
child 313499 1851b78b5a9673ee422f189b92e5f1e86b82a01c
child 313500 402dbb3419f489906677bace2be85c7326bd2763
push id30687
push usercbook@mozilla.com
push dateMon, 12 Sep 2016 11:05:55 +0000
treeherdermozilla-central@3d667f260feb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1302001
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1302001. Move some code to WaitForCDMState. r=kaku MozReview-Commit-ID: RAvuVs7Ykq
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -219,16 +219,17 @@ public:
   virtual void Enter() {}; // Entry action.
   virtual void Exit() {};  // Exit action.
   virtual void Step() {}   // Perform a 'cycle' of this state object.
   virtual State GetState() const = 0;
 
   // Event handlers for various events.
   // Return true if the event is handled by this state object.
   virtual bool HandleDormant(bool aDormant) { return false; }
+  virtual bool HandleCDMProxyReady() { return false; }
 
 protected:
   using Master = MediaDecoderStateMachine;
   explicit StateObject(Master* aPtr) : mMaster(aPtr) {}
   TaskQueue* OwnerThread() const { return mMaster->mTaskQueue; }
   MediaResource* Resource() const { return mMaster->mResource; }
   MediaDecoderReaderWrapper* Reader() const { return mMaster->mReader; }
 
@@ -374,16 +375,22 @@ class MediaDecoderStateMachine::WaitForC
 {
 public:
   explicit WaitForCDMState(Master* aPtr) : StateObject(aPtr) {}
 
   State GetState() const override
   {
     return DECODER_STATE_WAIT_FOR_CDM;
   }
+
+  bool HandleCDMProxyReady() override
+  {
+    SetState(DECODER_STATE_DECODING_FIRSTFRAME);
+    return true;
+  }
 };
 
 class MediaDecoderStateMachine::DormantState
   : public MediaDecoderStateMachine::StateObject
 {
 public:
   explicit DormantState(Master* aPtr) : StateObject(aPtr) {}
 
@@ -2949,19 +2956,17 @@ void MediaDecoderStateMachine::OnMediaSi
 #ifdef MOZ_EME
 void
 MediaDecoderStateMachine::OnCDMProxyReady(RefPtr<CDMProxy> aProxy)
 {
   MOZ_ASSERT(OnTaskQueue());
   mCDMProxyPromise.Complete();
   mCDMProxy = aProxy;
   mReader->SetCDMProxy(aProxy);
-  if (mState == DECODER_STATE_WAIT_FOR_CDM) {
-    SetState(DECODER_STATE_DECODING_FIRSTFRAME);
-  }
+  mStateObj->HandleCDMProxyReady();
 }
 
 void
 MediaDecoderStateMachine::OnCDMProxyNotReady()
 {
   MOZ_ASSERT(OnTaskQueue());
   mCDMProxyPromise.Complete();
 }