OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/mediasource/TrackDefaultList.h" | 5 #include "modules/mediasource/TrackDefaultList.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
9 #include "wtf/text/AtomicStringHash.h" | 9 #include "wtf/text/AtomicStringHash.h" |
10 #include "wtf/text/StringHash.h" | 10 #include "wtf/text/StringHash.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 TypeAndID(trackDefault->type(), trackDefault->byteStreamTrackID()); | 37 TypeAndID(trackDefault->type(), trackDefault->byteStreamTrackID()); |
38 if (!typeAndIDToTrackDefaultMap.add(key, trackDefault).isNewEntry) { | 38 if (!typeAndIDToTrackDefaultMap.add(key, trackDefault).isNewEntry) { |
39 exceptionState.throwDOMException( | 39 exceptionState.throwDOMException( |
40 InvalidAccessError, "Duplicate TrackDefault type (" + key.first + | 40 InvalidAccessError, "Duplicate TrackDefault type (" + key.first + |
41 ") and byteStreamTrackID (" + key.second + | 41 ") and byteStreamTrackID (" + key.second + |
42 ")"); | 42 ")"); |
43 return nullptr; | 43 return nullptr; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 // 2. Store a shallow copy of |trackDefaults| in this new object so the values
can | 47 // 2. Store a shallow copy of |trackDefaults| in this new object so the values |
48 // be returned by the accessor methods. | 48 // can be returned by the accessor methods. |
49 // This step is done in constructor initializer. | 49 // This step is done in constructor initializer. |
50 return new TrackDefaultList(trackDefaults); | 50 return new TrackDefaultList(trackDefaults); |
51 } | 51 } |
52 | 52 |
53 TrackDefault* TrackDefaultList::item(unsigned index) const { | 53 TrackDefault* TrackDefaultList::item(unsigned index) const { |
54 // Per 11 Dec 2014 Editor's Draft | 54 // Per 11 Dec 2014 Editor's Draft |
55 // https://w3c.github.io/media-source/#trackdefaultlist | 55 // https://w3c.github.io/media-source/#trackdefaultlist |
56 // When this method is invoked, the user agent must run the following steps: | 56 // When this method is invoked, the user agent must run the following steps: |
57 // 1. If |index| is greater than or equal to the length attribute then | 57 // 1. If |index| is greater than or equal to the length attribute then |
58 // return undefined and abort these steps. | 58 // return undefined and abort these steps. |
59 if (index >= m_trackDefaults.size()) | 59 if (index >= m_trackDefaults.size()) |
60 return 0; | 60 return 0; |
61 | 61 |
62 // 2. Return the |index|'th TrackDefault object in the list. | 62 // 2. Return the |index|'th TrackDefault object in the list. |
63 return m_trackDefaults[index].get(); | 63 return m_trackDefaults[index].get(); |
64 } | 64 } |
65 | 65 |
66 TrackDefaultList::TrackDefaultList() {} | 66 TrackDefaultList::TrackDefaultList() {} |
67 | 67 |
68 TrackDefaultList::TrackDefaultList( | 68 TrackDefaultList::TrackDefaultList( |
69 const HeapVector<Member<TrackDefault>>& trackDefaults) | 69 const HeapVector<Member<TrackDefault>>& trackDefaults) |
70 : m_trackDefaults(trackDefaults) {} | 70 : m_trackDefaults(trackDefaults) {} |
71 | 71 |
72 DEFINE_TRACE(TrackDefaultList) { | 72 DEFINE_TRACE(TrackDefaultList) { |
73 visitor->trace(m_trackDefaults); | 73 visitor->trace(m_trackDefaults); |
74 } | 74 } |
75 | 75 |
76 } // namespace blink | 76 } // namespace blink |
OLD | NEW |