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

Side by Side Diff: content/renderer/media/media_interface_provider.cc

Issue 2684103005: Allow media track switching. (Closed)
Patch Set: CR feedback Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_interface_provider.h" 5 #include "content/renderer/media/media_interface_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 10 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
11 #include "media/mojo/interfaces/renderer.mojom.h" 11 #include "media/mojo/interfaces/renderer.mojom.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 12 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "services/service_manager/public/cpp/interface_provider.h" 13 #include "services/service_manager/public/cpp/interface_provider.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 MediaInterfaceProvider::MediaInterfaceProvider( 17 MediaInterfaceProvider::MediaInterfaceProvider(
18 service_manager::InterfaceProvider* remote_interfaces) 18 service_manager::InterfaceProvider* remote_interfaces)
19 : remote_interfaces_(remote_interfaces) {} 19 : remote_interfaces_(remote_interfaces), weak_factory_(this) {
20 task_runner_ = base::ThreadTaskRunnerHandle::Get();
21 }
20 22
21 MediaInterfaceProvider::~MediaInterfaceProvider() { 23 MediaInterfaceProvider::~MediaInterfaceProvider() {
22 DCHECK(thread_checker_.CalledOnValidThread()); 24 DCHECK(thread_checker_.CalledOnValidThread());
23 } 25 }
24 26
25 void MediaInterfaceProvider::GetInterface(const std::string& interface_name, 27 void MediaInterfaceProvider::GetInterface(const std::string& interface_name,
26 mojo::ScopedMessagePipeHandle pipe) { 28 mojo::ScopedMessagePipeHandle pipe) {
27 DVLOG(1) << __func__; 29 DVLOG(1) << __func__;
30 if (!task_runner_->BelongsToCurrentThread()) {
31 task_runner_->PostTask(
32 FROM_HERE, base::Bind(&MediaInterfaceProvider::GetInterface,
33 weak_factory_.GetWeakPtr(), interface_name,
DaleCurtis 2017/03/24 19:35:22 Can't vend WeakPtrs from a different thread like t
servolk 2017/03/24 21:15:32 Done (although I'm a little surprised. shouldn't t
DaleCurtis 2017/03/24 21:30:38 Hard to DCHECK since it's a raciness issue.
34 base::Passed(&pipe)));
35 return;
36 }
28 DCHECK(thread_checker_.CalledOnValidThread()); 37 DCHECK(thread_checker_.CalledOnValidThread());
29 38
30 if (interface_name == media::mojom::ContentDecryptionModule::Name_) { 39 if (interface_name == media::mojom::ContentDecryptionModule::Name_) {
31 GetMediaInterfaceFactory()->CreateCdm( 40 GetMediaInterfaceFactory()->CreateCdm(
32 mojo::MakeRequest<media::mojom::ContentDecryptionModule>( 41 mojo::MakeRequest<media::mojom::ContentDecryptionModule>(
33 std::move(pipe))); 42 std::move(pipe)));
34 } else if (interface_name == media::mojom::Renderer::Name_) { 43 } else if (interface_name == media::mojom::Renderer::Name_) {
35 GetMediaInterfaceFactory()->CreateRenderer( 44 GetMediaInterfaceFactory()->CreateRenderer(
36 std::string(), 45 std::string(),
37 mojo::MakeRequest<media::mojom::Renderer>(std::move(pipe))); 46 mojo::MakeRequest<media::mojom::Renderer>(std::move(pipe)));
(...skipping 23 matching lines...) Expand all
61 } 70 }
62 71
63 void MediaInterfaceProvider::OnConnectionError() { 72 void MediaInterfaceProvider::OnConnectionError() {
64 DVLOG(1) << __func__; 73 DVLOG(1) << __func__;
65 DCHECK(thread_checker_.CalledOnValidThread()); 74 DCHECK(thread_checker_.CalledOnValidThread());
66 75
67 media_interface_factory_.reset(); 76 media_interface_factory_.reset();
68 } 77 }
69 78
70 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698