diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-28 06:36:15 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-28 06:36:15 +0000 |
commit | 69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27 (patch) | |
tree | 26e7e6c146725e92e66e1226a727add18fa563bc /content/renderer/pepper | |
parent | 355b853894c91bc1822d0737d55a5883d865d839 (diff) | |
download | chromium_src-69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27.zip chromium_src-69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27.tar.gz chromium_src-69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27.tar.bz2 |
RefCounted types should not have public destructors, content/browser part 2
BUG=123295
TEST=none
TBR=brettw
Review URL: https://chromiumcodereview.appspot.com/10071038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/pepper')
6 files changed, 156 insertions, 151 deletions
diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.cc b/content/renderer/pepper/pepper_platform_audio_input_impl.cc index c69d562..effcf2a 100644 --- a/content/renderer/pepper/pepper_platform_audio_input_impl.cc +++ b/content/renderer/pepper/pepper_platform_audio_input_impl.cc @@ -16,26 +16,6 @@ namespace content { -PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl() - : client_(NULL), - stream_id_(0), - main_message_loop_proxy_(base::MessageLoopProxy::current()), - shutdown_called_(false) { - filter_ = RenderThreadImpl::current()->audio_input_message_filter(); -} - -PepperPlatformAudioInputImpl::~PepperPlatformAudioInputImpl() { - // Make sure we have been shut down. Warning: this may happen on the I/O - // thread! - // Although these members should be accessed on a specific thread (either the - // main thread or the I/O thread), it should be fine to examine their value - // here. - DCHECK_EQ(0, stream_id_); - DCHECK(!client_); - DCHECK(label_.empty()); - DCHECK(shutdown_called_); -} - // static PepperPlatformAudioInputImpl* PepperPlatformAudioInputImpl::Create( const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, @@ -81,6 +61,83 @@ void PepperPlatformAudioInputImpl::ShutDown() { base::Bind(&PepperPlatformAudioInputImpl::ShutDownOnIOThread, this)); } +void PepperPlatformAudioInputImpl::OnStreamCreated( + base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) { +#if defined(OS_WIN) + DCHECK(handle); + DCHECK(socket_handle); +#else + DCHECK_NE(-1, handle.fd); + DCHECK_NE(-1, socket_handle); +#endif + DCHECK(length); + + if (base::MessageLoopProxy::current() != main_message_loop_proxy_) { + // No need to check |shutdown_called_| here. If shutdown has occurred, + // |client_| will be NULL and the handles will be cleaned up on the main + // thread. + main_message_loop_proxy_->PostTask( + FROM_HERE, + base::Bind(&PepperPlatformAudioInputImpl::OnStreamCreated, this, + handle, socket_handle, length)); + } else { + // Must dereference the client only on the main thread. Shutdown may have + // occurred while the request was in-flight, so we need to NULL check. + if (client_) { + client_->StreamCreated(handle, length, socket_handle); + } else { + // Clean up the handles. + base::SyncSocket temp_socket(socket_handle); + base::SharedMemory temp_shared_memory(handle, false); + } + } +} + +void PepperPlatformAudioInputImpl::OnVolume(double volume) {} + +void PepperPlatformAudioInputImpl::OnStateChanged(AudioStreamState state) {} + +void PepperPlatformAudioInputImpl::OnDeviceReady(const std::string& device_id) { + DCHECK(ChildProcess::current()->io_message_loop_proxy()-> + BelongsToCurrentThread()); + + if (shutdown_called_) + return; + + if (device_id.empty()) { + main_message_loop_proxy_->PostTask( + FROM_HERE, + base::Bind(&PepperPlatformAudioInputImpl::NotifyStreamCreationFailed, + this)); + } else { + // We will be notified by OnStreamCreated(). + filter_->Send(new AudioInputHostMsg_CreateStream(stream_id_, params_, + device_id, false)); + } +} + +PepperPlatformAudioInputImpl::~PepperPlatformAudioInputImpl() { + // Make sure we have been shut down. Warning: this may happen on the I/O + // thread! + // Although these members should be accessed on a specific thread (either the + // main thread or the I/O thread), it should be fine to examine their value + // here. + DCHECK_EQ(0, stream_id_); + DCHECK(!client_); + DCHECK(label_.empty()); + DCHECK(shutdown_called_); +} + +PepperPlatformAudioInputImpl::PepperPlatformAudioInputImpl() + : client_(NULL), + stream_id_(0), + main_message_loop_proxy_(base::MessageLoopProxy::current()), + shutdown_called_(false) { + filter_ = RenderThreadImpl::current()->audio_input_message_filter(); +} + bool PepperPlatformAudioInputImpl::Initialize( const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, const std::string& device_id, @@ -177,65 +234,6 @@ void PepperPlatformAudioInputImpl::ShutDownOnIOThread() { // PepperPluginDelegateImpl::CreateAudioInput. } -void PepperPlatformAudioInputImpl::OnStreamCreated( - base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) { -#if defined(OS_WIN) - DCHECK(handle); - DCHECK(socket_handle); -#else - DCHECK_NE(-1, handle.fd); - DCHECK_NE(-1, socket_handle); -#endif - DCHECK(length); - - if (base::MessageLoopProxy::current() != main_message_loop_proxy_) { - // No need to check |shutdown_called_| here. If shutdown has occurred, - // |client_| will be NULL and the handles will be cleaned up on the main - // thread. - main_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PepperPlatformAudioInputImpl::OnStreamCreated, this, - handle, socket_handle, length)); - } else { - // Must dereference the client only on the main thread. Shutdown may have - // occurred while the request was in-flight, so we need to NULL check. - if (client_) { - client_->StreamCreated(handle, length, socket_handle); - } else { - // Clean up the handles. - base::SyncSocket temp_socket(socket_handle); - base::SharedMemory temp_shared_memory(handle, false); - } - } -} - -void PepperPlatformAudioInputImpl::OnVolume(double volume) { -} - -void PepperPlatformAudioInputImpl::OnStateChanged(AudioStreamState state) { -} - -void PepperPlatformAudioInputImpl::OnDeviceReady(const std::string& device_id) { - DCHECK(ChildProcess::current()->io_message_loop_proxy()-> - BelongsToCurrentThread()); - - if (shutdown_called_) - return; - - if (device_id.empty()) { - main_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PepperPlatformAudioInputImpl::NotifyStreamCreationFailed, - this)); - } else { - // We will be notified by OnStreamCreated(). - filter_->Send(new AudioInputHostMsg_CreateStream(stream_id_, params_, - device_id, false)); - } -} - void PepperPlatformAudioInputImpl::OnDeviceOpened(int request_id, bool succeeded, const std::string& label) { diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.h b/content/renderer/pepper/pepper_platform_audio_input_impl.h index 4117fe4..6b6c3b41 100644 --- a/content/renderer/pepper/pepper_platform_audio_input_impl.h +++ b/content/renderer/pepper/pepper_platform_audio_input_impl.h @@ -36,8 +36,6 @@ class PepperPlatformAudioInputImpl public AudioInputMessageFilter::Delegate, public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { public: - virtual ~PepperPlatformAudioInputImpl(); - // Factory function, returns NULL on failure. StreamCreated() will be called // when the stream is created. static PepperPlatformAudioInputImpl* Create( @@ -52,7 +50,20 @@ class PepperPlatformAudioInputImpl virtual void StopCapture() OVERRIDE; virtual void ShutDown() OVERRIDE; + // AudioInputMessageFilter::Delegate. + virtual void OnStreamCreated(base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) OVERRIDE; + virtual void OnVolume(double volume) OVERRIDE; + virtual void OnStateChanged(AudioStreamState state) OVERRIDE; + virtual void OnDeviceReady(const std::string&) OVERRIDE; + + protected: + virtual ~PepperPlatformAudioInputImpl(); + private: + friend class base::RefCountedThreadSafe<PepperPlatformAudioInputImpl>; + PepperPlatformAudioInputImpl(); bool Initialize( @@ -68,14 +79,6 @@ class PepperPlatformAudioInputImpl void StopCaptureOnIOThread(); void ShutDownOnIOThread(); - // AudioInputMessageFilter::Delegate. - virtual void OnStreamCreated(base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) OVERRIDE; - virtual void OnVolume(double volume) OVERRIDE; - virtual void OnStateChanged(AudioStreamState state) OVERRIDE; - virtual void OnDeviceReady(const std::string&) OVERRIDE; - void OnDeviceOpened(int request_id, bool succeeded, const std::string& label); diff --git a/content/renderer/pepper/pepper_platform_audio_output_impl.cc b/content/renderer/pepper/pepper_platform_audio_output_impl.cc index 84ae082..65239e6 100644 --- a/content/renderer/pepper/pepper_platform_audio_output_impl.cc +++ b/content/renderer/pepper/pepper_platform_audio_output_impl.cc @@ -15,20 +15,6 @@ namespace content { -PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl() - : client_(NULL), - stream_id_(0), - main_message_loop_proxy_(base::MessageLoopProxy::current()) { - filter_ = RenderThreadImpl::current()->audio_message_filter(); -} - -PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() { - // Make sure we have been shut down. Warning: this will usually happen on - // the I/O thread! - DCHECK_EQ(0, stream_id_); - DCHECK(!client_); -} - // static PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create( int sample_rate, @@ -75,6 +61,47 @@ void PepperPlatformAudioOutputImpl::ShutDown() { base::Bind(&PepperPlatformAudioOutputImpl::ShutDownOnIOThread, this)); } +void PepperPlatformAudioOutputImpl::OnStateChanged(AudioStreamState state) {} + +void PepperPlatformAudioOutputImpl::OnStreamCreated( + base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) { +#if defined(OS_WIN) + DCHECK(handle); + DCHECK(socket_handle); +#else + DCHECK_NE(-1, handle.fd); + DCHECK_NE(-1, socket_handle); +#endif + DCHECK(length); + + if (base::MessageLoopProxy::current() == main_message_loop_proxy_) { + // Must dereference the client only on the main thread. Shutdown may have + // occurred while the request was in-flight, so we need to NULL check. + if (client_) + client_->StreamCreated(handle, length, socket_handle); + } else { + main_message_loop_proxy_->PostTask(FROM_HERE, + base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, + handle, socket_handle, length)); + } +} + +PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() { + // Make sure we have been shut down. Warning: this will usually happen on + // the I/O thread! + DCHECK_EQ(0, stream_id_); + DCHECK(!client_); +} + +PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl() + : client_(NULL), + stream_id_(0), + main_message_loop_proxy_(base::MessageLoopProxy::current()) { + filter_ = RenderThreadImpl::current()->audio_message_filter(); +} + bool PepperPlatformAudioOutputImpl::Initialize( int sample_rate, int frames_per_buffer, @@ -136,32 +163,4 @@ void PepperPlatformAudioOutputImpl::ShutDownOnIOThread() { // PepperPluginDelegateImpl::CreateAudio. } -void PepperPlatformAudioOutputImpl::OnStateChanged(AudioStreamState state) { -} - -void PepperPlatformAudioOutputImpl::OnStreamCreated( - base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) { -#if defined(OS_WIN) - DCHECK(handle); - DCHECK(socket_handle); -#else - DCHECK_NE(-1, handle.fd); - DCHECK_NE(-1, socket_handle); -#endif - DCHECK(length); - - if (base::MessageLoopProxy::current() == main_message_loop_proxy_) { - // Must dereference the client only on the main thread. Shutdown may have - // occurred while the request was in-flight, so we need to NULL check. - if (client_) - client_->StreamCreated(handle, length, socket_handle); - } else { - main_message_loop_proxy_->PostTask(FROM_HERE, - base::Bind(&PepperPlatformAudioOutputImpl::OnStreamCreated, this, - handle, socket_handle, length)); - } -} - } // namespace content diff --git a/content/renderer/pepper/pepper_platform_audio_output_impl.h b/content/renderer/pepper/pepper_platform_audio_output_impl.h index 6ad8b80..3b426ad 100644 --- a/content/renderer/pepper/pepper_platform_audio_output_impl.h +++ b/content/renderer/pepper/pepper_platform_audio_output_impl.h @@ -25,8 +25,6 @@ class PepperPlatformAudioOutputImpl public AudioMessageFilter::Delegate, public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { public: - virtual ~PepperPlatformAudioOutputImpl(); - // Factory function, returns NULL on failure. StreamCreated() will be called // when the stream is created. static PepperPlatformAudioOutputImpl* Create( @@ -39,7 +37,18 @@ class PepperPlatformAudioOutputImpl virtual bool StopPlayback() OVERRIDE; virtual void ShutDown() OVERRIDE; + // AudioMessageFilter::Delegate. + virtual void OnStateChanged(AudioStreamState state) OVERRIDE; + virtual void OnStreamCreated(base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) OVERRIDE; + + protected: + virtual ~PepperPlatformAudioOutputImpl(); + private: + friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>; + PepperPlatformAudioOutputImpl(); bool Initialize( @@ -53,12 +62,6 @@ class PepperPlatformAudioOutputImpl void StopPlaybackOnIOThread(); void ShutDownOnIOThread(); - // AudioMessageFilter::Delegate. - virtual void OnStateChanged(AudioStreamState state) OVERRIDE; - virtual void OnStreamCreated(base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) OVERRIDE; - // The client to notify when the stream is created. THIS MUST ONLY BE // ACCESSED ON THE MAIN THREAD. webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_; diff --git a/content/renderer/pepper/pepper_platform_video_capture_impl.cc b/content/renderer/pepper/pepper_platform_video_capture_impl.cc index c688d3d..35bfd58 100644 --- a/content/renderer/pepper/pepper_platform_video_capture_impl.cc +++ b/content/renderer/pepper/pepper_platform_video_capture_impl.cc @@ -42,17 +42,6 @@ PepperPlatformVideoCaptureImpl::PepperPlatformVideoCaptureImpl( } } -PepperPlatformVideoCaptureImpl::~PepperPlatformVideoCaptureImpl() { - if (video_capture_) { - VideoCaptureImplManager* manager = - RenderThreadImpl::current()->video_capture_impl_manager(); - manager->RemoveDevice(session_id_, handler_proxy_.get()); - } - - if (plugin_delegate_ && !label_.empty()) - plugin_delegate_->CloseDevice(label_); -} - void PepperPlatformVideoCaptureImpl::StartCapture( media::VideoCapture::EventHandler* handler, const media::VideoCaptureCapability& capability) { @@ -155,6 +144,17 @@ void PepperPlatformVideoCaptureImpl::OnDeviceInfoReceived( handler_->OnDeviceInfoReceived(capture, device_info); } +PepperPlatformVideoCaptureImpl::~PepperPlatformVideoCaptureImpl() { + if (video_capture_) { + VideoCaptureImplManager* manager = + RenderThreadImpl::current()->video_capture_impl_manager(); + manager->RemoveDevice(session_id_, handler_proxy_.get()); + } + + if (plugin_delegate_ && !label_.empty()) + plugin_delegate_->CloseDevice(label_); +} + void PepperPlatformVideoCaptureImpl::Initialize() { VideoCaptureImplManager* manager = RenderThreadImpl::current()->video_capture_impl_manager(); diff --git a/content/renderer/pepper/pepper_platform_video_capture_impl.h b/content/renderer/pepper/pepper_platform_video_capture_impl.h index 02fe6ab..a4fe0df 100644 --- a/content/renderer/pepper/pepper_platform_video_capture_impl.h +++ b/content/renderer/pepper/pepper_platform_video_capture_impl.h @@ -32,7 +32,6 @@ class PepperPlatformVideoCaptureImpl const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, const std::string& device_id, webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler* handler); - virtual ~PepperPlatformVideoCaptureImpl(); // webkit::ppapi::PluginDelegate::PlatformVideoCapture implementation. virtual void StartCapture( @@ -58,6 +57,9 @@ class PepperPlatformVideoCaptureImpl VideoCapture* capture, const media::VideoCaptureParams& device_info) OVERRIDE; + protected: + virtual ~PepperPlatformVideoCaptureImpl(); + private: void Initialize(); |