| 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 #ifndef MediaKeyStatusMap_h | 5 #ifndef MediaKeyStatusMap_h |
| 6 #define MediaKeyStatusMap_h | 6 #define MediaKeyStatusMap_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/Maplike.h" | 8 #include "bindings/core/v8/Iterable.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/DOMArrayPiece.h" | 11 #include "core/dom/DOMArrayPiece.h" |
| 11 #include "platform/heap/Heap.h" | 12 #include "platform/heap/Heap.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class ExceptionState; | 16 class ExceptionState; |
| 16 class Iterator; | 17 class Iterator; |
| 17 class ScriptState; | 18 class ScriptState; |
| 18 class WebData; | 19 class WebData; |
| 19 | 20 |
| 20 // Represents a read-only map (to JavaScript) of key IDs and their current | 21 // Represents a read-only map (to JavaScript) of key IDs and their current |
| 21 // status known to a particular session. Since it can be updated any time there | 22 // status known to a particular session. Since it can be updated any time there |
| 22 // is a keychange event, iteration order and completeness is not guaranteed | 23 // is a keychange event, iteration order and completeness is not guaranteed |
| 23 // if the event loop runs. | 24 // if the event loop runs. |
| 24 class MediaKeyStatusMap final : public GarbageCollected<MediaKeyStatusMap>, publ
ic ScriptWrappable, public Maplike<ArrayBufferOrArrayBufferView, String> { | 25 class MediaKeyStatusMap final : public GarbageCollected<MediaKeyStatusMap>, publ
ic ScriptWrappable, public PairIterable<ArrayBufferOrArrayBufferView, String> { |
| 25 DEFINE_WRAPPERTYPEINFO(); | 26 DEFINE_WRAPPERTYPEINFO(); |
| 26 private: | 27 private: |
| 27 // MapEntry holds the keyId (DOMArrayBuffer) and status (MediaKeyStatus as | 28 // MapEntry holds the keyId (DOMArrayBuffer) and status (MediaKeyStatus as |
| 28 // String) for each entry. | 29 // String) for each entry. |
| 29 class MapEntry; | 30 class MapEntry; |
| 30 | 31 |
| 31 // The key ids and their status are kept in a list, as order is important. | 32 // The key ids and their status are kept in a list, as order is important. |
| 32 // Note that order (or lack of it) is not specified in the EME spec. | 33 // Note that order (or lack of it) is not specified in the EME spec. |
| 33 using MediaKeyStatusMapType = HeapVector<Member<MapEntry>>; | 34 using MediaKeyStatusMapType = HeapVector<Member<MapEntry>>; |
| 34 | 35 |
| 35 public: | 36 public: |
| 36 MediaKeyStatusMap() { } | 37 MediaKeyStatusMap() { } |
| 37 | 38 |
| 38 void clear(); | 39 void clear(); |
| 39 void addEntry(WebData keyId, const String& status); | 40 void addEntry(WebData keyId, const String& status); |
| 40 const MapEntry& at(size_t) const; | 41 const MapEntry& at(size_t) const; |
| 41 | 42 |
| 42 // IDL attributes / methods | 43 // IDL attributes / methods |
| 43 size_t size() const { return m_entries.size(); } | 44 size_t size() const { return m_entries.size(); } |
| 45 bool has(const ArrayBufferOrArrayBufferView& keyId); |
| 46 ScriptValue get(ScriptState*, const ArrayBufferOrArrayBufferView& keyId); |
| 44 | 47 |
| 45 DECLARE_VIRTUAL_TRACE(); | 48 DECLARE_VIRTUAL_TRACE(); |
| 46 | 49 |
| 47 private: | 50 private: |
| 51 // PairIterable<> implementation. |
| 48 IterationSource* startIteration(ScriptState*, ExceptionState&) override; | 52 IterationSource* startIteration(ScriptState*, ExceptionState&) override; |
| 49 bool getMapEntry(ScriptState*, const ArrayBufferOrArrayBufferView&, String&,
ExceptionState&) override; | |
| 50 | 53 |
| 51 size_t indexOf(const DOMArrayPiece& key) const; | 54 size_t indexOf(const DOMArrayPiece& keyId) const; |
| 52 | 55 |
| 53 MediaKeyStatusMapType m_entries; | 56 MediaKeyStatusMapType m_entries; |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 } // namespace blink | 59 } // namespace blink |
| 57 | 60 |
| 58 #endif // MediaKeyStatusMap_h | 61 #endif // MediaKeyStatusMap_h |
| OLD | NEW |