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

Unified Diff: content/renderer/pepper/pepper_platform_audio_input_impl.cc

Issue 10071038: RefCounted types should not have public destructors, content/browser part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright bump Created 8 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
Index: content/renderer/pepper/pepper_platform_audio_input_impl.cc
diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.cc b/content/renderer/pepper/pepper_platform_audio_input_impl.cc
index c69d562ecd0e7a76dc3055e84a6e225641eda4e8..effcf2acd112ca650d646ddf510556275ca16739 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) {

Powered by Google App Engine
This is Rietveld 408576698