OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 | 27 |
28 #include "public/platform/WebMediaStreamTrackSourcesRequest.h" | 28 #include "WebMediaDevicesRequest.h" |
29 | 29 |
30 #include "platform/mediastream/MediaStreamTrackSourcesRequest.h" | 30 #include "WebDocument.h" |
31 #include "public/platform/WebSourceInfo.h" | 31 #include "WebSecurityOrigin.h" |
32 #include "wtf/PassOwnPtr.h" | 32 #include "core/dom/Document.h" |
| 33 #include "modules/mediastream/MediaDevicesRequest.h" |
| 34 #include "platform/weborigin/SecurityOrigin.h" |
| 35 #include "public/platform/WebMediaDeviceInfo.h" |
| 36 #include "public/platform/WebString.h" |
| 37 #include "public/platform/WebVector.h" |
| 38 #include "wtf/Vector.h" |
33 | 39 |
34 using namespace WebCore; | 40 using namespace WebCore; |
35 | 41 |
36 namespace blink { | 42 namespace blink { |
37 | 43 |
38 namespace { | 44 WebMediaDevicesRequest::WebMediaDevicesRequest(const PassRefPtr<MediaDevicesRequ
est>& request) |
39 | |
40 class ExtraDataContainer : public MediaStreamTrackSourcesRequest::ExtraData { | |
41 public: | |
42 ExtraDataContainer(PassOwnPtr<WebMediaStreamTrackSourcesRequest::ExtraData>
extraData) : m_extraData(extraData) { } | |
43 | |
44 WebMediaStreamTrackSourcesRequest::ExtraData* extraData() { return m_extraDa
ta.get(); } | |
45 | |
46 private: | |
47 OwnPtr<WebMediaStreamTrackSourcesRequest::ExtraData> m_extraData; | |
48 }; | |
49 | |
50 } // namespace | |
51 | |
52 WebMediaStreamTrackSourcesRequest::WebMediaStreamTrackSourcesRequest(const PassR
efPtr<MediaStreamTrackSourcesRequest>& request) | |
53 : m_private(request) | 45 : m_private(request) |
54 { | 46 { |
55 } | 47 } |
56 | 48 |
57 void WebMediaStreamTrackSourcesRequest::assign(const WebMediaStreamTrackSourcesR
equest& other) | 49 WebMediaDevicesRequest::WebMediaDevicesRequest(MediaDevicesRequest* request) |
| 50 : m_private(request) |
| 51 { |
| 52 } |
| 53 |
| 54 void WebMediaDevicesRequest::reset() |
| 55 { |
| 56 m_private.reset(); |
| 57 } |
| 58 |
| 59 WebSecurityOrigin WebMediaDevicesRequest::securityOrigin() const |
| 60 { |
| 61 ASSERT(!isNull() && m_private->executionContext()); |
| 62 return WebSecurityOrigin(m_private->executionContext()->securityOrigin()); |
| 63 } |
| 64 |
| 65 WebDocument WebMediaDevicesRequest::ownerDocument() const |
| 66 { |
| 67 ASSERT(!isNull()); |
| 68 return WebDocument(m_private->ownerDocument()); |
| 69 } |
| 70 |
| 71 void WebMediaDevicesRequest::requestSucceeded(WebVector<WebMediaDeviceInfo> webD
evices) |
| 72 { |
| 73 ASSERT(!isNull()); |
| 74 |
| 75 MediaDeviceInfoVector devices(webDevices.size()); |
| 76 for (size_t i = 0; i < webDevices.size(); ++i) |
| 77 devices[i] = MediaDeviceInfo::create(webDevices[i]); |
| 78 |
| 79 m_private->succeed(devices); |
| 80 } |
| 81 |
| 82 bool WebMediaDevicesRequest::equals(const WebMediaDevicesRequest& other) const |
| 83 { |
| 84 if (isNull() || other.isNull()) |
| 85 return false; |
| 86 return m_private.get() == other.m_private.get(); |
| 87 } |
| 88 |
| 89 void WebMediaDevicesRequest::assign(const WebMediaDevicesRequest& other) |
58 { | 90 { |
59 m_private = other.m_private; | 91 m_private = other.m_private; |
60 } | 92 } |
61 | 93 |
62 void WebMediaStreamTrackSourcesRequest::reset() | 94 WebMediaDevicesRequest::operator MediaDevicesRequest*() const |
63 { | 95 { |
64 m_private.reset(); | 96 return m_private.get(); |
65 } | |
66 | |
67 WebString WebMediaStreamTrackSourcesRequest::origin() const | |
68 { | |
69 ASSERT(m_private.get()); | |
70 return m_private->origin(); | |
71 } | |
72 | |
73 void WebMediaStreamTrackSourcesRequest::requestSucceeded(const WebVector<WebSour
ceInfo>& sourceInfos) const | |
74 { | |
75 ASSERT(m_private.get()); | |
76 m_private->requestSucceeded(sourceInfos); | |
77 } | |
78 | |
79 WebMediaStreamTrackSourcesRequest::ExtraData* WebMediaStreamTrackSourcesRequest:
:extraData() const | |
80 { | |
81 MediaStreamTrackSourcesRequest::ExtraData* data = m_private->extraData(); | |
82 if (!data) | |
83 return 0; | |
84 return static_cast<ExtraDataContainer*>(data)->extraData(); | |
85 } | |
86 | |
87 void WebMediaStreamTrackSourcesRequest::setExtraData(ExtraData* extraData) | |
88 { | |
89 m_private->setExtraData(adoptPtr(new ExtraDataContainer(adoptPtr(extraData))
)); | |
90 } | 97 } |
91 | 98 |
92 } // namespace blink | 99 } // namespace blink |
93 | |
OLD | NEW |