OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "ppapi/shared_impl/dictionary_var.h" | 5 #include "ppapi/shared_impl/dictionary_var.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "ppapi/shared_impl/array_var.h" | 9 #include "ppapi/shared_impl/array_var.h" |
10 #include "ppapi/shared_impl/ppapi_globals.h" | 10 #include "ppapi/shared_impl/ppapi_globals.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 iter != key_value_map_.end(); | 83 iter != key_value_map_.end(); |
84 ++iter) { | 84 ++iter) { |
85 array_var->elements().push_back(ScopedPPVar( | 85 array_var->elements().push_back(ScopedPPVar( |
86 ScopedPPVar::PassRef(), StringVar::StringToPPVar(iter->first))); | 86 ScopedPPVar::PassRef(), StringVar::StringToPPVar(iter->first))); |
87 } | 87 } |
88 return array_var->GetPPVar(); | 88 return array_var->GetPPVar(); |
89 } | 89 } |
90 | 90 |
91 bool DictionaryVar::SetWithStringKey(const std::string& utf8_key, | 91 bool DictionaryVar::SetWithStringKey(const std::string& utf8_key, |
92 const PP_Var& value) { | 92 const PP_Var& value) { |
93 if (!base::IsStringUTF8(utf8_key)) | 93 if (!IsStringUTF8(utf8_key)) |
94 return false; | 94 return false; |
95 | 95 |
96 key_value_map_[utf8_key] = value; | 96 key_value_map_[utf8_key] = value; |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 void DictionaryVar::DeleteWithStringKey(const std::string& utf8_key) { | 100 void DictionaryVar::DeleteWithStringKey(const std::string& utf8_key) { |
101 key_value_map_.erase(utf8_key); | 101 key_value_map_.erase(utf8_key); |
102 } | 102 } |
103 | 103 |
104 } // namespace ppapi | 104 } // namespace ppapi |
OLD | NEW |