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

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

Issue 9255017: Add thread safety to AudioManagerBase to protect access to the audio thread member variable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style issue Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 IPC_MESSAGE_UNHANDLED(handled = false) 270 IPC_MESSAGE_UNHANDLED(handled = false)
271 IPC_END_MESSAGE_MAP_EX() 271 IPC_END_MESSAGE_MAP_EX()
272 272
273 EXPECT_TRUE(message_is_ok); 273 EXPECT_TRUE(message_is_ok);
274 274
275 return true; 275 return true;
276 } 276 }
277 277
278 // Posts a final task to the IO message loop and waits for completion. 278 // Posts a final task to the IO message loop and waits for completion.
279 void WebRTCAudioDeviceTest::WaitForIOThreadCompletion() { 279 void WebRTCAudioDeviceTest::WaitForIOThreadCompletion() {
280 WaitForMessageLoopCompletion(ChildProcess::current()->io_message_loop()); 280 WaitForMessageLoopCompletion(
281 ChildProcess::current()->io_message_loop()->message_loop_proxy());
281 } 282 }
282 283
283 void WebRTCAudioDeviceTest::WaitForAudioManagerCompletion() { 284 void WebRTCAudioDeviceTest::WaitForAudioManagerCompletion() {
284 if (audio_manager_) 285 if (audio_manager_)
285 WaitForMessageLoopCompletion(audio_manager_->GetMessageLoop()); 286 WaitForMessageLoopCompletion(audio_manager_->GetMessageLoop());
286 } 287 }
287 288
288 void WebRTCAudioDeviceTest::WaitForMessageLoopCompletion(MessageLoop* loop) { 289 void WebRTCAudioDeviceTest::WaitForMessageLoopCompletion(
290 base::MessageLoopProxy* loop) {
289 base::WaitableEvent* event = new base::WaitableEvent(false, false); 291 base::WaitableEvent* event = new base::WaitableEvent(false, false);
290 loop->PostTask(FROM_HERE, base::Bind(&base::WaitableEvent::Signal, 292 loop->PostTask(FROM_HERE, base::Bind(&base::WaitableEvent::Signal,
291 base::Unretained(event))); 293 base::Unretained(event)));
292 if (event->TimedWait(base::TimeDelta::FromMilliseconds( 294 if (event->TimedWait(base::TimeDelta::FromMilliseconds(
293 TestTimeouts::action_max_timeout_ms()))) { 295 TestTimeouts::action_max_timeout_ms()))) {
294 delete event; 296 delete event;
295 } else { 297 } else {
296 // Don't delete the event object in case the message ever gets processed. 298 // Don't delete the event object in case the message ever gets processed.
297 // If we do, we will crash the test process. 299 // If we do, we will crash the test process.
298 ADD_FAILURE() << "Failed to wait for message loop"; 300 ADD_FAILURE() << "Failed to wait for message loop";
(...skipping 20 matching lines...) Expand all
319 WebRTCTransportImpl::~WebRTCTransportImpl() {} 321 WebRTCTransportImpl::~WebRTCTransportImpl() {}
320 322
321 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { 323 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) {
322 return network_->ReceivedRTPPacket(channel, data, len); 324 return network_->ReceivedRTPPacket(channel, data, len);
323 } 325 }
324 326
325 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, 327 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data,
326 int len) { 328 int len) {
327 return network_->ReceivedRTCPPacket(channel, data, len); 329 return network_->ReceivedRTCPPacket(channel, data, len);
328 } 330 }
OLDNEW
« no previous file with comments | « content/test/webrtc_audio_device_test.h ('k') | media/audio/audio_low_latency_input_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698