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

Side by Side Diff: Source/modules/mediasource/WebKitMediaSource.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) 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers() 63 WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers()
64 { 64 {
65 // FIXME(91649): support track selection 65 // FIXME(91649): support track selection
66 return m_activeSourceBuffers.get(); 66 return m_activeSourceBuffers.get();
67 } 67 }
68 68
69 WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, Excep tionCode& ec) 69 WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, Excep tionCode& ec)
70 { 70 {
71 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-addsourcebuffer 71 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-addsourcebuffer
72 // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and 72 // 1. If type is null or an empty then throw an InvalidAccessError exception and
73 // abort these steps. 73 // abort these steps.
74 if (type.isNull() || type.isEmpty()) { 74 if (type.isNull() || type.isEmpty()) {
75 ec = INVALID_ACCESS_ERR; 75 ec = InvalidAccessError;
76 return 0; 76 return 0;
77 } 77 }
78 78
79 // 2. If type contains a MIME type that is not supported ..., then throw a 79 // 2. If type contains a MIME type that is not supported ..., then throw a
80 // NotSupportedError exception and abort these steps. 80 // NotSupportedError exception and abort these steps.
81 if (!isTypeSupported(type)) { 81 if (!isTypeSupported(type)) {
82 ec = NotSupportedError; 82 ec = NotSupportedError;
83 return 0; 83 return 0;
84 } 84 }
85 85
86 // 4. If the readyState attribute is not in the "open" state then throw an 86 // 4. If the readyState attribute is not in the "open" state then throw an
87 // INVALID_STATE_ERR exception and abort these steps. 87 // InvalidStateError exception and abort these steps.
88 if (!isOpen()) { 88 if (!isOpen()) {
89 ec = INVALID_STATE_ERR; 89 ec = InvalidStateError;
90 return 0; 90 return 0;
91 } 91 }
92 92
93 // 5. Create a new SourceBuffer object and associated resources. 93 // 5. Create a new SourceBuffer object and associated resources.
94 ContentType contentType(type); 94 ContentType contentType(type);
95 Vector<String> codecs = contentType.codecs(); 95 Vector<String> codecs = contentType.codecs();
96 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate( contentType.type(), codecs, ec); 96 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate( contentType.type(), codecs, ec);
97 if (!sourceBufferPrivate) 97 if (!sourceBufferPrivate)
98 return 0; 98 return 0;
99 99
100 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferP rivate.release(), this); 100 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferP rivate.release(), this);
101 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 101 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
102 m_sourceBuffers->add(buffer); 102 m_sourceBuffers->add(buffer);
103 m_activeSourceBuffers->add(buffer); 103 m_activeSourceBuffers->add(buffer);
104 // 7. Return the new object to the caller. 104 // 7. Return the new object to the caller.
105 return buffer.get(); 105 return buffer.get();
106 } 106 }
107 107
108 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception Code& ec) 108 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception Code& ec)
109 { 109 {
110 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-removesourcebuffer 110 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour ce.html#dom-removesourcebuffer
111 // 1. If sourceBuffer is null then throw an INVALID_ACCESS_ERR exception and 111 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and
112 // abort these steps. 112 // abort these steps.
113 if (!buffer) { 113 if (!buffer) {
114 ec = INVALID_ACCESS_ERR; 114 ec = InvalidAccessError;
115 return; 115 return;
116 } 116 }
117 117
118 // 2. If sourceBuffers is empty then throw an INVALID_STATE_ERR exception an d 118 // 2. If sourceBuffers is empty then throw an InvalidStateError exception an d
119 // abort these steps. 119 // abort these steps.
120 if (isClosed() || !m_sourceBuffers->length()) { 120 if (isClosed() || !m_sourceBuffers->length()) {
121 ec = INVALID_STATE_ERR; 121 ec = InvalidStateError;
122 return; 122 return;
123 } 123 }
124 124
125 // 3. If sourceBuffer specifies an object that is not in sourceBuffers then 125 // 3. If sourceBuffer specifies an object that is not in sourceBuffers then
126 // throw a NotFoundError exception and abort these steps. 126 // throw a NotFoundError exception and abort these steps.
127 // 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer e vent 127 // 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer e vent
128 // on that object. 128 // on that object.
129 if (!m_sourceBuffers->remove(buffer)) { 129 if (!m_sourceBuffers->remove(buffer)) {
130 ec = NotFoundError; 130 ec = NotFoundError;
131 return; 131 return;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void WebKitMediaSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) co nst 200 void WebKitMediaSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) co nst
201 { 201 {
202 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 202 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
203 ScriptWrappable::reportMemoryUsage(memoryObjectInfo); 203 ScriptWrappable::reportMemoryUsage(memoryObjectInfo);
204 MediaSourceBase::reportMemoryUsage(memoryObjectInfo); 204 MediaSourceBase::reportMemoryUsage(memoryObjectInfo);
205 info.addMember(m_sourceBuffers, "sourceBuffers"); 205 info.addMember(m_sourceBuffers, "sourceBuffers");
206 info.addMember(m_activeSourceBuffers, "activeSourceBuffers"); 206 info.addMember(m_activeSourceBuffers, "activeSourceBuffers");
207 } 207 }
208 208
209 } // namespace WebCore 209 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/SourceBuffer.cpp ('k') | Source/modules/mediasource/WebKitSourceBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698