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

Side by Side Diff: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc

Issue 8872030: Removing MessageLoop::QuitTask() from content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix escaping Created 9 years 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/mock_resource_context.h" 10 #include "content/browser/mock_resource_context.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // These handler methods do minimal things and delegate to the mock methods. 97 // These handler methods do minimal things and delegate to the mock methods.
98 void OnStreamGenerated( 98 void OnStreamGenerated(
99 const IPC::Message& msg, 99 const IPC::Message& msg,
100 int request_id, 100 int request_id,
101 std::string label, 101 std::string label,
102 StreamDeviceInfoArray audio_device_list, 102 StreamDeviceInfoArray audio_device_list,
103 StreamDeviceInfoArray video_device_list) { 103 StreamDeviceInfoArray video_device_list) {
104 OnStreamGenerated(msg.routing_id(), request_id, audio_device_list.size(), 104 OnStreamGenerated(msg.routing_id(), request_id, audio_device_list.size(),
105 video_device_list.size()); 105 video_device_list.size());
106 // Notify that the event have occured. 106 // Notify that the event have occured.
107 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 107 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
108 label_ = label; 108 label_ = label;
109 audio_devices_ = audio_device_list; 109 audio_devices_ = audio_device_list;
110 video_devices_ = video_device_list; 110 video_devices_ = video_device_list;
111 } 111 }
112 112
113 void OnStreamGenerationFailed(const IPC::Message& msg, int request_id) { 113 void OnStreamGenerationFailed(const IPC::Message& msg, int request_id) {
114 OnStreamGenerationFailed(msg.routing_id(), request_id); 114 OnStreamGenerationFailed(msg.routing_id(), request_id);
115 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 115 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
116 label_= ""; 116 label_= "";
117 } 117 }
118 118
119 void OnAudioDeviceFailed(const IPC::Message& msg, 119 void OnAudioDeviceFailed(const IPC::Message& msg,
120 std::string label, 120 std::string label,
121 int index) { 121 int index) {
122 OnAudioDeviceFailed(msg.routing_id(), index); 122 OnAudioDeviceFailed(msg.routing_id(), index);
123 audio_devices_.erase(audio_devices_.begin() + index); 123 audio_devices_.erase(audio_devices_.begin() + index);
124 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 124 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
125 } 125 }
126 126
127 void OnVideoDeviceFailed(const IPC::Message& msg, 127 void OnVideoDeviceFailed(const IPC::Message& msg,
128 std::string label, 128 std::string label,
129 int index) { 129 int index) {
130 OnVideoDeviceFailed(msg.routing_id(), index); 130 OnVideoDeviceFailed(msg.routing_id(), index);
131 video_devices_.erase(video_devices_.begin() + index); 131 video_devices_.erase(video_devices_.begin() + index);
132 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 132 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
133 } 133 }
134 134
135 MessageLoop* message_loop_; 135 MessageLoop* message_loop_;
136 }; 136 };
137 137
138 class MediaStreamDispatcherHostTest : public testing::Test { 138 class MediaStreamDispatcherHostTest : public testing::Test {
139 public: 139 public:
140 void WaitForResult() { 140 void WaitForResult() {
141 message_loop_->Run(); 141 message_loop_->Run();
142 } 142 }
(...skipping 22 matching lines...) Expand all
165 165
166 virtual void TearDown() { 166 virtual void TearDown() {
167 content::MockResourceContext::GetInstance()->set_media_stream_manager(NULL); 167 content::MockResourceContext::GetInstance()->set_media_stream_manager(NULL);
168 168
169 // Needed to make sure the manager finishes all tasks on its own thread. 169 // Needed to make sure the manager finishes all tasks on its own thread.
170 SyncWithVideoCaptureManagerThread(); 170 SyncWithVideoCaptureManagerThread();
171 } 171 }
172 172
173 // Called on the VideoCaptureManager thread. 173 // Called on the VideoCaptureManager thread.
174 static void PostQuitMessageLoop(MessageLoop* message_loop) { 174 static void PostQuitMessageLoop(MessageLoop* message_loop) {
175 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 175 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
176 } 176 }
177 177
178 // Called on the main thread. 178 // Called on the main thread.
179 static void PostQuitOnVideoCaptureManagerThread( 179 static void PostQuitOnVideoCaptureManagerThread(
180 MessageLoop* message_loop, 180 MessageLoop* message_loop,
181 media_stream::MediaStreamManager* media_stream_manager) { 181 media_stream::MediaStreamManager* media_stream_manager) {
182 media_stream_manager->video_capture_manager()->GetMessageLoop()-> 182 media_stream_manager->video_capture_manager()->GetMessageLoop()->
183 PostTask(FROM_HERE, 183 PostTask(FROM_HERE,
184 base::Bind(&PostQuitMessageLoop, message_loop)); 184 base::Bind(&PostQuitMessageLoop, message_loop));
185 } 185 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 EXPECT_EQ(host_->video_devices_.size(), 0u); 305 EXPECT_EQ(host_->video_devices_.size(), 0u);
306 EXPECT_EQ(host_->NumberOfStreams(), 1u); 306 EXPECT_EQ(host_->NumberOfStreams(), 1u);
307 307
308 // TODO(perkj): test audio device failure? 308 // TODO(perkj): test audio device failure?
309 309
310 host_->OnStopGeneratedStream(label); 310 host_->OnStopGeneratedStream(label);
311 EXPECT_EQ(host_->NumberOfStreams(), 0u); 311 EXPECT_EQ(host_->NumberOfStreams(), 0u);
312 } 312 }
313 313
314 }; // namespace media_stream 314 }; // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698