OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "modules/encryptedmedia/MediaKeyStatusMap.h" | 6 #include "modules/encryptedmedia/MediaKeyStatusMap.h" |
7 | 7 |
8 #include "core/dom/DOMArrayBuffer.h" | 8 #include "core/dom/DOMArrayBuffer.h" |
9 #include "core/dom/DOMArrayPiece.h" | 9 #include "core/dom/DOMArrayPiece.h" |
10 #include "public/platform/WebData.h" | 10 #include "public/platform/WebData.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 DOMArrayBuffer* keyId() const | 25 DOMArrayBuffer* keyId() const |
26 { | 26 { |
27 return m_keyId.get(); | 27 return m_keyId.get(); |
28 } | 28 } |
29 | 29 |
30 const String& status() const | 30 const String& status() const |
31 { | 31 { |
32 return m_status; | 32 return m_status; |
33 } | 33 } |
34 | 34 |
35 virtual void trace(Visitor* visitor) | 35 DEFINE_INLINE_VIRTUAL_TRACE() |
36 { | 36 { |
37 } | 37 } |
38 | 38 |
39 private: | 39 private: |
40 MapEntry(WebData keyId, const String& status) | 40 MapEntry(WebData keyId, const String& status) |
41 : m_keyId(DOMArrayBuffer::create(keyId.data(), keyId.size())) | 41 : m_keyId(DOMArrayBuffer::create(keyId.data(), keyId.size())) |
42 , m_status(status) | 42 , m_status(status) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
(...skipping 16 matching lines...) Expand all Loading... |
62 // so if the iterated object is mutated values may be skipped. | 62 // so if the iterated object is mutated values may be skipped. |
63 if (m_current >= m_map->size()) | 63 if (m_current >= m_map->size()) |
64 return false; | 64 return false; |
65 | 65 |
66 const auto& entry = m_map->at(m_current++); | 66 const auto& entry = m_map->at(m_current++); |
67 key.setArrayBuffer(entry.keyId()); | 67 key.setArrayBuffer(entry.keyId()); |
68 value = entry.status(); | 68 value = entry.status(); |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 void trace(Visitor* visitor) override | 72 DEFINE_INLINE_VIRTUAL_TRACE() |
73 { | 73 { |
74 visitor->trace(m_map); | 74 visitor->trace(m_map); |
75 PairIterable<ArrayBufferOrArrayBufferView, String>::IterationSource::tra
ce(visitor); | 75 PairIterable<ArrayBufferOrArrayBufferView, String>::IterationSource::tra
ce(visitor); |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 // m_map is stored just for keeping it alive. It needs to be kept | 79 // m_map is stored just for keeping it alive. It needs to be kept |
80 // alive while JavaScript holds the iterator to it. | 80 // alive while JavaScript holds the iterator to it. |
81 const Member<const MediaKeyStatusMap> m_map; | 81 const Member<const MediaKeyStatusMap> m_map; |
82 size_t m_current; | 82 size_t m_current; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 bool MediaKeyStatusMap::getMapEntry(ScriptState*, const ArrayBufferOrArrayBuffer
View& key, String& value, ExceptionState&) | 118 bool MediaKeyStatusMap::getMapEntry(ScriptState*, const ArrayBufferOrArrayBuffer
View& key, String& value, ExceptionState&) |
119 { | 119 { |
120 size_t index = indexOf(key); | 120 size_t index = indexOf(key); |
121 if (index < m_entries.size()) { | 121 if (index < m_entries.size()) { |
122 value = at(index).status(); | 122 value = at(index).status(); |
123 return true; | 123 return true; |
124 } | 124 } |
125 return false; | 125 return false; |
126 } | 126 } |
127 | 127 |
128 void MediaKeyStatusMap::trace(Visitor* visitor) | 128 DEFINE_TRACE(MediaKeyStatusMap) |
129 { | 129 { |
130 visitor->trace(m_entries); | 130 visitor->trace(m_entries); |
131 } | 131 } |
132 | 132 |
133 } // namespace blink | 133 } // namespace blink |
OLD | NEW |