Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: chromecast/browser/media/cma_message_filter_host.cc

Issue 1091903003: Chromecast teardown race: SetCdm vs. pipeline destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adds explanation in comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/browser/media/cma_message_filter_host.cc
diff --git a/chromecast/browser/media/cma_message_filter_host.cc b/chromecast/browser/media/cma_message_filter_host.cc
index bdcc35b15bae1a85fa667978a7f91ba6edeece3a..e47cd71bafe539f49d5d44703609fc5fda03871c 100644
--- a/chromecast/browser/media/cma_message_filter_host.cc
+++ b/chromecast/browser/media/cma_message_filter_host.cc
@@ -37,7 +37,16 @@ namespace {
const size_t kMaxSharedMem = 8 * 1024 * 1024;
-void DestroyMediaPipeline(scoped_ptr<MediaPipelineHost> media_pipeline) {
+void DestroyMediaPipelineUi(
+ scoped_refptr<base::SingleThreadTaskRunner> cma_task_runner,
+ scoped_ptr<MediaPipelineHost> media_pipeline) {
+ // Note: the longest path that uses MediaPipelineHost from
+ // CmaMessageFilterHost is the "SetCdm" message, which travels:
+ // IO thread (msg) --> UI thread (get BrowserCdm) --> CMA thread (SetCdm)
+ // Teardown follows the same path to avoid MediaPipelineHost being destroyed
+ // while SetCdm is on/waiting for the UI thread.
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ cma_task_runner->DeleteSoon(FROM_HERE, media_pipeline.release());
}
void UpdateVideoSurfaceHost(int surface_id, const gfx::QuadF& quad) {
@@ -103,9 +112,11 @@ void CmaMessageFilterHost::DeleteEntries() {
it != media_pipelines_.end(); ) {
scoped_ptr<MediaPipelineHost> media_pipeline(it->second);
media_pipelines_.erase(it++);
- task_runner_->PostTask(
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
FROM_HERE,
- base::Bind(&DestroyMediaPipeline, base::Passed(&media_pipeline)));
+ base::Bind(&DestroyMediaPipelineUi, task_runner_,
+ base::Passed(&media_pipeline)));
}
}
@@ -153,9 +164,11 @@ void CmaMessageFilterHost::DestroyMedia(int media_id) {
scoped_ptr<MediaPipelineHost> media_pipeline(it->second);
media_pipelines_.erase(it);
- task_runner_->PostTask(
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
FROM_HERE,
- base::Bind(&DestroyMediaPipeline, base::Passed(&media_pipeline)));
+ base::Bind(&DestroyMediaPipelineUi, task_runner_,
+ base::Passed(&media_pipeline)));
}
void CmaMessageFilterHost::SetCdm(int media_id,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698