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 19 matching lines...) Expand all Loading... |
30 using TypeAndID = std::pair<AtomicString, String>; | 30 using TypeAndID = std::pair<AtomicString, String>; |
31 using TypeAndIDToTrackDefaultMap = | 31 using TypeAndIDToTrackDefaultMap = |
32 HeapHashMap<TypeAndID, Member<TrackDefault>>; | 32 HeapHashMap<TypeAndID, Member<TrackDefault>>; |
33 TypeAndIDToTrackDefaultMap typeAndIDToTrackDefaultMap; | 33 TypeAndIDToTrackDefaultMap typeAndIDToTrackDefaultMap; |
34 | 34 |
35 for (const auto& trackDefault : trackDefaults) { | 35 for (const auto& trackDefault : trackDefaults) { |
36 TypeAndID key = | 36 TypeAndID key = |
37 TypeAndID(trackDefault->type(), trackDefault->byteStreamTrackID()); | 37 TypeAndID(trackDefault->type(), trackDefault->byteStreamTrackID()); |
38 if (!typeAndIDToTrackDefaultMap.insert(key, trackDefault).isNewEntry) { | 38 if (!typeAndIDToTrackDefaultMap.insert(key, trackDefault).isNewEntry) { |
39 exceptionState.throwDOMException( | 39 exceptionState.throwDOMException( |
40 InvalidAccessError, "Duplicate TrackDefault type (" + key.first + | 40 InvalidAccessError, |
41 ") and byteStreamTrackID (" + key.second + | 41 "Duplicate TrackDefault type (" + key.first + |
42 ")"); | 42 ") and byteStreamTrackID (" + key.second + ")"); |
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 | 47 // 2. Store a shallow copy of |trackDefaults| in this new object so the values |
48 // can 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 |
(...skipping 14 matching lines...) Expand all Loading... |
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 |