Chromium Code Reviews| Index: ppapi/shared_impl/dictionary_var.h |
| diff --git a/ppapi/shared_impl/dictionary_var.h b/ppapi/shared_impl/dictionary_var.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..911298ce9d9767afbeb5783b7c12964b6054e7bb |
| --- /dev/null |
| +++ b/ppapi/shared_impl/dictionary_var.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ |
| +#define PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "ppapi/c/pp_var.h" |
| +#include "ppapi/shared_impl/ppapi_shared_export.h" |
| +#include "ppapi/shared_impl/scoped_pp_var.h" |
| +#include "ppapi/shared_impl/var.h" |
| + |
| +namespace ppapi { |
| + |
| +class PPAPI_SHARED_EXPORT DictionaryVar : public Var { |
| + public: |
| + typedef std::map<std::string, ScopedPPVar> KeyValueMap; |
| + |
| + DictionaryVar(); |
| + |
| + // Helper function that converts a PP_Var to a DictionaryVar. This will |
| + // return NULL if the PP_Var is not of type PP_VARTYPE_DICTIONARY or the |
| + // dictionary cannot be found from the var tracker. |
| + static DictionaryVar* FromPPVar(const PP_Var& var); |
| + |
| + // Var overrides. |
| + virtual DictionaryVar* AsDictionaryVar() OVERRIDE; |
| + virtual PP_VarType GetType() const OVERRIDE; |
| + |
| + // The returned PP_Var has been added ref on behalf of the caller. |
|
dmichael (off chromium)
2013/03/05 22:01:03
nit: wording is a little akward (maybe just make i
yzshen1
2013/03/14 05:38:21
Done. Yeah, it sounds better that way.
On 2013/03/
|
| + PP_Var Get(const PP_Var& key) const; |
| + PP_Bool Set(const PP_Var& key, const PP_Var& value); |
| + void Delete(const PP_Var& key); |
| + PP_Bool HasKey(const PP_Var& key) const; |
| + // The returned PP_Var has been added ref on behalf of the caller. |
|
dmichael (off chromium)
2013/03/05 22:01:03
ditto, and please make it plural (returned PP_Vars
yzshen1
2013/03/14 05:38:21
Done changing it to "had a ref added on behalf of
dmichael (off chromium)
2013/03/15 17:35:48
Sorry, I had the array ref-counts on the brain. Yo
|
| + PP_Var GetKeys() const; |
| + |
| + // Returns false and keeps the dictionary unchanged if |key| is not a valid |
| + // UTF-8 string. |
| + bool SetWithStringKey(const std::string& utf8_key, const PP_Var& value); |
| + void DeleteWithStringKey(const std::string& utf8_key); |
| + |
| + const KeyValueMap& key_value_map() const { |
| + return key_value_map_; |
| + } |
| + |
| + protected: |
| + virtual ~DictionaryVar(); |
| + |
| + private: |
| + KeyValueMap key_value_map_; |
|
dmichael (off chromium)
2013/03/05 22:01:03
So I take it you're not worrying about making it w
yzshen1
2013/03/14 05:38:21
Correct. I haven't done that part.
I think at leas
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(DictionaryVar); |
| +}; |
| + |
| +} // namespace ppapi |
| + |
| +#endif // PPAPI_SHARED_IMPL_DICTIONARY_VAR_H_ |