Update histograms.xml for recent BadMessage values.
[chromium-blink-merge.git] / ppapi / shared_impl / dictionary_var.h
blob06f9502c48dd11d5b13ca0f52545c0e2ea30c14e
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
3 // found in the LICENSE file.
5 #ifndef PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_
6 #define PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ppapi/c/pp_var.h"
14 #include "ppapi/shared_impl/ppapi_shared_export.h"
15 #include "ppapi/shared_impl/scoped_pp_var.h"
16 #include "ppapi/shared_impl/var.h"
18 namespace ppapi {
20 class PPAPI_SHARED_EXPORT DictionaryVar : public Var {
21 public:
22 typedef std::map<std::string, ScopedPPVar> KeyValueMap;
24 DictionaryVar();
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
28 // dictionary cannot be found from the var tracker.
29 static DictionaryVar* FromPPVar(const PP_Var& var);
31 // Var overrides.
32 DictionaryVar* AsDictionaryVar() override;
33 PP_VarType GetType() const override;
35 // The returned PP_Var has had a ref added on behalf of the caller.
36 PP_Var Get(const PP_Var& key) const;
37 PP_Bool Set(const PP_Var& key, const PP_Var& value);
38 void Delete(const PP_Var& key);
39 PP_Bool HasKey(const PP_Var& key) const;
40 // The returned PP_Var has had a ref added on behalf of the caller.
41 PP_Var GetKeys() const;
43 // Returns false and keeps the dictionary unchanged if |key| is not a valid
44 // UTF-8 string.
45 bool SetWithStringKey(const std::string& utf8_key, const PP_Var& value);
46 void DeleteWithStringKey(const std::string& utf8_key);
48 const KeyValueMap& key_value_map() const { return key_value_map_; }
50 protected:
51 ~DictionaryVar() override;
53 private:
54 KeyValueMap key_value_map_;
56 DISALLOW_COPY_AND_ASSIGN(DictionaryVar);
59 } // namespace ppapi
61 #endif // PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_