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

Side by Side Diff: media/mojo/services/mojo_renderer_impl.cc

Issue 1517753002: Create and use mojo::Binding on the same thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « media/mojo/services/mojo_renderer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/mojo/services/mojo_renderer_impl.h" 5 #include "media/mojo/services/mojo_renderer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "media/base/bind_to_current_loop.h" 11 #include "media/base/bind_to_current_loop.h"
12 #include "media/base/demuxer_stream_provider.h" 12 #include "media/base/demuxer_stream_provider.h"
13 #include "media/mojo/services/mojo_demuxer_stream_impl.h" 13 #include "media/mojo/services/mojo_demuxer_stream_impl.h"
14 #include "mojo/application/public/cpp/connect.h" 14 #include "mojo/application/public/cpp/connect.h"
15 #include "mojo/application/public/interfaces/service_provider.mojom.h" 15 #include "mojo/application/public/interfaces/service_provider.mojom.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 MojoRendererImpl::MojoRendererImpl( 19 MojoRendererImpl::MojoRendererImpl(
20 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 20 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
21 interfaces::RendererPtr remote_renderer) 21 interfaces::RendererPtr remote_renderer)
22 : task_runner_(task_runner), 22 : task_runner_(task_runner),
23 remote_renderer_(remote_renderer.Pass()), 23 remote_renderer_(remote_renderer.Pass()),
24 binding_(this),
25 weak_factory_(this) { 24 weak_factory_(this) {
26 DVLOG(1) << __FUNCTION__; 25 DVLOG(1) << __FUNCTION__;
27 } 26 }
28 27
29 MojoRendererImpl::~MojoRendererImpl() { 28 MojoRendererImpl::~MojoRendererImpl() {
30 DVLOG(1) << __FUNCTION__; 29 DVLOG(1) << __FUNCTION__;
31 DCHECK(task_runner_->BelongsToCurrentThread()); 30 DCHECK(task_runner_->BelongsToCurrentThread());
32 // Connection to |remote_renderer_| will error-out here. 31 // Connection to |remote_renderer_| will error-out here.
33 } 32 }
34 33
(...skipping 25 matching lines...) Expand all
60 59
61 interfaces::DemuxerStreamPtr audio_stream; 60 interfaces::DemuxerStreamPtr audio_stream;
62 if (audio) 61 if (audio)
63 new MojoDemuxerStreamImpl(audio, GetProxy(&audio_stream)); 62 new MojoDemuxerStreamImpl(audio, GetProxy(&audio_stream));
64 63
65 interfaces::DemuxerStreamPtr video_stream; 64 interfaces::DemuxerStreamPtr video_stream;
66 if (video) 65 if (video)
67 new MojoDemuxerStreamImpl(video, GetProxy(&video_stream)); 66 new MojoDemuxerStreamImpl(video, GetProxy(&video_stream));
68 67
69 interfaces::RendererClientPtr client_ptr; 68 interfaces::RendererClientPtr client_ptr;
70 binding_.Bind(GetProxy(&client_ptr)); 69 binding_.reset(
70 new mojo::Binding<RendererClient>(this, GetProxy(&client_ptr)));
71 remote_renderer_->Initialize( 71 remote_renderer_->Initialize(
72 client_ptr.Pass(), audio_stream.Pass(), video_stream.Pass(), 72 client_ptr.Pass(), audio_stream.Pass(), video_stream.Pass(),
73 BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized, 73 BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized,
74 weak_factory_.GetWeakPtr()))); 74 weak_factory_.GetWeakPtr())));
75 } 75 }
76 76
77 void MojoRendererImpl::SetCdm(CdmContext* cdm_context, 77 void MojoRendererImpl::SetCdm(CdmContext* cdm_context,
78 const CdmAttachedCB& cdm_attached_cb) { 78 const CdmAttachedCB& cdm_attached_cb) {
79 DVLOG(1) << __FUNCTION__; 79 DVLOG(1) << __FUNCTION__;
80 DCHECK(task_runner_->BelongsToCurrentThread()); 80 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void MojoRendererImpl::OnInitialized(bool success) { 203 void MojoRendererImpl::OnInitialized(bool success) {
204 DVLOG(1) << __FUNCTION__; 204 DVLOG(1) << __FUNCTION__;
205 DCHECK(task_runner_->BelongsToCurrentThread()); 205 DCHECK(task_runner_->BelongsToCurrentThread());
206 DCHECK(!init_cb_.is_null()); 206 DCHECK(!init_cb_.is_null());
207 207
208 base::ResetAndReturn(&init_cb_) 208 base::ResetAndReturn(&init_cb_)
209 .Run(success ? PIPELINE_OK : PIPELINE_ERROR_INITIALIZATION_FAILED); 209 .Run(success ? PIPELINE_OK : PIPELINE_ERROR_INITIALIZATION_FAILED);
210 } 210 }
211 211
212 } // namespace media 212 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_renderer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698