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/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "bindings/core/v8/UnionTypesCore.h" |
9 #include "core/dom/DOMArrayPiece.h" | 10 #include "core/dom/DOMArrayPiece.h" |
10 #include "core/dom/Iterable.h" | 11 #include "core/dom/Maplike.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 PairIterable<DOMArrayBuffer*, String> { | 25 class MediaKeyStatusMap final : public GarbageCollected<MediaKeyStatusMap>, publ
ic ScriptWrappable, public Maplike<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 // As the number of keys per session should be small, the key ids and | 32 // As the number of keys per session should be small, the key ids and |
32 // their status are kept in a list rather than a proper map. | 33 // their status are kept in a list rather than a proper map. |
33 typedef HeapVector<Member<MapEntry>> MapType; | 34 typedef HeapVector<Member<MapEntry>> MapType; |
34 | 35 |
35 public: | 36 public: |
36 MediaKeyStatusMap() { } | 37 MediaKeyStatusMap() { } |
37 | 38 |
38 void clear(); | 39 void clear(); |
39 void addEntry(WebData source, const String& status); | 40 void addEntry(WebData source, 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(); } |
44 String get(const DOMArrayPiece& key); | |
45 bool has(const DOMArrayPiece& key) const; | |
46 | 45 |
47 virtual void trace(Visitor*); | 46 virtual void trace(Visitor*); |
48 | 47 |
49 private: | 48 private: |
50 IterationSource* startIteration(ScriptState*, ExceptionState&) override; | 49 IterationSource* startIteration(ScriptState*, ExceptionState&) override; |
| 50 bool getMapEntry(ScriptState*, const ArrayBufferOrArrayBufferView&, String&,
ExceptionState&) override; |
51 | 51 |
52 size_t indexOf(const DOMArrayPiece& key) const; | 52 size_t indexOf(const DOMArrayPiece& key) const; |
53 | 53 |
54 MapType m_entries; | 54 MapType m_entries; |
55 }; | 55 }; |
56 | 56 |
57 } // namespace blink | 57 } // namespace blink |
58 | 58 |
59 #endif // MediaKeyStatusMap_h | 59 #endif // MediaKeyStatusMap_h |
OLD | NEW |