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

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

Issue 18548003: Rename ExceptionCode constants to use the names in the spec (2/3) (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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 SourceBuffer::~SourceBuffer() 66 SourceBuffer::~SourceBuffer()
67 { 67 {
68 ASSERT(isRemoved()); 68 ASSERT(isRemoved());
69 } 69 }
70 70
71 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const 71 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const
72 { 72 {
73 // Section 3.1 buffered attribute steps. 73 // Section 3.1 buffered attribute steps.
74 // 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
75 // INVALID_STATE_ERR exception and abort these steps. 75 // InvalidStateError exception and abort these steps.
76 if (isRemoved()) { 76 if (isRemoved()) {
77 ec = INVALID_STATE_ERR; 77 ec = InvalidStateError;
78 return 0; 78 return 0;
79 } 79 }
80 80
81 // 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.
82 return m_private->buffered(); 82 return m_private->buffered();
83 } 83 }
84 84
85 double SourceBuffer::timestampOffset() const 85 double SourceBuffer::timestampOffset() const
86 { 86 {
87 return m_timestampOffset; 87 return m_timestampOffset;
88 } 88 }
89 89
90 void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec) 90 void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
91 { 91 {
92 // Section 3.1 timestampOffset attribute setter steps. 92 // Section 3.1 timestampOffset attribute setter steps.
93 // 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
94 // INVALID_STATE_ERR exception and abort these steps. 94 // InvalidStateError exception and abort these steps.
95 if (isRemoved()) { 95 if (isRemoved()) {
96 ec = INVALID_STATE_ERR; 96 ec = InvalidStateError;
97 return; 97 return;
98 } 98 }
99 99
100 // 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:
101 // 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"
102 // 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.
103 m_source->openIfInEndedState(); 103 m_source->openIfInEndedState();
104 104
105 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an INVALID_STATE_ERR 105 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError
106 // and abort these steps. 106 // and abort these steps.
107 if (!m_private->setTimestampOffset(offset)) { 107 if (!m_private->setTimestampOffset(offset)) {
108 ec = INVALID_STATE_ERR; 108 ec = InvalidStateError;
109 return; 109 return;
110 } 110 }
111 111
112 // 6. Update the attribute to the new value. 112 // 6. Update the attribute to the new value.
113 m_timestampOffset = offset; 113 m_timestampOffset = offset;
114 } 114 }
115 115
116 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionCode& ec) 116 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionCode& ec)
117 { 117 {
118 // Section 3.2 appendBuffer() 118 // Section 3.2 appendBuffer()
119 // 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
120 // 1. If data is null then throw an INVALID_ACCESS_ERR exception and abort t hese steps. 120 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps.
121 if (!data) { 121 if (!data) {
122 ec = INVALID_ACCESS_ERR; 122 ec = InvalidAccessError;
123 return; 123 return;
124 } 124 }
125 125
126 appendBufferInternal(static_cast<unsigned char*>(data->data()), data->byteLe ngth(), ec); 126 appendBufferInternal(static_cast<unsigned char*>(data->data()), data->byteLe ngth(), ec);
127 } 127 }
128 128
129 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionCode& ec) 129 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionCode& ec)
130 { 130 {
131 // Section 3.2 appendBuffer() 131 // Section 3.2 appendBuffer()
132 // 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
133 // 1. If data is null then throw an INVALID_ACCESS_ERR exception and abort t hese steps. 133 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps.
134 if (!data) { 134 if (!data) {
135 ec = INVALID_ACCESS_ERR; 135 ec = InvalidAccessError;
136 return; 136 return;
137 } 137 }
138 138
139 appendBufferInternal(static_cast<unsigned char*>(data->baseAddress()), data- >byteLength(), ec); 139 appendBufferInternal(static_cast<unsigned char*>(data->baseAddress()), data- >byteLength(), ec);
140 } 140 }
141 141
142 void SourceBuffer::abort(ExceptionCode& ec) 142 void SourceBuffer::abort(ExceptionCode& ec)
143 { 143 {
144 // Section 3.2 abort() method steps. 144 // Section 3.2 abort() method steps.
145 // 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
146 // 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
147 // then throw an INVALID_STATE_ERR exception and abort these steps. 147 // then throw an InvalidStateError exception and abort these steps.
148 // 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
149 // then throw an INVALID_STATE_ERR exception and abort these steps. 149 // then throw an InvalidStateError exception and abort these steps.
150 if (isRemoved() || !m_source->isOpen()) { 150 if (isRemoved() || !m_source->isOpen()) {
151 ec = INVALID_STATE_ERR; 151 ec = InvalidStateError;
152 return; 152 return;
153 } 153 }
154 154
155 // 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: ...
156 abortIfUpdating(); 156 abortIfUpdating();
157 157
158 // 4. Run the reset parser state algorithm. 158 // 4. Run the reset parser state algorithm.
159 m_private->abort(); 159 m_private->abort();
160 160
161 // FIXME(229408) Add steps 5-6 update appendWindowStart & appendWindowEnd. 161 // FIXME(229408) Add steps 5-6 update appendWindowStart & appendWindowEnd.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 m_asyncEventQueue->enqueueEvent(event.release()); 239 m_asyncEventQueue->enqueueEvent(event.release());
240 } 240 }
241 241
242 void SourceBuffer::appendBufferInternal(unsigned char* data, unsigned size, Exce ptionCode& ec) 242 void SourceBuffer::appendBufferInternal(unsigned char* data, unsigned size, Exce ptionCode& ec)
243 { 243 {
244 // Section 3.2 appendBuffer() 244 // Section 3.2 appendBuffer()
245 // 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
246 246
247 // Step 1 is enforced by the caller. 247 // Step 1 is enforced by the caller.
248 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an INVALID_STATE_ERR 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.
249 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. 249 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
250 if (isRemoved() || m_updating) { 250 if (isRemoved() || m_updating) {
251 ec = INVALID_STATE_ERR; 251 ec = InvalidStateError;
252 return; 252 return;
253 } 253 }
254 254
255 // 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: ...
256 m_source->openIfInEndedState(); 256 m_source->openIfInEndedState();
257 257
258 // Steps 5-6 258 // Steps 5-6
259 259
260 // 7. Add data to the end of the input buffer. 260 // 7. Add data to the end of the input buffer.
261 m_pendingAppendData.append(data, size); 261 m_pendingAppendData.append(data, size);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 m_pendingAppendData.clear(); 293 m_pendingAppendData.clear();
294 294
295 // 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.
296 scheduleEvent(eventNames().updateEvent); 296 scheduleEvent(eventNames().updateEvent);
297 297
298 // 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.
299 scheduleEvent(eventNames().updateendEvent); 299 scheduleEvent(eventNames().updateendEvent);
300 } 300 }
301 301
302 } // namespace WebCore 302 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/MediaSourceBase.cpp ('k') | Source/modules/mediasource/WebKitMediaSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698