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

Side by Side Diff: Source/core/dom/Maplike.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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/modules/encryptedmedia/MediaKeyStatusMap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef Maplike_h
6 #define Maplike_h
7
8 #include "bindings/core/v8/ScriptValue.h"
9 #include "bindings/core/v8/ToV8.h"
10 #include "core/dom/Iterable.h"
11
12 namespace blink {
13
14 template <typename KeyType, typename ValueType>
15 class Maplike : public PairIterable<KeyType, ValueType> {
16 public:
17 bool hasForBinding(ScriptState* scriptState, const KeyType& key, ExceptionSt ate& exceptionState)
18 {
19 ValueType value;
20 return getMapEntry(scriptState, key, value, exceptionState);
21 }
22
23 ScriptValue getForBinding(ScriptState* scriptState, const KeyType& key, Exce ptionState& exceptionState)
24 {
25 ValueType value;
26 if (getMapEntry(scriptState, key, value, exceptionState))
27 return ScriptValue(scriptState, toV8(value, scriptState->context()-> Global(), scriptState->isolate()));
28 return ScriptValue(scriptState, v8::Undefined(scriptState->isolate()));
29 }
30
31 private:
32 virtual bool getMapEntry(ScriptState*, const KeyType&, ValueType&, Exception State&) = 0;
33 };
34
35 } // namespace blink
36
37 #endif // Maplike_h
OLDNEW
« no previous file with comments | « no previous file | Source/modules/encryptedmedia/MediaKeyStatusMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698