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

Side by Side Diff: Source/modules/mediasource/MediaSource.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
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/MediaSourceBase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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/MediaSource.h" 32 #include "modules/mediasource/MediaSource.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/dom/GenericEventQueue.h" 35 #include "core/dom/GenericEventQueue.h"
38 #include "core/html/TimeRanges.h" 36 #include "core/html/TimeRanges.h"
39 #include "core/platform/ContentType.h" 37 #include "core/platform/ContentType.h"
40 #include "core/platform/Logging.h" 38 #include "core/platform/Logging.h"
41 #include "core/platform/MIMETypeRegistry.h" 39 #include "core/platform/MIMETypeRegistry.h"
42 #include "core/platform/graphics/SourceBufferPrivate.h" 40 #include "core/platform/graphics/SourceBufferPrivate.h"
43 #include "modules/mediasource/MediaSourceRegistry.h" 41 #include "modules/mediasource/MediaSourceRegistry.h"
44 #include "wtf/Uint8Array.h" 42 #include "wtf/Uint8Array.h"
45 #include "wtf/text/CString.h" 43 #include "wtf/text/CString.h"
46 44
(...skipping 14 matching lines...) Expand all
61 m_sourceBuffers = SourceBufferList::create(scriptExecutionContext(), asyncEv entQueue()); 59 m_sourceBuffers = SourceBufferList::create(scriptExecutionContext(), asyncEv entQueue());
62 m_activeSourceBuffers = SourceBufferList::create(scriptExecutionContext(), a syncEventQueue()); 60 m_activeSourceBuffers = SourceBufferList::create(scriptExecutionContext(), a syncEventQueue());
63 } 61 }
64 62
65 MediaSource::~MediaSource() 63 MediaSource::~MediaSource()
66 { 64 {
67 LOG(Media, "MediaSource::~MediaSource %p", this); 65 LOG(Media, "MediaSource::~MediaSource %p", this);
68 ASSERT(isClosed()); 66 ASSERT(isClosed());
69 } 67 }
70 68
71 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e s) 69 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec )
72 { 70 {
73 LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this) ; 71 LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this) ;
74 72
75 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 73 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
76 // 1. If type is null or an empty then throw an InvalidAccessError exception and 74 // 1. If type is null or an empty then throw an InvalidAccessError exception and
77 // abort these steps. 75 // abort these steps.
78 if (type.isNull() || type.isEmpty()) { 76 if (type.isNull() || type.isEmpty()) {
79 es.throwDOMException(InvalidAccessError); 77 ec = InvalidAccessError;
80 return 0; 78 return 0;
81 } 79 }
82 80
83 // 2. If type contains a MIME type that is not supported ..., then throw a 81 // 2. If type contains a MIME type that is not supported ..., then throw a
84 // NotSupportedError exception and abort these steps. 82 // NotSupportedError exception and abort these steps.
85 if (!isTypeSupported(type)) { 83 if (!isTypeSupported(type)) {
86 es.throwDOMException(NotSupportedError); 84 ec = NotSupportedError;
87 return 0; 85 return 0;
88 } 86 }
89 87
90 // 4. If the readyState attribute is not in the "open" state then throw an 88 // 4. If the readyState attribute is not in the "open" state then throw an
91 // InvalidStateError exception and abort these steps. 89 // InvalidStateError exception and abort these steps.
92 if (!isOpen()) { 90 if (!isOpen()) {
93 es.throwDOMException(InvalidStateError); 91 ec = InvalidStateError;
94 return 0; 92 return 0;
95 } 93 }
96 94
97 // 5. Create a new SourceBuffer object and associated resources. 95 // 5. Create a new SourceBuffer object and associated resources.
98 ContentType contentType(type); 96 ContentType contentType(type);
99 Vector<String> codecs = contentType.codecs(); 97 Vector<String> codecs = contentType.codecs();
100 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate( contentType.type(), codecs, es); 98 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate( contentType.type(), codecs, ec);
101 99
102 if (!sourceBufferPrivate) { 100 if (!sourceBufferPrivate) {
103 ASSERT(es == NotSupportedError || es == QuotaExceededError); 101 ASSERT(ec == NotSupportedError || ec == QuotaExceededError);
104 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps. 102 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps.
105 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps 103 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps
106 return 0; 104 return 0;
107 } 105 }
108 106
109 RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.relea se(), this, asyncEventQueue()); 107 RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.relea se(), this, asyncEventQueue());
110 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 108 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
111 m_sourceBuffers->add(buffer); 109 m_sourceBuffers->add(buffer);
112 m_activeSourceBuffers->add(buffer); 110 m_activeSourceBuffers->add(buffer);
113 // 7. Return the new object to the caller. 111 // 7. Return the new object to the caller.
114 return buffer.get(); 112 return buffer.get();
115 } 113 }
116 114
117 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& es) 115 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionCode& ec)
118 { 116 {
119 LOG(Media, "MediaSource::removeSourceBuffer() %p", this); 117 LOG(Media, "MediaSource::removeSourceBuffer() %p", this);
120 RefPtr<SourceBuffer> protect(buffer); 118 RefPtr<SourceBuffer> protect(buffer);
121 119
122 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 120 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
123 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and 121 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and
124 // abort these steps. 122 // abort these steps.
125 if (!buffer) { 123 if (!buffer) {
126 es.throwDOMException(InvalidAccessError); 124 ec = InvalidAccessError;
127 return; 125 return;
128 } 126 }
129 127
130 // 2. If sourceBuffer specifies an object that is not in sourceBuffers then 128 // 2. If sourceBuffer specifies an object that is not in sourceBuffers then
131 // throw a NotFoundError exception and abort these steps. 129 // throw a NotFoundError exception and abort these steps.
132 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { 130 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
133 es.throwDOMException(NotFoundError); 131 ec = NotFoundError;
134 return; 132 return;
135 } 133 }
136 134
137 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ... 135 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ...
138 buffer->abortIfUpdating(); 136 buffer->abortIfUpdating();
139 137
140 // Steps 4-9 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet. 138 // Steps 4-9 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet.
141 // FIXME(91649): support track selection 139 // FIXME(91649): support track selection
142 140
143 // 10. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer f rom activeSourceBuffers ... 141 // 10. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer f rom activeSourceBuffers ...
(...skipping 28 matching lines...) Expand all
172 m_sourceBuffers->item(i)->removedFromMediaSource(); 170 m_sourceBuffers->item(i)->removedFromMediaSource();
173 m_sourceBuffers->clear(); 171 m_sourceBuffers->clear();
174 172
175 scheduleEvent(eventNames().sourcecloseEvent); 173 scheduleEvent(eventNames().sourcecloseEvent);
176 } 174 }
177 175
178 Vector<RefPtr<TimeRanges> > MediaSource::activeRanges() const 176 Vector<RefPtr<TimeRanges> > MediaSource::activeRanges() const
179 { 177 {
180 Vector<RefPtr<TimeRanges> > activeRanges(m_activeSourceBuffers->length()); 178 Vector<RefPtr<TimeRanges> > activeRanges(m_activeSourceBuffers->length());
181 for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i) 179 for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i)
182 activeRanges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXC EPTION_STATE); 180 activeRanges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXC EPTION);
183 181
184 return activeRanges; 182 return activeRanges;
185 } 183 }
186 184
187 bool MediaSource::isTypeSupported(const String& type) 185 bool MediaSource::isTypeSupported(const String& type)
188 { 186 {
189 LOG(Media, "MediaSource::isTypeSupported(%s)", type.ascii().data()); 187 LOG(Media, "MediaSource::isTypeSupported(%s)", type.ascii().data());
190 188
191 // Section 2.2 isTypeSupported() method steps. 189 // Section 2.2 isTypeSupported() method steps.
192 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type 190 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
(...skipping 14 matching lines...) Expand all
207 // 6. Return true. 205 // 6. Return true.
208 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(), codecs); 206 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(), codecs);
209 } 207 }
210 208
211 const AtomicString& MediaSource::interfaceName() const 209 const AtomicString& MediaSource::interfaceName() const
212 { 210 {
213 return eventNames().interfaceForMediaSource; 211 return eventNames().interfaceForMediaSource;
214 } 212 }
215 213
216 } // namespace WebCore 214 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/MediaSourceBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698