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

Unified Diff: content/renderer/media/media_interface_provider.cc

Issue 2684103005: Allow media track switching. (Closed)
Patch Set: Fixed comments Created 3 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 | « content/renderer/media/media_interface_provider.h ('k') | media/base/audio_renderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_interface_provider.cc
diff --git a/content/renderer/media/media_interface_provider.cc b/content/renderer/media/media_interface_provider.cc
index 8f779f5bf39dddd7a374c9949ee9788350077769..49592bb8dec660e92b5250821c67d03958e9ee46 100644
--- a/content/renderer/media/media_interface_provider.cc
+++ b/content/renderer/media/media_interface_provider.cc
@@ -16,16 +16,26 @@ namespace content {
MediaInterfaceProvider::MediaInterfaceProvider(
service_manager::InterfaceProvider* remote_interfaces)
- : remote_interfaces_(remote_interfaces) {}
+ : remote_interfaces_(remote_interfaces), weak_factory_(this) {
+ task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ weak_this_ = weak_factory_.GetWeakPtr();
+}
MediaInterfaceProvider::~MediaInterfaceProvider() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
}
void MediaInterfaceProvider::GetInterface(const std::string& interface_name,
mojo::ScopedMessagePipeHandle pipe) {
DVLOG(1) << __func__;
- DCHECK(thread_checker_.CalledOnValidThread());
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&MediaInterfaceProvider::GetInterface, weak_this_,
+ interface_name, base::Passed(&pipe)));
+ return;
+ }
+
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (interface_name == media::mojom::ContentDecryptionModule::Name_) {
GetMediaInterfaceFactory()->CreateCdm(
@@ -49,7 +59,7 @@ void MediaInterfaceProvider::GetInterface(const std::string& interface_name,
media::mojom::InterfaceFactory*
MediaInterfaceProvider::GetMediaInterfaceFactory() {
DVLOG(1) << __func__;
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (!media_interface_factory_) {
remote_interfaces_->GetInterface(&media_interface_factory_);
@@ -62,7 +72,7 @@ MediaInterfaceProvider::GetMediaInterfaceFactory() {
void MediaInterfaceProvider::OnConnectionError() {
DVLOG(1) << __func__;
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
media_interface_factory_.reset();
}
« no previous file with comments | « content/renderer/media/media_interface_provider.h ('k') | media/base/audio_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698