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

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

Issue 266453005: Apply TypeChecking to MediaSource IDLs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use MAX_VALUE instead of POS_INF. Created 6 years, 7 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) 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 { 68 {
69 WTF_LOG(Media, "MediaSource::~MediaSource %p", this); 69 WTF_LOG(Media, "MediaSource::~MediaSource %p", this);
70 ASSERT(isClosed()); 70 ASSERT(isClosed());
71 } 71 }
72 72
73 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState) 73 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState)
74 { 74 {
75 WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), t his); 75 WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), t his);
76 76
77 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 77 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
78 // 1. If type is null or an empty then throw an InvalidAccessError exception and 78 // 1. If type is an empty string then throw an InvalidAccessError exception
79 // abort these steps. 79 // and abort these steps.
80 if (type.isNull() || type.isEmpty()) { 80 if (type.isEmpty()) {
81 exceptionState.throwDOMException(InvalidAccessError, "The type provided is empty."); 81 exceptionState.throwDOMException(InvalidAccessError, "The type provided is empty.");
82 return 0; 82 return 0;
83 } 83 }
84 84
85 // 2. If type contains a MIME type that is not supported ..., then throw a 85 // 2. If type contains a MIME type that is not supported ..., then throw a
86 // NotSupportedError exception and abort these steps. 86 // NotSupportedError exception and abort these steps.
87 if (!isTypeSupported(type)) { 87 if (!isTypeSupported(type)) {
88 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + type + "') is unsupported."); 88 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + type + "') is unsupported.");
89 return 0; 89 return 0;
90 } 90 }
(...skipping 24 matching lines...) Expand all
115 // 7. Return the new object to the caller. 115 // 7. Return the new object to the caller.
116 return buffer.get(); 116 return buffer.get();
117 } 117 }
118 118
119 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState) 119 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState)
120 { 120 {
121 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); 121 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this);
122 RefPtr<SourceBuffer> protect(buffer); 122 RefPtr<SourceBuffer> protect(buffer);
123 123
124 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 124 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
125 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and
126 // abort these steps.
127 if (!buffer) {
128 exceptionState.throwDOMException(InvalidAccessError, "The SourceBuffer p rovided is invalid.");
129 return;
130 }
131 125
132 // 2. If sourceBuffer specifies an object that is not in sourceBuffers then 126 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then
133 // throw a NotFoundError exception and abort these steps. 127 // throw a NotFoundError exception and abort these steps.
134 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { 128 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
135 exceptionState.throwDOMException(NotFoundError, "The SourceBuffer provid ed is not contained in this MediaSource."); 129 exceptionState.throwDOMException(NotFoundError, "The SourceBuffer provid ed is not contained in this MediaSource.");
136 return; 130 return;
137 } 131 }
138 132
139 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ... 133 // 2. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ...
140 buffer->abortIfUpdating(); 134 buffer->abortIfUpdating();
141 135
142 // Steps 4-9 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet. 136 // Steps 3-8 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet.
143 // FIXME(91649): support track selection 137 // FIXME(91649): support track selection
144 138
145 // 10. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer f rom activeSourceBuffers ... 139 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer fr om activeSourceBuffers ...
146 m_activeSourceBuffers->remove(buffer); 140 m_activeSourceBuffers->remove(buffer);
147 141
148 // 11. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event 142 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event
149 // on that object. 143 // on that object.
150 m_sourceBuffers->remove(buffer); 144 m_sourceBuffers->remove(buffer);
151 145
152 // 12. Destroy all resources for sourceBuffer. 146 // 11. Destroy all resources for sourceBuffer.
153 buffer->removedFromMediaSource(); 147 buffer->removedFromMediaSource();
154 } 148 }
155 149
156 void MediaSource::onReadyStateChange(const AtomicString& oldState, const AtomicS tring& newState) 150 void MediaSource::onReadyStateChange(const AtomicString& oldState, const AtomicS tring& newState)
157 { 151 {
158 if (isOpen()) { 152 if (isOpen()) {
159 scheduleEvent(EventTypeNames::sourceopen); 153 scheduleEvent(EventTypeNames::sourceopen);
160 return; 154 return;
161 } 155 }
162 156
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 221 }
228 222
229 void MediaSource::trace(Visitor* visitor) 223 void MediaSource::trace(Visitor* visitor)
230 { 224 {
231 visitor->trace(m_sourceBuffers); 225 visitor->trace(m_sourceBuffers);
232 visitor->trace(m_activeSourceBuffers); 226 visitor->trace(m_activeSourceBuffers);
233 MediaSourceBase::trace(visitor); 227 MediaSourceBase::trace(visitor);
234 } 228 }
235 229
236 } // namespace WebCore 230 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698