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 #ifndef PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ | 5 #ifndef PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ |
6 #define PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ | 6 #define PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 typedef std::map<std::string, ScopedPPVar> KeyValueMap; | 22 typedef std::map<std::string, ScopedPPVar> KeyValueMap; |
23 | 23 |
24 DictionaryVar(); | 24 DictionaryVar(); |
25 | 25 |
26 // Helper function that converts a PP_Var to a DictionaryVar. This will | 26 // Helper function that converts a PP_Var to a DictionaryVar. This will |
27 // return NULL if the PP_Var is not of type PP_VARTYPE_DICTIONARY or the | 27 // return NULL if the PP_Var is not of type PP_VARTYPE_DICTIONARY or the |
28 // dictionary cannot be found from the var tracker. | 28 // dictionary cannot be found from the var tracker. |
29 static DictionaryVar* FromPPVar(const PP_Var& var); | 29 static DictionaryVar* FromPPVar(const PP_Var& var); |
30 | 30 |
31 // Var overrides. | 31 // Var overrides. |
32 virtual DictionaryVar* AsDictionaryVar() OVERRIDE; | 32 virtual DictionaryVar* AsDictionaryVar() override; |
33 virtual PP_VarType GetType() const OVERRIDE; | 33 virtual PP_VarType GetType() const override; |
34 | 34 |
35 // The returned PP_Var has had a ref added on behalf of the caller. | 35 // The returned PP_Var has had a ref added on behalf of the caller. |
36 PP_Var Get(const PP_Var& key) const; | 36 PP_Var Get(const PP_Var& key) const; |
37 PP_Bool Set(const PP_Var& key, const PP_Var& value); | 37 PP_Bool Set(const PP_Var& key, const PP_Var& value); |
38 void Delete(const PP_Var& key); | 38 void Delete(const PP_Var& key); |
39 PP_Bool HasKey(const PP_Var& key) const; | 39 PP_Bool HasKey(const PP_Var& key) const; |
40 // The returned PP_Var has had a ref added on behalf of the caller. | 40 // The returned PP_Var has had a ref added on behalf of the caller. |
41 PP_Var GetKeys() const; | 41 PP_Var GetKeys() const; |
42 | 42 |
43 // Returns false and keeps the dictionary unchanged if |key| is not a valid | 43 // Returns false and keeps the dictionary unchanged if |key| is not a valid |
44 // UTF-8 string. | 44 // UTF-8 string. |
45 bool SetWithStringKey(const std::string& utf8_key, const PP_Var& value); | 45 bool SetWithStringKey(const std::string& utf8_key, const PP_Var& value); |
46 void DeleteWithStringKey(const std::string& utf8_key); | 46 void DeleteWithStringKey(const std::string& utf8_key); |
47 | 47 |
48 const KeyValueMap& key_value_map() const { return key_value_map_; } | 48 const KeyValueMap& key_value_map() const { return key_value_map_; } |
49 | 49 |
50 protected: | 50 protected: |
51 virtual ~DictionaryVar(); | 51 virtual ~DictionaryVar(); |
52 | 52 |
53 private: | 53 private: |
54 KeyValueMap key_value_map_; | 54 KeyValueMap key_value_map_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(DictionaryVar); | 56 DISALLOW_COPY_AND_ASSIGN(DictionaryVar); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace ppapi | 59 } // namespace ppapi |
60 | 60 |
61 #endif // PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ | 61 #endif // PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ |
OLD | NEW |