Commit 3a66ca5c authored by Max Morin's avatar Max Morin Committed by Commit Bot

Use ScopedCallbackRunner in MojoAudioOutputIPC.

We now have a shiny new toy, which simplifies the code a bit.

BUG=None

Change-Id: I1ffc10027238762364eae99f743a194159a99d8d
Reviewed-on: https://chromium-review.googlesource.com/568027
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486016}
parent 45aacc7e
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <utility> #include <utility>
#include "media/audio/audio_device_description.h" #include "media/audio/audio_device_description.h"
#include "media/base/scoped_callback_runner.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
namespace content { namespace content {
...@@ -44,22 +45,17 @@ void MojoAudioOutputIPC::RequestDeviceAuthorization( ...@@ -44,22 +45,17 @@ void MojoAudioOutputIPC::RequestDeviceAuthorization(
DCHECK(!StreamCreationRequested()); DCHECK(!StreamCreationRequested());
delegate_ = delegate; delegate_ = delegate;
// We pass in a ScopedClosureRunner to detect the case when the mojo // We wrap the callback in a ScopedCallbackRunner to detect the case when the
// connection is terminated prior to receiving the response. In this case, // mojo connection is terminated prior to receiving the response. In this
// the closure runner will be destructed and call ReceivedDeviceAuthorization // case, the callback runner will be destructed and call
// with an error. // ReceivedDeviceAuthorization with an error.
DoRequestDeviceAuthorization( DoRequestDeviceAuthorization(
session_id, device_id, session_id, device_id,
base::BindOnce( media::ScopedCallbackRunner(
&MojoAudioOutputIPC::ReceivedDeviceAuthorization, base::BindOnce(&MojoAudioOutputIPC::ReceivedDeviceAuthorization,
weak_factory_.GetWeakPtr(), weak_factory_.GetWeakPtr()),
base::ScopedClosureRunner(base::Bind( media::OutputDeviceStatus::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL,
&MojoAudioOutputIPC::ReceivedDeviceAuthorization, media::AudioParameters::UnavailableDeviceParams(), std::string()));
weak_factory_.GetWeakPtr(),
base::Passed(base::ScopedClosureRunner()),
media::OutputDeviceStatus::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL,
media::AudioParameters::UnavailableDeviceParams(),
std::string()))));
} }
void MojoAudioOutputIPC::CreateStream(media::AudioOutputIPCDelegate* delegate, void MojoAudioOutputIPC::CreateStream(media::AudioOutputIPCDelegate* delegate,
...@@ -167,13 +163,11 @@ bool MojoAudioOutputIPC::DoRequestDeviceAuthorization( ...@@ -167,13 +163,11 @@ bool MojoAudioOutputIPC::DoRequestDeviceAuthorization(
} }
void MojoAudioOutputIPC::ReceivedDeviceAuthorization( void MojoAudioOutputIPC::ReceivedDeviceAuthorization(
base::ScopedClosureRunner fallback_closure,
media::OutputDeviceStatus status, media::OutputDeviceStatus status,
const media::AudioParameters& params, const media::AudioParameters& params,
const std::string& device_id) const { const std::string& device_id) const {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(delegate_); DCHECK(delegate_);
ignore_result(fallback_closure.Release());
delegate_->OnDeviceAuthorized(status, params, device_id); delegate_->OnDeviceAuthorized(status, params, device_id);
} }
......
...@@ -58,8 +58,7 @@ class CONTENT_EXPORT MojoAudioOutputIPC : public media::AudioOutputIPC { ...@@ -58,8 +58,7 @@ class CONTENT_EXPORT MojoAudioOutputIPC : public media::AudioOutputIPC {
const std::string& device_id, const std::string& device_id,
AuthorizationCB callback); AuthorizationCB callback);
void ReceivedDeviceAuthorization(base::ScopedClosureRunner fallback_closure, void ReceivedDeviceAuthorization(media::OutputDeviceStatus status,
media::OutputDeviceStatus status,
const media::AudioParameters& params, const media::AudioParameters& params,
const std::string& device_id) const; const std::string& device_id) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment