Bug 1264694 - [MSE] P3. Remove no longer necessay methods. r=jwwang, a=ritu
☠☠ backed out by 9d87d3a279a0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 16 May 2016 21:14:28 +0800
changeset 333071 72d6db53a7b3f3d6d46fba8df205692a3d0f1270
parent 333070 beddf03ae7f7dfa3a935d316a5d8d159f7b8110a
child 333072 acbb89b3299e3c69ad9eddfb6abc44b143e29f6c
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, ritu
bugs1264694
milestone48.0a2
Bug 1264694 - [MSE] P3. Remove no longer necessay methods. r=jwwang, a=ritu P2 let all tasks run until completion, as such we don't need to deal with interrupted tasks anymore. MozReview-Commit-ID: 45lYcIGk2ce
dom/media/mediasource/TrackBuffersManager.cpp
dom/media/mediasource/TrackBuffersManager.h
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -106,17 +106,16 @@ TrackBuffersManager::TrackBuffersManager
   , mEvictionOccurred(false)
   , mMonitor("TrackBuffersManager")
 {
   MOZ_ASSERT(NS_IsMainThread(), "Must be instanciated on the main thread");
 }
 
 TrackBuffersManager::~TrackBuffersManager()
 {
-  CancelAllTasks();
   ShutdownDemuxers();
 }
 
 RefPtr<TrackBuffersManager::AppendPromise>
 TrackBuffersManager::AppendData(MediaByteBuffer* aData,
                                 const SourceBufferAttributes& aAttributes)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -211,53 +210,16 @@ TrackBuffersManager::ProcessTasks()
     default:
       NS_WARNING("Invalid Task");
   }
   nsCOMPtr<nsIRunnable> task =
     NS_NewRunnableMethod(this, &TrackBuffersManager::ProcessTasks);
   GetTaskQueue()->Dispatch(task.forget());
 }
 
-// A PromiseHolder will assert upon destruction if it has a pending promise
-// that hasn't been completed. It is possible that a task didn't get processed
-// due to the owning SourceBuffer having shutdown.
-// We resolve/reject all pending promises and remove all pending tasks from the
-// queue.
-void
-TrackBuffersManager::CancelAllTasks()
-{
-  typedef SourceBufferTask::Type Type;
-
-  if (mCurrentTask) {
-    mQueue.Push(mCurrentTask);
-    mCurrentTask = nullptr;
-  }
-
-  RefPtr<SourceBufferTask> task;
-  while ((task = mQueue.Pop())) {
-    switch (task->GetType()) {
-      case Type::AppendBuffer:
-        task->As<AppendBufferTask>()->mPromise.RejectIfExists(NS_ERROR_ABORT, __func__);
-        break;
-      case Type::RangeRemoval:
-        task->As<RangeRemovalTask>()->mPromise.ResolveIfExists(false, __func__);
-        break;
-      case Type::EvictData:
-        break;
-      case Type::Abort:
-        // not handled yet, and probably never.
-        break;
-      case Type::Reset:
-        break;
-      default:
-        NS_WARNING("Invalid Task");
-    }
-  }
-}
-
 // The MSE spec requires that we abort the current SegmentParserLoop
 // which is then followed by a call to ResetParserState.
 // However due to our asynchronous design this causes inherent difficulties.
 // As the spec behaviour is non deterministic anyway, we instead process all
 // pending frames found in the input buffer.
 void
 TrackBuffersManager::AbortAppendData()
 {
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -30,16 +30,20 @@ class MediaRawData;
 class MediaSourceDemuxer;
 class SourceBufferResource;
 
 class SourceBufferTaskQueue {
 public:
   SourceBufferTaskQueue()
   : mMonitor("SourceBufferTaskQueue")
   {}
+  ~SourceBufferTaskQueue()
+  {
+    MOZ_ASSERT(mQueue.IsEmpty(), "All tasks must have been processed");
+  }
 
   void Push(SourceBufferTask* aTask)
   {
     MonitorAutoLock mon(mMonitor);
     mQueue.AppendElement(aTask);
   }
 
   already_AddRefed<SourceBufferTask> Pop()
@@ -375,17 +379,16 @@ private:
     return !GetTaskQueue() || GetTaskQueue()->IsCurrentThreadIn();
   }
   RefPtr<AutoTaskQueue> mTaskQueue;
 
   // SourceBuffer Queues and running context.
   SourceBufferTaskQueue mQueue;
   void QueueTask(SourceBufferTask* aTask);
   void ProcessTasks();
-  void CancelAllTasks();
   // Set if the TrackBuffersManager is currently processing a task.
   // At this stage, this task is always a AppendBufferTask.
   RefPtr<SourceBufferTask> mCurrentTask;
   // Current SourceBuffer state for ongoing task.
   // Its content is returned to the SourceBuffer once the AppendBufferTask has
   // completed.
   UniquePtr<SourceBufferAttributes> mSourceBufferAttributes;
   // The current sourcebuffer append window. It's content is equivalent to