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

Side by Side Diff: content/test/webrtc_audio_device_test.cc

Issue 10990079: Clean up scoped_com_initializer.h. Remove #ifdefs for non-Windows (this is in base/win, no one sho… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/test/webrtc_audio_device_test.h" 5 #include "content/test/webrtc_audio_device_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/win/scoped_com_initializer.h"
15 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 14 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
16 #include "content/browser/renderer_host/media/audio_renderer_host.h" 15 #include "content/browser/renderer_host/media/audio_renderer_host.h"
17 #include "content/browser/renderer_host/media/media_stream_manager.h" 16 #include "content/browser/renderer_host/media/media_stream_manager.h"
18 #include "content/browser/renderer_host/media/mock_media_observer.h" 17 #include "content/browser/renderer_host/media/mock_media_observer.h"
19 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/content_paths.h" 20 #include "content/public/common/content_paths.h"
22 #include "content/public/test/mock_resource_context.h" 21 #include "content/public/test/mock_resource_context.h"
23 #include "content/public/test/test_browser_thread.h" 22 #include "content/public/test/test_browser_thread.h"
24 #include "content/renderer/media/audio_device_factory.h" 23 #include "content/renderer/media/audio_device_factory.h"
25 #include "content/renderer/media/audio_hardware.h" 24 #include "content/renderer/media/audio_hardware.h"
26 #include "content/renderer/media/audio_input_message_filter.h" 25 #include "content/renderer/media/audio_input_message_filter.h"
27 #include "content/renderer/media/audio_message_filter.h" 26 #include "content/renderer/media/audio_message_filter.h"
28 #include "content/renderer/media/webrtc_audio_device_impl.h" 27 #include "content/renderer/media/webrtc_audio_device_impl.h"
29 #include "content/renderer/render_process.h" 28 #include "content/renderer/render_process.h"
30 #include "content/renderer/render_thread_impl.h" 29 #include "content/renderer/render_thread_impl.h"
31 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 30 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
32 #include "net/url_request/url_request_test_util.h" 31 #include "net/url_request/url_request_test_util.h"
33 #include "testing/gmock/include/gmock/gmock.h" 32 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
35 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" 34 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h"
36 #include "third_party/webrtc/voice_engine/include/voe_base.h" 35 #include "third_party/webrtc/voice_engine/include/voe_base.h"
37 #include "third_party/webrtc/voice_engine/include/voe_file.h" 36 #include "third_party/webrtc/voice_engine/include/voe_file.h"
38 #include "third_party/webrtc/voice_engine/include/voe_network.h" 37 #include "third_party/webrtc/voice_engine/include/voe_network.h"
39 38
40 using base::win::ScopedCOMInitializer; 39 #if defined(OS_WIN)
40 #include "base/win/scoped_com_initializer.h"
41 #endif
42
41 using testing::_; 43 using testing::_;
42 using testing::InvokeWithoutArgs; 44 using testing::InvokeWithoutArgs;
43 using testing::Return; 45 using testing::Return;
44 using testing::StrEq; 46 using testing::StrEq;
45 47
46 // This class is a mock of the child process singleton which is needed 48 // This class is a mock of the child process singleton which is needed
47 // to be able to create a RenderThread object. 49 // to be able to create a RenderThread object.
48 class WebRTCMockRenderProcess : public RenderProcess { 50 class WebRTCMockRenderProcess : public RenderProcess {
49 public: 51 public:
50 WebRTCMockRenderProcess() {} 52 WebRTCMockRenderProcess() {}
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 191 }
190 192
191 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) { 193 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) {
192 // Invalidate any potentially cached values since the new callback should 194 // Invalidate any potentially cached values since the new callback should
193 // be used for those queries. 195 // be used for those queries.
194 audio_hardware::ResetCache(); 196 audio_hardware::ResetCache();
195 audio_util_callback_ = callback; 197 audio_util_callback_ = callback;
196 } 198 }
197 199
198 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) { 200 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) {
201 #if defined(OS_WIN)
199 // We initialize COM (STA) on our IO thread as is done in Chrome. 202 // We initialize COM (STA) on our IO thread as is done in Chrome.
200 // See BrowserProcessSubThread::Init. 203 // See BrowserProcessSubThread::Init.
201 initialize_com_.reset(new ScopedCOMInitializer()); 204 initialize_com_.reset(new base::win::ScopedCOMInitializer());
205 #endif
202 206
203 // Set the current thread as the IO thread. 207 // Set the current thread as the IO thread.
204 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO, 208 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO,
205 MessageLoop::current())); 209 MessageLoop::current()));
206 210
207 // Populate our resource context. 211 // Populate our resource context.
208 test_request_context_.reset(new TestURLRequestContext()); 212 test_request_context_.reset(new TestURLRequestContext());
209 MockResourceContext* resource_context = 213 MockResourceContext* resource_context =
210 static_cast<MockResourceContext*>(resource_context_.get()); 214 static_cast<MockResourceContext*>(resource_context_.get());
211 resource_context->set_request_context(test_request_context_.get()); 215 resource_context->set_request_context(test_request_context_.get());
212 media_observer_.reset(new MockMediaObserver()); 216 media_observer_.reset(new MockMediaObserver());
213 217
214 has_input_devices_ = audio_manager_->HasAudioInputDevices(); 218 has_input_devices_ = audio_manager_->HasAudioInputDevices();
215 has_output_devices_ = audio_manager_->HasAudioOutputDevices(); 219 has_output_devices_ = audio_manager_->HasAudioOutputDevices();
216 220
217 // Create an IPC channel that handles incoming messages on the IO thread. 221 // Create an IPC channel that handles incoming messages on the IO thread.
218 CreateChannel(thread_name); 222 CreateChannel(thread_name);
219 } 223 }
220 224
221 void WebRTCAudioDeviceTest::UninitializeIOThread() { 225 void WebRTCAudioDeviceTest::UninitializeIOThread() {
222 resource_context_.reset(); 226 resource_context_.reset();
223 227
224 test_request_context_.reset(); 228 test_request_context_.reset();
229
230 #if defined(OS_WIN)
225 initialize_com_.reset(); 231 initialize_com_.reset();
232 #endif
226 } 233 }
227 234
228 void WebRTCAudioDeviceTest::CreateChannel(const char* name) { 235 void WebRTCAudioDeviceTest::CreateChannel(const char* name) {
229 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 236 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
230 audio_render_host_ = new AudioRendererHost( 237 audio_render_host_ = new AudioRendererHost(
231 audio_manager_.get(), media_observer_.get()); 238 audio_manager_.get(), media_observer_.get());
232 audio_render_host_->OnChannelConnected(base::GetCurrentProcId()); 239 audio_render_host_->OnChannelConnected(base::GetCurrentProcId());
233 240
234 audio_input_renderer_host_ = new AudioInputRendererHost( 241 audio_input_renderer_host_ = new AudioInputRendererHost(
235 audio_manager_.get(), media_stream_manager_.get()); 242 audio_manager_.get(), media_stream_manager_.get());
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 WebRTCTransportImpl::~WebRTCTransportImpl() {} 368 WebRTCTransportImpl::~WebRTCTransportImpl() {}
362 369
363 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { 370 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) {
364 return network_->ReceivedRTPPacket(channel, data, len); 371 return network_->ReceivedRTPPacket(channel, data, len);
365 } 372 }
366 373
367 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, 374 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data,
368 int len) { 375 int len) {
369 return network_->ReceivedRTCPPacket(channel, data, len); 376 return network_->ReceivedRTCPPacket(channel, data, len);
370 } 377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698