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

Side by Side Diff: mojo/public/cpp/bindings/map.h

Issue 646773005: mojo: Switch the clipboard interface over to using map<>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar tests Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "mojo/public/cpp/bindings/lib/map_internal.h" 10 #include "mojo/public/cpp/bindings/lib/map_internal.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void insert(KeyForwardType key, ValueForwardType value) { 81 void insert(KeyForwardType key, ValueForwardType value) {
82 is_null_ = false; 82 is_null_ = false;
83 Traits::Insert(&map_, key, value); 83 Traits::Insert(&map_, key, value);
84 } 84 }
85 85
86 ValueRefType at(KeyForwardType key) { return Traits::at(&map_, key); } 86 ValueRefType at(KeyForwardType key) { return Traits::at(&map_, key); }
87 ValueConstRefType at(KeyForwardType key) const { 87 ValueConstRefType at(KeyForwardType key) const {
88 return Traits::at(&map_, key); 88 return Traits::at(&map_, key);
89 } 89 }
90 90
91 ValueRefType operator[](KeyForwardType key) {
92 is_null_ = false;
93 return Traits::GetOrInsert(&map_, key);
94 }
95
91 void Swap(Map<Key, Value>* other) { 96 void Swap(Map<Key, Value>* other) {
92 std::swap(is_null_, other->is_null_); 97 std::swap(is_null_, other->is_null_);
93 map_.swap(other->map_); 98 map_.swap(other->map_);
94 } 99 }
95 void Swap(std::map<Key, Value>* other) { 100 void Swap(std::map<Key, Value>* other) {
96 is_null_ = false; 101 is_null_ = false;
97 map_.swap(*other); 102 map_.swap(*other);
98 } 103 }
99 104
100 // This moves all values in the map to a set of parallel arrays. This action 105 // This moves all values in the map to a set of parallel arrays. This action
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 TypeConverter<STLValue, MojoValue>::Convert(it.GetValue()))); 221 TypeConverter<STLValue, MojoValue>::Convert(it.GetValue())));
217 } 222 }
218 } 223 }
219 return result; 224 return result;
220 } 225 }
221 }; 226 };
222 227
223 } // namespace mojo 228 } // namespace mojo
224 229
225 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ 230 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_internal.h ('k') | mojo/public/cpp/bindings/tests/map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698