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

Side by Side Diff: Source/modules/mediasource/SourceBuffer.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) 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/SourceBuffer.h" 32 #include "modules/mediasource/SourceBuffer.h"
33 33
34 #include "bindings/v8/ExceptionState.h"
35 #include "core/dom/Event.h" 34 #include "core/dom/Event.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/Logging.h" 37 #include "core/platform/Logging.h"
40 #include "core/platform/graphics/SourceBufferPrivate.h" 38 #include "core/platform/graphics/SourceBufferPrivate.h"
41 #include "modules/mediasource/MediaSource.h" 39 #include "modules/mediasource/MediaSource.h"
42 #include "wtf/ArrayBuffer.h" 40 #include "wtf/ArrayBuffer.h"
43 #include "wtf/ArrayBufferView.h" 41 #include "wtf/ArrayBufferView.h"
44 42
45 namespace WebCore { 43 namespace WebCore {
46 44
(...skipping 16 matching lines...) Expand all
63 ASSERT(m_private); 61 ASSERT(m_private);
64 ASSERT(m_source); 62 ASSERT(m_source);
65 ScriptWrappable::init(this); 63 ScriptWrappable::init(this);
66 } 64 }
67 65
68 SourceBuffer::~SourceBuffer() 66 SourceBuffer::~SourceBuffer()
69 { 67 {
70 ASSERT(isRemoved()); 68 ASSERT(isRemoved());
71 } 69 }
72 70
73 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& es) const 71 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const
74 { 72 {
75 // Section 3.1 buffered attribute steps. 73 // Section 3.1 buffered attribute steps.
76 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 74 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
77 // InvalidStateError exception and abort these steps. 75 // InvalidStateError exception and abort these steps.
78 if (isRemoved()) { 76 if (isRemoved()) {
79 es.throwDOMException(InvalidStateError); 77 ec = InvalidStateError;
80 return 0; 78 return 0;
81 } 79 }
82 80
83 // 2. Return a new static normalized TimeRanges object for the media segment s buffered. 81 // 2. Return a new static normalized TimeRanges object for the media segment s buffered.
84 return m_private->buffered(); 82 return m_private->buffered();
85 } 83 }
86 84
87 double SourceBuffer::timestampOffset() const 85 double SourceBuffer::timestampOffset() const
88 { 86 {
89 return m_timestampOffset; 87 return m_timestampOffset;
90 } 88 }
91 89
92 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& es) 90 void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
93 { 91 {
94 // Section 3.1 timestampOffset attribute setter steps. 92 // Section 3.1 timestampOffset attribute setter steps.
95 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 93 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
96 // InvalidStateError exception and abort these steps. 94 // InvalidStateError exception and abort these steps.
97 if (isRemoved()) { 95 if (isRemoved()) {
98 es.throwDOMException(InvalidStateError); 96 ec = InvalidStateError;
99 return; 97 return;
100 } 98 }
101 99
102 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 100 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
103 // 4.1 Set the readyState attribute of the parent media source to "open" 101 // 4.1 Set the readyState attribute of the parent media source to "open"
104 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source. 102 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source.
105 m_source->openIfInEndedState(); 103 m_source->openIfInEndedState();
106 104
107 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError 105 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError
108 // and abort these steps. 106 // and abort these steps.
109 if (!m_private->setTimestampOffset(offset)) { 107 if (!m_private->setTimestampOffset(offset)) {
110 es.throwDOMException(InvalidStateError); 108 ec = InvalidStateError;
111 return; 109 return;
112 } 110 }
113 111
114 // 6. Update the attribute to the new value. 112 // 6. Update the attribute to the new value.
115 m_timestampOffset = offset; 113 m_timestampOffset = offset;
116 } 114 }
117 115
118 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& es ) 116 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionCode& ec)
119 { 117 {
120 // Section 3.2 appendBuffer() 118 // Section 3.2 appendBuffer()
121 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 119 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
122 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps. 120 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps.
123 if (!data) { 121 if (!data) {
124 es.throwDOMException(InvalidAccessError); 122 ec = InvalidAccessError;
125 return; 123 return;
126 } 124 }
127 125
128 appendBufferInternal(static_cast<unsigned char*>(data->data()), data->byteLe ngth(), es); 126 appendBufferInternal(static_cast<unsigned char*>(data->data()), data->byteLe ngth(), ec);
129 } 127 }
130 128
131 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionState & es) 129 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionCode& ec)
132 { 130 {
133 // Section 3.2 appendBuffer() 131 // Section 3.2 appendBuffer()
134 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 132 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
135 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps. 133 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps.
136 if (!data) { 134 if (!data) {
137 es.throwDOMException(InvalidAccessError); 135 ec = InvalidAccessError;
138 return; 136 return;
139 } 137 }
140 138
141 appendBufferInternal(static_cast<unsigned char*>(data->baseAddress()), data- >byteLength(), es); 139 appendBufferInternal(static_cast<unsigned char*>(data->baseAddress()), data- >byteLength(), ec);
142 } 140 }
143 141
144 void SourceBuffer::abort(ExceptionState& es) 142 void SourceBuffer::abort(ExceptionCode& ec)
145 { 143 {
146 // Section 3.2 abort() method steps. 144 // Section 3.2 abort() method steps.
147 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-abort-void 145 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-abort-void
148 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source 146 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source
149 // then throw an InvalidStateError exception and abort these steps. 147 // then throw an InvalidStateError exception and abort these steps.
150 // 2. If the readyState attribute of the parent media source is not in the " open" state 148 // 2. If the readyState attribute of the parent media source is not in the " open" state
151 // then throw an InvalidStateError exception and abort these steps. 149 // then throw an InvalidStateError exception and abort these steps.
152 if (isRemoved() || !m_source->isOpen()) { 150 if (isRemoved() || !m_source->isOpen()) {
153 es.throwDOMException(InvalidStateError); 151 ec = InvalidStateError;
154 return; 152 return;
155 } 153 }
156 154
157 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ... 155 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ...
158 abortIfUpdating(); 156 abortIfUpdating();
159 157
160 // 4. Run the reset parser state algorithm. 158 // 4. Run the reset parser state algorithm.
161 m_private->abort(); 159 m_private->abort();
162 160
163 // FIXME(229408) Add steps 5-6 update appendWindowStart & appendWindowEnd. 161 // FIXME(229408) Add steps 5-6 update appendWindowStart & appendWindowEnd.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 void SourceBuffer::scheduleEvent(const AtomicString& eventName) 232 void SourceBuffer::scheduleEvent(const AtomicString& eventName)
235 { 233 {
236 ASSERT(m_asyncEventQueue); 234 ASSERT(m_asyncEventQueue);
237 235
238 RefPtr<Event> event = Event::create(eventName, false, false); 236 RefPtr<Event> event = Event::create(eventName, false, false);
239 event->setTarget(this); 237 event->setTarget(this);
240 238
241 m_asyncEventQueue->enqueueEvent(event.release()); 239 m_asyncEventQueue->enqueueEvent(event.release());
242 } 240 }
243 241
244 void SourceBuffer::appendBufferInternal(unsigned char* data, unsigned size, Exce ptionState& es) 242 void SourceBuffer::appendBufferInternal(unsigned char* data, unsigned size, Exce ptionCode& ec)
245 { 243 {
246 // Section 3.2 appendBuffer() 244 // Section 3.2 appendBuffer()
247 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 245 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
248 246
249 // Step 1 is enforced by the caller. 247 // Step 1 is enforced by the caller.
250 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an InvalidStateError exception and abort these steps. 248 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an InvalidStateError exception and abort these steps.
251 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. 249 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
252 if (isRemoved() || m_updating) { 250 if (isRemoved() || m_updating) {
253 es.throwDOMException(InvalidStateError); 251 ec = InvalidStateError;
254 return; 252 return;
255 } 253 }
256 254
257 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: ... 255 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: ...
258 m_source->openIfInEndedState(); 256 m_source->openIfInEndedState();
259 257
260 // Steps 5-6 258 // Steps 5-6
261 259
262 // 7. Add data to the end of the input buffer. 260 // 7. Add data to the end of the input buffer.
263 m_pendingAppendData.append(data, size); 261 m_pendingAppendData.append(data, size);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 m_pendingAppendData.clear(); 293 m_pendingAppendData.clear();
296 294
297 // 4. Queue a task to fire a simple event named update at this SourceBuffer object. 295 // 4. Queue a task to fire a simple event named update at this SourceBuffer object.
298 scheduleEvent(eventNames().updateEvent); 296 scheduleEvent(eventNames().updateEvent);
299 297
300 // 5. Queue a task to fire a simple event named updateend at this SourceBuff er object. 298 // 5. Queue a task to fire a simple event named updateend at this SourceBuff er object.
301 scheduleEvent(eventNames().updateendEvent); 299 scheduleEvent(eventNames().updateendEvent);
302 } 300 }
303 301
304 } // namespace WebCore 302 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/SourceBuffer.h ('k') | Source/modules/mediasource/WebKitMediaSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698