Chromium Code Reviews| Index: content/renderer/pepper/pepper_audio_input_host.cc |
| diff --git a/content/renderer/pepper/pepper_audio_input_host.cc b/content/renderer/pepper/pepper_audio_input_host.cc |
| index 19aa2b1b285ffe9835c4ce1b994915de413d3248..cc5052294882c0289e937ae4f9d1bfa94d1905e2 100644 |
| --- a/content/renderer/pepper/pepper_audio_input_host.cc |
| +++ b/content/renderer/pepper/pepper_audio_input_host.cc |
| @@ -45,6 +45,7 @@ PepperAudioInputHost::PepperAudioInputHost( |
| PP_Resource resource) |
| : ResourceHost(host->GetPpapiHost(), instance, resource), |
| renderer_ppapi_host_(host), |
| + open_pending_(false), |
| audio_input_(NULL), |
| enumeration_helper_( |
| this, |
| @@ -92,7 +93,7 @@ int32_t PepperAudioInputHost::OnOpen( |
| const std::string& device_id, |
| PP_AudioSampleRate sample_rate, |
| uint32_t sample_frame_count) { |
| - if (open_context_) |
| + if (open_pending_) |
| return PP_ERROR_INPROGRESS; |
| if (audio_input_) |
| return PP_ERROR_FAILED; |
| @@ -112,8 +113,8 @@ int32_t PepperAudioInputHost::OnOpen( |
| static_cast<int>(sample_rate), |
| static_cast<int>(sample_frame_count), this); |
| if (audio_input_) { |
| - open_context_.reset(new ppapi::host::ReplyMessageContext( |
| - context->MakeReplyMessageContext())); |
| + open_context_ = context->MakeReplyMessageContext(); |
| + open_pending_ = true; |
| return PP_OK_COMPLETIONPENDING; |
| } else { |
| return PP_ERROR_FAILED; |
| @@ -147,7 +148,7 @@ void PepperAudioInputHost::OnOpenComplete( |
| base::SyncSocket scoped_socket(socket_handle); |
| base::SharedMemory scoped_shared_memory(shared_memory_handle, false); |
| - if (!open_context_) { |
| + if (!open_pending_) { |
| NOTREACHED(); |
| return; |
| } |
| @@ -173,12 +174,9 @@ void PepperAudioInputHost::OnOpenComplete( |
| // inconvenient to clean up. Our IPC code will automatically handle this for |
| // us, as long as the remote side always closes the handles it receives, even |
| // in the failure case. |
| - open_context_->params.set_result(result); |
| - open_context_->params.AppendHandle(serialized_socket_handle); |
| - open_context_->params.AppendHandle(serialized_shared_memory_handle); |
| - |
| - host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
| - open_context_.reset(); |
| + open_context_.params.AppendHandle(serialized_socket_handle); |
| + open_context_.params.AppendHandle(serialized_shared_memory_handle); |
|
dmichael (off chromium)
2014/04/11 18:11:23
What about adding an is_valid to the ReplyMessageC
bbudge
2014/04/11 20:41:19
I thought about this. I think it's a great idea so
|
| + SendOpenReply(result); |
| } |
| int32_t PepperAudioInputHost::GetRemoteHandles( |
| @@ -206,11 +204,15 @@ void PepperAudioInputHost::Close() { |
| audio_input_->ShutDown(); |
| audio_input_ = NULL; |
| - if (open_context_) { |
| - open_context_->params.set_result(PP_ERROR_ABORTED); |
| - host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
| - open_context_.reset(); |
| - } |
| + if (open_pending_) |
| + SendOpenReply(PP_ERROR_ABORTED); |
| +} |
| + |
| +void PepperAudioInputHost::SendOpenReply(int32_t result) { |
| + open_context_.params.set_result(result); |
| + host()->SendReply(open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
| + open_context_ = ppapi::host::ReplyMessageContext(); |
| + open_pending_ = false; |
| } |
| } // namespace content |