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

Side by Side Diff: Source/modules/mediasource/WebKitMediaSource.cpp

Issue 19724003: Revert "Transition modules/** to use ExceptionState" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/mediasource/WebKitMediaSource.h" 32 #include "modules/mediasource/WebKitMediaSource.h"
33 33
34 #include "bindings/v8/ExceptionState.h" 34 #include "core/dom/ExceptionCodePlaceholder.h"
35 #include "bindings/v8/ExceptionStatePlaceholder.h"
36 #include "core/dom/ExceptionCode.h"
37 #include "core/html/TimeRanges.h" 35 #include "core/html/TimeRanges.h"
38 #include "core/platform/ContentType.h" 36 #include "core/platform/ContentType.h"
39 #include "core/platform/MIMETypeRegistry.h" 37 #include "core/platform/MIMETypeRegistry.h"
40 #include "core/platform/graphics/SourceBufferPrivate.h" 38 #include "core/platform/graphics/SourceBufferPrivate.h"
41 #include "modules/mediasource/MediaSourceRegistry.h" 39 #include "modules/mediasource/MediaSourceRegistry.h"
42 #include "wtf/Uint8Array.h" 40 #include "wtf/Uint8Array.h"
43 41
44 namespace WebCore { 42 namespace WebCore {
45 43
46 PassRefPtr<WebKitMediaSource> WebKitMediaSource::create(ScriptExecutionContext* context) 44 PassRefPtr<WebKitMediaSource> WebKitMediaSource::create(ScriptExecutionContext* context)
(...skipping 15 matching lines...) Expand all
62 { 60 {
63 return m_sourceBuffers.get(); 61 return m_sourceBuffers.get();
64 } 62 }
65 63
66 WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers() 64 WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers()
67 { 65 {
68 // FIXME(91649): support track selection 66 // FIXME(91649): support track selection
69 return m_activeSourceBuffers.get(); 67 return m_activeSourceBuffers.get();
70 } 68 }
71 69
72 WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, Excep tionState& es) 70 WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, Excep tionCode& ec)
73 { 71 {
74 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-addsourcebuffer 72 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-addsourcebuffer
75 // 1. If type is null or an empty then throw an InvalidAccessError exception and 73 // 1. If type is null or an empty then throw an InvalidAccessError exception and
76 // abort these steps. 74 // abort these steps.
77 if (type.isNull() || type.isEmpty()) { 75 if (type.isNull() || type.isEmpty()) {
78 es.throwDOMException(InvalidAccessError); 76 ec = InvalidAccessError;
79 return 0; 77 return 0;
80 } 78 }
81 79
82 // 2. If type contains a MIME type that is not supported ..., then throw a 80 // 2. If type contains a MIME type that is not supported ..., then throw a
83 // NotSupportedError exception and abort these steps. 81 // NotSupportedError exception and abort these steps.
84 if (!isTypeSupported(type)) { 82 if (!isTypeSupported(type)) {
85 es.throwDOMException(NotSupportedError); 83 ec = NotSupportedError;
86 return 0; 84 return 0;
87 } 85 }
88 86
89 // 4. If the readyState attribute is not in the "open" state then throw an 87 // 4. If the readyState attribute is not in the "open" state then throw an
90 // InvalidStateError exception and abort these steps. 88 // InvalidStateError exception and abort these steps.
91 if (!isOpen()) { 89 if (!isOpen()) {
92 es.throwDOMException(InvalidStateError); 90 ec = InvalidStateError;
93 return 0; 91 return 0;
94 } 92 }
95 93
96 // 5. Create a new SourceBuffer object and associated resources. 94 // 5. Create a new SourceBuffer object and associated resources.
97 ContentType contentType(type); 95 ContentType contentType(type);
98 Vector<String> codecs = contentType.codecs(); 96 Vector<String> codecs = contentType.codecs();
99 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate( contentType.type(), codecs, es); 97 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate( contentType.type(), codecs, ec);
100 if (!sourceBufferPrivate) 98 if (!sourceBufferPrivate)
101 return 0; 99 return 0;
102 100
103 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferP rivate.release(), this); 101 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferP rivate.release(), this);
104 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 102 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
105 m_sourceBuffers->add(buffer); 103 m_sourceBuffers->add(buffer);
106 m_activeSourceBuffers->add(buffer); 104 m_activeSourceBuffers->add(buffer);
107 // 7. Return the new object to the caller. 105 // 7. Return the new object to the caller.
108 return buffer.get(); 106 return buffer.get();
109 } 107 }
110 108
111 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception State& es) 109 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception Code& ec)
112 { 110 {
113 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-removesourcebuffer 111 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-removesourcebuffer
114 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and 112 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and
115 // abort these steps. 113 // abort these steps.
116 if (!buffer) { 114 if (!buffer) {
117 es.throwDOMException(InvalidAccessError); 115 ec = InvalidAccessError;
118 return; 116 return;
119 } 117 }
120 118
121 // 2. If sourceBuffers is empty then throw an InvalidStateError exception an d 119 // 2. If sourceBuffers is empty then throw an InvalidStateError exception an d
122 // abort these steps. 120 // abort these steps.
123 if (isClosed() || !m_sourceBuffers->length()) { 121 if (isClosed() || !m_sourceBuffers->length()) {
124 es.throwDOMException(InvalidStateError); 122 ec = InvalidStateError;
125 return; 123 return;
126 } 124 }
127 125
128 // 3. If sourceBuffer specifies an object that is not in sourceBuffers then 126 // 3. If sourceBuffer specifies an object that is not in sourceBuffers then
129 // throw a NotFoundError exception and abort these steps. 127 // throw a NotFoundError exception and abort these steps.
130 // 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer e vent 128 // 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer e vent
131 // on that object. 129 // on that object.
132 if (!m_sourceBuffers->remove(buffer)) { 130 if (!m_sourceBuffers->remove(buffer)) {
133 es.throwDOMException(NotFoundError); 131 ec = NotFoundError;
134 return; 132 return;
135 } 133 }
136 134
137 // 7. Destroy all resources for sourceBuffer. 135 // 7. Destroy all resources for sourceBuffer.
138 m_activeSourceBuffers->remove(buffer); 136 m_activeSourceBuffers->remove(buffer);
139 137
140 // 4. Remove track information from audioTracks, videoTracks, and textTracks for all tracks 138 // 4. Remove track information from audioTracks, videoTracks, and textTracks for all tracks
141 // associated with sourceBuffer and fire a simple event named change on the modified lists. 139 // associated with sourceBuffer and fire a simple event named change on the modified lists.
142 // FIXME(91649): support track selection 140 // FIXME(91649): support track selection
143 141
(...skipping 19 matching lines...) Expand all
163 if (isOpen()) { 161 if (isOpen()) {
164 scheduleEvent(eventNames().webkitsourceopenEvent); 162 scheduleEvent(eventNames().webkitsourceopenEvent);
165 return; 163 return;
166 } 164 }
167 } 165 }
168 166
169 Vector<RefPtr<TimeRanges> > WebKitMediaSource::activeRanges() const 167 Vector<RefPtr<TimeRanges> > WebKitMediaSource::activeRanges() const
170 { 168 {
171 Vector<RefPtr<TimeRanges> > activeRanges(m_activeSourceBuffers->length()); 169 Vector<RefPtr<TimeRanges> > activeRanges(m_activeSourceBuffers->length());
172 for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i) 170 for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i)
173 activeRanges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXC EPTION_STATE); 171 activeRanges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXC EPTION);
174 172
175 return activeRanges; 173 return activeRanges;
176 } 174 }
177 175
178 bool WebKitMediaSource::isTypeSupported(const String& type) 176 bool WebKitMediaSource::isTypeSupported(const String& type)
179 { 177 {
180 // Section 2.1 isTypeSupported() method steps. 178 // Section 2.1 isTypeSupported() method steps.
181 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type 179 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
182 // 1. If type is an empty string, then return false. 180 // 1. If type is an empty string, then return false.
183 if (type.isNull() || type.isEmpty()) 181 if (type.isNull() || type.isEmpty())
(...skipping 12 matching lines...) Expand all
196 // 6. Return true. 194 // 6. Return true.
197 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(), codecs); 195 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(), codecs);
198 } 196 }
199 197
200 const AtomicString& WebKitMediaSource::interfaceName() const 198 const AtomicString& WebKitMediaSource::interfaceName() const
201 { 199 {
202 return eventNames().interfaceForWebKitMediaSource; 200 return eventNames().interfaceForWebKitMediaSource;
203 } 201 }
204 202
205 } // namespace WebCore 203 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/WebKitMediaSource.h ('k') | Source/modules/mediasource/WebKitSourceBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698