Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Unified Diff: Source/modules/webmidi/MIDIPortMap.h

Issue 920713002: Add Maplike<> utility mixin class for implementing maplike interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-iterable-etc-typedefs
Patch Set: drop some includes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webmidi/MIDIOutputMap.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIPortMap.h
diff --git a/Source/modules/webmidi/MIDIPortMap.h b/Source/modules/webmidi/MIDIPortMap.h
index b5f55fe0939facca85db17dbad15049437d62826..a99bf491633951851286e1a49026efa38b5279ad 100644
--- a/Source/modules/webmidi/MIDIPortMap.h
+++ b/Source/modules/webmidi/MIDIPortMap.h
@@ -6,10 +6,8 @@
#define MIDIPortMap_h
#include "bindings/core/v8/ExceptionState.h"
-#include "bindings/core/v8/ScriptState.h"
-#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8Binding.h"
-#include "core/dom/Iterable.h"
+#include "core/dom/Maplike.h"
#include "platform/heap/Handle.h"
#include "wtf/HashMap.h"
#include "wtf/text/StringHash.h"
@@ -18,14 +16,12 @@
namespace blink {
template <typename T>
-class MIDIPortMap : public GarbageCollected<MIDIPortMap<T>>, public PairIterable<String, T*> {
+class MIDIPortMap : public GarbageCollected<MIDIPortMap<T>>, public Maplike<String, T*> {
public:
explicit MIDIPortMap(const HeapHashMap<String, Member<T>>& entries) : m_entries(entries) { }
// IDL attributes / methods
size_t size() const { return m_entries.size(); }
- T* get(const String& key) const;
- bool has(const String& key) const { return m_entries.contains(key); }
DEFINE_INLINE_VIRTUAL_TRACE()
{
@@ -41,6 +37,14 @@ private:
return new MapIterationSource(this, m_entries.begin(), m_entries.end());
}
+ bool getMapEntry(ScriptState*, const String& key, T*& value, ExceptionState&) override
+ {
+ if (!m_entries.contains(key))
+ return false;
+ value = m_entries.get(key);
+ return true;
+ }
+
// Note: This template class relies on the fact that m_map.m_entries will
// never be modified once it is created.
class MapIterationSource final : public PairIterable<String, T*>::IterationSource {
@@ -79,12 +83,6 @@ private:
const MapType m_entries;
};
-template <typename T>
-T* MIDIPortMap<T>::get(const String& key) const
-{
- return has(key) ? m_entries.get(key) : 0;
-}
-
} // namespace blink
#endif
« no previous file with comments | « Source/modules/webmidi/MIDIOutputMap.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698