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

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

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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
« no previous file with comments | « content/test/webrtc_audio_device_test.h ('k') | content/utility/utility_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return test_request_context_; 110 return test_request_context_;
111 } 111 }
112 112
113 private: 113 private:
114 net::URLRequestContext* test_request_context_; 114 net::URLRequestContext* test_request_context_;
115 115
116 DISALLOW_COPY_AND_ASSIGN(MockRTCResourceContext); 116 DISALLOW_COPY_AND_ASSIGN(MockRTCResourceContext);
117 }; 117 };
118 118
119 ACTION_P(QuitMessageLoop, loop_or_proxy) { 119 ACTION_P(QuitMessageLoop, loop_or_proxy) {
120 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 120 loop_or_proxy->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
121 } 121 }
122 122
123 WebRTCAudioDeviceTest::WebRTCAudioDeviceTest() 123 WebRTCAudioDeviceTest::WebRTCAudioDeviceTest()
124 : render_thread_(NULL), audio_hardware_config_(NULL), 124 : render_thread_(NULL), audio_hardware_config_(NULL),
125 has_input_devices_(false), has_output_devices_(false) { 125 has_input_devices_(false), has_output_devices_(false) {
126 } 126 }
127 127
128 WebRTCAudioDeviceTest::~WebRTCAudioDeviceTest() {} 128 WebRTCAudioDeviceTest::~WebRTCAudioDeviceTest() {}
129 129
130 void WebRTCAudioDeviceTest::SetUp() { 130 void WebRTCAudioDeviceTest::SetUp() {
131 // This part sets up a RenderThread environment to ensure that 131 // This part sets up a RenderThread environment to ensure that
132 // RenderThread::current() (<=> TLS pointer) is valid. 132 // RenderThread::current() (<=> TLS pointer) is valid.
133 // Main parts are inspired by the RenderViewFakeResourcesTest. 133 // Main parts are inspired by the RenderViewFakeResourcesTest.
134 // Note that, the IPC part is not utilized in this test. 134 // Note that, the IPC part is not utilized in this test.
135 saved_content_renderer_.reset( 135 saved_content_renderer_.reset(
136 new ReplaceContentClientRenderer(&content_renderer_client_)); 136 new ReplaceContentClientRenderer(&content_renderer_client_));
137 mock_process_.reset(new WebRTCMockRenderProcess()); 137 mock_process_.reset(new WebRTCMockRenderProcess());
138 ui_thread_.reset(new TestBrowserThread(BrowserThread::UI, 138 ui_thread_.reset(
139 MessageLoop::current())); 139 new TestBrowserThread(BrowserThread::UI, base::MessageLoop::current()));
140 140
141 // Construct the resource context on the UI thread. 141 // Construct the resource context on the UI thread.
142 resource_context_.reset(new MockRTCResourceContext); 142 resource_context_.reset(new MockRTCResourceContext);
143 143
144 static const char kThreadName[] = "RenderThread"; 144 static const char kThreadName[] = "RenderThread";
145 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, 145 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
146 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread, 146 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread,
147 base::Unretained(this), kThreadName)); 147 base::Unretained(this), kThreadName));
148 WaitForIOThreadCompletion(); 148 WaitForIOThreadCompletion();
149 149
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 196
197 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) { 197 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) {
198 #if defined(OS_WIN) 198 #if defined(OS_WIN)
199 // We initialize COM (STA) on our IO thread as is done in Chrome. 199 // We initialize COM (STA) on our IO thread as is done in Chrome.
200 // See BrowserProcessSubThread::Init. 200 // See BrowserProcessSubThread::Init.
201 initialize_com_.reset(new base::win::ScopedCOMInitializer()); 201 initialize_com_.reset(new base::win::ScopedCOMInitializer());
202 #endif 202 #endif
203 203
204 // Set the current thread as the IO thread. 204 // Set the current thread as the IO thread.
205 io_thread_.reset(new TestBrowserThread(BrowserThread::IO, 205 io_thread_.reset(
206 MessageLoop::current())); 206 new TestBrowserThread(BrowserThread::IO, base::MessageLoop::current()));
207 207
208 // Populate our resource context. 208 // Populate our resource context.
209 test_request_context_.reset(new net::TestURLRequestContext()); 209 test_request_context_.reset(new net::TestURLRequestContext());
210 MockRTCResourceContext* resource_context = 210 MockRTCResourceContext* resource_context =
211 static_cast<MockRTCResourceContext*>(resource_context_.get()); 211 static_cast<MockRTCResourceContext*>(resource_context_.get());
212 resource_context->set_request_context(test_request_context_.get()); 212 resource_context->set_request_context(test_request_context_.get());
213 media_internals_.reset(new MockMediaInternals()); 213 media_internals_.reset(new MockMediaInternals());
214 214
215 // Create our own AudioManager, AudioMirroringManager and MediaStreamManager. 215 // Create our own AudioManager, AudioMirroringManager and MediaStreamManager.
216 audio_manager_.reset(media::AudioManager::Create()); 216 audio_manager_.reset(media::AudioManager::Create());
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { 357 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) {
358 return network_->ReceivedRTPPacket(channel, data, len); 358 return network_->ReceivedRTPPacket(channel, data, len);
359 } 359 }
360 360
361 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, 361 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data,
362 int len) { 362 int len) {
363 return network_->ReceivedRTCPPacket(channel, data, len); 363 return network_->ReceivedRTCPPacket(channel, data, len);
364 } 364 }
365 365
366 } // namespace content 366 } // namespace content
OLDNEW
« no previous file with comments | « content/test/webrtc_audio_device_test.h ('k') | content/utility/utility_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698