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

Side by Side Diff: components/test_runner/mock_web_user_media_client.cc

Issue 2357043003: Remove WebCallbackTask (Closed)
Patch Set: remove WebTaskRunner::postTask(base::Closure). git cl format Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/test_runner/mock_web_user_media_client.h" 5 #include "components/test_runner/mock_web_user_media_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/test_runner/web_task.h"
14 #include "components/test_runner/web_test_delegate.h" 13 #include "components/test_runner/web_test_delegate.h"
15 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
16 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" 15 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
17 #include "third_party/WebKit/public/platform/WebMediaStream.h" 16 #include "third_party/WebKit/public/platform/WebMediaStream.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
20 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h " 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h "
21 #include "third_party/WebKit/public/platform/WebSourceInfo.h" 20 #include "third_party/WebKit/public/platform/WebSourceInfo.h"
22 #include "third_party/WebKit/public/platform/WebVector.h" 21 #include "third_party/WebKit/public/platform/WebVector.h"
23 #include "third_party/WebKit/public/web/WebDocument.h" 22 #include "third_party/WebKit/public/web/WebDocument.h"
(...skipping 23 matching lines...) Expand all
47 weak_factory_(this) {} 46 weak_factory_(this) {}
48 47
49 MockWebUserMediaClient::~MockWebUserMediaClient() {} 48 MockWebUserMediaClient::~MockWebUserMediaClient() {}
50 49
51 void MockWebUserMediaClient::requestUserMedia( 50 void MockWebUserMediaClient::requestUserMedia(
52 const WebUserMediaRequest& stream_request) { 51 const WebUserMediaRequest& stream_request) {
53 DCHECK(!stream_request.isNull()); 52 DCHECK(!stream_request.isNull());
54 WebUserMediaRequest request = stream_request; 53 WebUserMediaRequest request = stream_request;
55 54
56 if (request.ownerDocument().isNull() || !request.ownerDocument().frame()) { 55 if (request.ownerDocument().isNull() || !request.ownerDocument().frame()) {
57 delegate_->PostTask(new WebCallbackTask(base::Bind( 56 delegate_->PostTask(base::Bind(
58 &WebUserMediaRequest::requestFailed, 57 &WebUserMediaRequest::requestFailed,
59 base::Owned(new WebUserMediaRequest(request)), WebString()))); 58 base::Owned(new WebUserMediaRequest(request)), WebString()));
60 return; 59 return;
61 } 60 }
62 61
63 WebMediaStream stream; 62 WebMediaStream stream;
64 stream.initialize(WebVector<WebMediaStreamTrack>(), 63 stream.initialize(WebVector<WebMediaStreamTrack>(),
65 WebVector<WebMediaStreamTrack>()); 64 WebVector<WebMediaStreamTrack>());
66 stream.setExtraData(new MockExtraData()); 65 stream.setExtraData(new MockExtraData());
67 66
68 if (request.audio() && 67 if (request.audio() &&
69 !delegate_->AddMediaStreamAudioSourceAndTrack(&stream)) { 68 !delegate_->AddMediaStreamAudioSourceAndTrack(&stream)) {
(...skipping 12 matching lines...) Expand all
82 WebMediaStreamSource source; 81 WebMediaStreamSource source;
83 source.initialize("MockVideoDevice#1", 82 source.initialize("MockVideoDevice#1",
84 WebMediaStreamSource::TypeVideo, 83 WebMediaStreamSource::TypeVideo,
85 "Mock video device", 84 "Mock video device",
86 false /* remote */); 85 false /* remote */);
87 WebMediaStreamTrack web_track; 86 WebMediaStreamTrack web_track;
88 web_track.initialize(source); 87 web_track.initialize(source);
89 stream.addTrack(web_track); 88 stream.addTrack(web_track);
90 } 89 }
91 90
92 delegate_->PostTask(new WebCallbackTask( 91 delegate_->PostTask(
93 base::Bind(&WebUserMediaRequest::requestSucceeded, 92 base::Bind(&WebUserMediaRequest::requestSucceeded,
94 base::Owned(new WebUserMediaRequest(request)), stream))); 93 base::Owned(new WebUserMediaRequest(request)), stream));
95 } 94 }
96 95
97 void MockWebUserMediaClient::cancelUserMediaRequest( 96 void MockWebUserMediaClient::cancelUserMediaRequest(
98 const WebUserMediaRequest&) { 97 const WebUserMediaRequest&) {
99 } 98 }
100 99
101 void MockWebUserMediaClient::requestMediaDevices( 100 void MockWebUserMediaClient::requestMediaDevices(
102 const WebMediaDevicesRequest& request) { 101 const WebMediaDevicesRequest& request) {
103 struct { 102 struct {
104 const char* device_id; 103 const char* device_id;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ? arraysize(test_devices) 135 ? arraysize(test_devices)
137 : arraysize(test_devices) - 1; 136 : arraysize(test_devices) - 1;
138 WebVector<WebMediaDeviceInfo> devices(num_devices); 137 WebVector<WebMediaDeviceInfo> devices(num_devices);
139 for (size_t i = 0; i < num_devices; ++i) { 138 for (size_t i = 0; i < num_devices; ++i) {
140 devices[i].initialize(WebString::fromUTF8(test_devices[i].device_id), 139 devices[i].initialize(WebString::fromUTF8(test_devices[i].device_id),
141 test_devices[i].kind, 140 test_devices[i].kind,
142 WebString::fromUTF8(test_devices[i].label), 141 WebString::fromUTF8(test_devices[i].label),
143 WebString::fromUTF8(test_devices[i].group_id)); 142 WebString::fromUTF8(test_devices[i].group_id));
144 } 143 }
145 144
146 delegate_->PostTask(new WebCallbackTask( 145 delegate_->PostTask(
147 base::Bind(&WebMediaDevicesRequest::requestSucceeded, 146 base::Bind(&WebMediaDevicesRequest::requestSucceeded,
148 base::Owned(new WebMediaDevicesRequest(request)), devices))); 147 base::Owned(new WebMediaDevicesRequest(request)), devices));
149 148
150 should_enumerate_extra_device_ = !should_enumerate_extra_device_; 149 should_enumerate_extra_device_ = !should_enumerate_extra_device_;
151 if (!media_device_change_observer_.isNull()) 150 if (!media_device_change_observer_.isNull())
152 media_device_change_observer_.didChangeMediaDevices(); 151 media_device_change_observer_.didChangeMediaDevices();
153 } 152 }
154 153
155 void MockWebUserMediaClient::cancelMediaDevicesRequest( 154 void MockWebUserMediaClient::cancelMediaDevicesRequest(
156 const WebMediaDevicesRequest&) { 155 const WebMediaDevicesRequest&) {
157 } 156 }
158 157
(...skipping 20 matching lines...) Expand all
179 }; 178 };
180 179
181 WebVector<WebSourceInfo> sources(arraysize(test_sources)); 180 WebVector<WebSourceInfo> sources(arraysize(test_sources));
182 for (size_t i = 0; i < arraysize(test_sources); ++i) { 181 for (size_t i = 0; i < arraysize(test_sources); ++i) {
183 sources[i].initialize(WebString::fromUTF8(test_sources[i].id), 182 sources[i].initialize(WebString::fromUTF8(test_sources[i].id),
184 test_sources[i].kind, 183 test_sources[i].kind,
185 WebString::fromUTF8(test_sources[i].label), 184 WebString::fromUTF8(test_sources[i].label),
186 test_sources[i].facing); 185 test_sources[i].facing);
187 } 186 }
188 187
189 delegate_->PostTask(new WebCallbackTask(base::Bind( 188 delegate_->PostTask(base::Bind(
190 &WebMediaStreamTrackSourcesRequest::requestSucceeded, 189 &WebMediaStreamTrackSourcesRequest::requestSucceeded,
191 base::Owned(new WebMediaStreamTrackSourcesRequest(request)), sources))); 190 base::Owned(new WebMediaStreamTrackSourcesRequest(request)), sources));
192 } 191 }
193 192
194 void MockWebUserMediaClient::setMediaDeviceChangeObserver( 193 void MockWebUserMediaClient::setMediaDeviceChangeObserver(
195 const blink::WebMediaDeviceChangeObserver& observer) { 194 const blink::WebMediaDeviceChangeObserver& observer) {
196 media_device_change_observer_ = observer; 195 media_device_change_observer_ = observer;
197 } 196 }
198 197
199 } // namespace test_runner 198 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/mock_web_speech_recognizer.cc ('k') | components/test_runner/mock_webrtc_data_channel_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698