diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 22:11:37 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 22:11:37 +0000 |
commit | bec820d6bdf619ccfc07747cd124286edfa5d99d (patch) | |
tree | 85dc6f7a8829315786b89ccf6427683b5ea57b53 /remoting/host/ipc_audio_capturer.cc | |
parent | 098fa7a8f9b2ad4a28e9c6268329ab1e20eb081f (diff) | |
download | chromium_src-bec820d6bdf619ccfc07747cd124286edfa5d99d.zip chromium_src-bec820d6bdf619ccfc07747cd124286edfa5d99d.tar.gz chromium_src-bec820d6bdf619ccfc07747cd124286edfa5d99d.tar.bz2 |
DesktopSessionProxy should be owned by the event executor and audio/video capturers it creates.
This CL makes sure that a DesktopSessionProxy object is owned by the event executor and audio/video capturers it creates and nobody else. This change is requied in order to be able create the desktop environment late (in ClientSession::OnConnectionChannelsConnected()) and keep it around until the event executor and audio/video capturers have been created. This in turn makes sure that |curtain_activated| flag can be properly set when an instance of desktop environment is created.
Related changes in this CL:
- Received audio/video packets are posted to the corresponding threads via weak pointers. The pointers are invalidated when the corresponding capturer is stopped.
- DesktopSessionConnector registration keeps a raw pointer to DesktopSessionProxy. DesktopSessionProxy makes sure that the registration is undone in the destructor.
- DesktopSessionProxy makes sure it is deleted on the proper thread, so all members are deleted on the same thread they were created on.
BUG=137696
Review URL: https://chromiumcodereview.appspot.com/12374098
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/ipc_audio_capturer.cc')
-rw-r--r-- | remoting/host/ipc_audio_capturer.cc | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/remoting/host/ipc_audio_capturer.cc b/remoting/host/ipc_audio_capturer.cc index 17c478e..49fb51e 100644 --- a/remoting/host/ipc_audio_capturer.cc +++ b/remoting/host/ipc_audio_capturer.cc @@ -11,48 +11,32 @@ namespace remoting { IpcAudioCapturer::IpcAudioCapturer( scoped_refptr<DesktopSessionProxy> desktop_session_proxy) - : desktop_session_proxy_(desktop_session_proxy) { - // The audio capturer is created on the network thread while used on the audio - // capture thread. Detach |thread_checker_| from the current thread so that it - // will re-attach to the proper thread when Start() is called for the first - // time. - thread_checker_.DetachFromThread(); + : desktop_session_proxy_(desktop_session_proxy), + weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } IpcAudioCapturer::~IpcAudioCapturer() { - DCHECK(callback_.is_null()); } bool IpcAudioCapturer::Start(const PacketCapturedCallback& callback) { - DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(callback_.is_null()); DCHECK(!callback.is_null()); callback_ = callback; - desktop_session_proxy_->StartAudioCapturer(this); - + desktop_session_proxy_->SetAudioCapturer(weak_factory_.GetWeakPtr()); return true; } void IpcAudioCapturer::Stop() { - DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK(!callback_.is_null()); - - desktop_session_proxy_->StopAudioCapturer(); callback_.Reset(); + weak_factory_.InvalidateWeakPtrs(); } bool IpcAudioCapturer::IsStarted() { - DCHECK(thread_checker_.CalledOnValidThread()); - return !callback_.is_null(); } -// Called when an audio packet has been received. void IpcAudioCapturer::OnAudioPacket(scoped_ptr<AudioPacket> packet) { - DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK(!callback_.is_null()); - callback_.Run(packet.Pass()); } |