| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_HASH_MAP_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_HASH_MAP_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_HASH_MAP_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_HASH_MAP_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "mojo/public/cpp/bindings/map_traits.h" | 9 #include "mojo/public/cpp/bindings/map_traits.h" |
| 10 #include "third_party/WebKit/Source/wtf/HashMap.h" | 10 #include "third_party/WebKit/Source/wtf/HashMap.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 static V& GetValue(Iterator& iterator) { return iterator->value; } | 46 static V& GetValue(Iterator& iterator) { return iterator->value; } |
| 47 static const V& GetValue(ConstIterator& iterator) { return iterator->value; } | 47 static const V& GetValue(ConstIterator& iterator) { return iterator->value; } |
| 48 | 48 |
| 49 template <typename IK, typename IV> | 49 template <typename IK, typename IV> |
| 50 static bool Insert(WTF::HashMap<K, V>& input, IK&& key, IV&& value) { | 50 static bool Insert(WTF::HashMap<K, V>& input, IK&& key, IV&& value) { |
| 51 if (!WTF::HashMap<K, V>::isValidKey(key)) { | 51 if (!WTF::HashMap<K, V>::isValidKey(key)) { |
| 52 LOG(ERROR) << "The key value is disallowed by WTF::HashMap"; | 52 LOG(ERROR) << "The key value is disallowed by WTF::HashMap"; |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 input.add(std::forward<IK>(key), std::forward<IV>(value)); | 55 input.insert(std::forward<IK>(key), std::forward<IV>(value)); |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 static void SetToEmpty(WTF::HashMap<K, V>* output) { output->clear(); } | 59 static void SetToEmpty(WTF::HashMap<K, V>* output) { output->clear(); } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 } // namespace mojo | 62 } // namespace mojo |
| 63 | 63 |
| 64 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_HASH_MAP_H_ | 64 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_WTF_HASH_MAP_H_ |
| OLD | NEW |