| Index: content/renderer/media/audio_renderer_impl_unittest.cc
 | 
| ===================================================================
 | 
| --- content/renderer/media/audio_renderer_impl_unittest.cc	(revision 110348)
 | 
| +++ content/renderer/media/audio_renderer_impl_unittest.cc	(working copy)
 | 
| @@ -10,7 +10,6 @@
 | 
|  #include "base/time.h"
 | 
|  #include "content/common/child_process.h"
 | 
|  #include "content/common/child_thread.h"
 | 
| -#include "content/common/media/audio_messages.h"
 | 
|  #include "content/renderer/media/audio_renderer_impl.h"
 | 
|  #include "content/renderer/mock_content_renderer_client.h"
 | 
|  #include "content/renderer/render_process.h"
 | 
| @@ -46,31 +45,13 @@
 | 
|  
 | 
|  // This class defines a set of methods which will be used in combination
 | 
|  // with NewRunnableMethod to form tasks which will be posted on the
 | 
| -// IO thread. All methods emulate AudioMessageFilter::Delegate calls.
 | 
| +// IO thread. This emulates MessageLoop::DestructionObserver.
 | 
|  class DelegateCaller : public base::RefCountedThreadSafe<DelegateCaller> {
 | 
|   public:
 | 
|    explicit DelegateCaller(AudioRendererImpl* renderer)
 | 
|        : renderer_(renderer) {}
 | 
|  
 | 
| -  void OnCreated(base::SharedMemoryHandle handle, uint32 length) {
 | 
| -    if (renderer_->latency_type() == AudioRendererImpl::kHighLatency) {
 | 
| -      renderer_->OnCreated(handle, length);
 | 
| -    } else {
 | 
| -      renderer_->OnLowLatencyCreated(handle, 0, length);
 | 
| -    }
 | 
| -  }
 | 
| -  void OnStateChanged(AudioStreamState state) {
 | 
| -    renderer_->OnStateChanged(state);
 | 
| -  }
 | 
| -  void OnRequestPacket(AudioBuffersState buffers_state) {
 | 
| -    renderer_->OnRequestPacket(buffers_state);
 | 
| -  }
 | 
| -  void OnVolume(double volume) {
 | 
| -    renderer_->OnVolume(volume);
 | 
| -  }
 | 
| -  void DestroyCurrentMessageLoop() {
 | 
| -    renderer_->WillDestroyCurrentMessageLoop();
 | 
| -  }
 | 
| +  void DestroyCurrentMessageLoop() {}
 | 
|   private:
 | 
|    friend class base::RefCountedThreadSafe<DelegateCaller>;
 | 
|    virtual ~DelegateCaller() {}
 | 
| @@ -96,31 +77,19 @@
 | 
|    DISALLOW_COPY_AND_ASSIGN(WaitTask);
 | 
|  };
 | 
|  
 | 
| -// Class we would be testing. The only difference between it and "real" one
 | 
| -// is that test class does not open sockets and launch audio thread.
 | 
| +// Class we would be testing.
 | 
|  class TestAudioRendererImpl : public AudioRendererImpl {
 | 
|   public:
 | 
|    explicit TestAudioRendererImpl()
 | 
|        : AudioRendererImpl() {
 | 
|    }
 | 
| - private:
 | 
| -  virtual void CreateSocket(base::SyncSocket::Handle socket_handle) {}
 | 
| -  virtual void CreateAudioThread() {}
 | 
|  };
 | 
|  
 | 
|  class AudioRendererImplTest
 | 
|      : public ::testing::Test,
 | 
|        public IPC::Channel::Listener {
 | 
|   public:
 | 
| -  static void SetUpTestCase() {
 | 
| -    // Set low latency mode, as it soon would be on by default.
 | 
| -    if (AudioRendererImpl::latency_type() ==
 | 
| -        AudioRendererImpl::kUninitializedLatency) {
 | 
| -      AudioRendererImpl::set_latency_type(AudioRendererImpl::kLowLatency);
 | 
| -    }
 | 
| -    DCHECK_EQ(AudioRendererImpl::kLowLatency,
 | 
| -              AudioRendererImpl::latency_type());
 | 
| -  }
 | 
| +  static void SetUpTestCase() {}
 | 
|  
 | 
|    // IPC::Channel::Listener implementation.
 | 
|    virtual bool OnMessageReceived(const IPC::Message& message) {
 | 
| @@ -149,9 +118,6 @@
 | 
|      render_thread_ = new RenderThreadImpl(kThreadName);
 | 
|      mock_process_->set_main_thread(render_thread_);
 | 
|  
 | 
| -    // Create temporary shared memory.
 | 
| -    CHECK(shared_mem_.CreateAnonymous(kSize));
 | 
| -
 | 
|      // Setup expectations for initialization.
 | 
|      decoder_ = new media::MockAudioDecoder();
 | 
|  
 | 
| @@ -164,7 +130,6 @@
 | 
|  
 | 
|      // Create and initialize the audio renderer.
 | 
|      renderer_ = new TestAudioRendererImpl();
 | 
| -    renderer_->set_host(&host_);
 | 
|      renderer_->Initialize(decoder_, media::NewExpectedClosure(),
 | 
|                            NewUnderflowClosure());
 | 
|  
 | 
| @@ -174,20 +139,6 @@
 | 
|      // We need an event to verify that all tasks are done before leaving
 | 
|      // our tests.
 | 
|      event_.reset(new base::WaitableEvent(false, false));
 | 
| -
 | 
| -    // Duplicate the shared memory handle so both the test and the callee can
 | 
| -    // close their copy.
 | 
| -    base::SharedMemoryHandle duplicated_handle;
 | 
| -    EXPECT_TRUE(shared_mem_.ShareToProcess(base::GetCurrentProcessHandle(),
 | 
| -      &duplicated_handle));
 | 
| -
 | 
| -    // Set things up and ensure that the call comes from the IO thread
 | 
| -    // as all AudioMessageFilter::Delegate methods.
 | 
| -    ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -        FROM_HERE,
 | 
| -        base::Bind(&DelegateCaller::OnCreated, delegate_caller_.get(),
 | 
| -                   duplicated_handle, kSize));
 | 
| -    WaitForIOThreadCompletion();
 | 
|    }
 | 
|  
 | 
|    virtual void TearDown() {
 | 
| @@ -215,8 +166,6 @@
 | 
|    scoped_ptr<IPC::Channel> channel_;
 | 
|    RenderThreadImpl* render_thread_;  // owned by mock_process_
 | 
|    scoped_ptr<MockRenderProcess> mock_process_;
 | 
| -  base::SharedMemory shared_mem_;
 | 
| -  media::MockFilterHost host_;
 | 
|    scoped_refptr<media::MockAudioDecoder> decoder_;
 | 
|    scoped_refptr<AudioRendererImpl> renderer_;
 | 
|    scoped_ptr<base::WaitableEvent> event_;
 | 
| @@ -256,37 +205,6 @@
 | 
|    // Tasks will be posted internally on the IO thread.
 | 
|    renderer_->Stop(media::NewExpectedClosure());
 | 
|  
 | 
| -  // Run AudioMessageFilter::Delegate methods, which can be executed after being
 | 
| -  // stopped. AudioRendererImpl shouldn't create any messages in this state.
 | 
| -  // All delegate method calls are posted on the IO thread since it is
 | 
| -  // a requirement.
 | 
| -  if (renderer_->latency_type() == AudioRendererImpl::kHighLatency) {
 | 
| -    ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -        FROM_HERE,
 | 
| -        base::Bind(&DelegateCaller::OnRequestPacket,
 | 
| -                   delegate_caller_.get(), AudioBuffersState(kSize, 0)));
 | 
| -  }
 | 
| -  ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -      FROM_HERE,
 | 
| -      base::Bind(&DelegateCaller::OnStateChanged,
 | 
| -                 delegate_caller_.get(), kAudioStreamError));
 | 
| -  ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -      FROM_HERE,
 | 
| -      base::Bind(&DelegateCaller::OnStateChanged,
 | 
| -                 delegate_caller_.get(), kAudioStreamPlaying));
 | 
| -  ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -      FROM_HERE,
 | 
| -      base::Bind(&DelegateCaller::OnStateChanged,
 | 
| -                 delegate_caller_.get(), kAudioStreamPaused));
 | 
| -  ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -      FROM_HERE,
 | 
| -      base::Bind(&DelegateCaller::OnCreated,
 | 
| -                 delegate_caller_.get(), shared_mem_.handle(), kSize));
 | 
| -  ChildProcess::current()->io_message_loop()->PostTask(
 | 
| -      FROM_HERE,
 | 
| -      base::Bind(&DelegateCaller::OnVolume,
 | 
| -                 delegate_caller_.get(), 0.5));
 | 
| -
 | 
|    WaitForIOThreadCompletion();
 | 
|  
 | 
|    // It's possible that the upstream decoder replies right after being stopped.
 | 
| 
 |