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

Side by Side Diff: ppapi/cpp/extensions/dict_field.h

Issue 13811036: Add Pepper API tests for chrome.socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/nacl/nacl_test_data.gyp ('k') | ppapi/ppapi_nacl_test_common.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CPP_EXTENSIONS_DICT_FIELD_H_ 5 #ifndef PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_
6 #define PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_ 6 #define PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ppapi/c/pp_bool.h" 10 #include "ppapi/c/pp_bool.h"
(...skipping 10 matching lines...) Expand all
21 class DictField { 21 class DictField {
22 public: 22 public:
23 explicit DictField(const std::string& key) : key_(key), value_() { 23 explicit DictField(const std::string& key) : key_(key), value_() {
24 } 24 }
25 25
26 ~DictField() { 26 ~DictField() {
27 } 27 }
28 28
29 const std::string& key() const { return key_; } 29 const std::string& key() const { return key_; }
30 30
31 T& value() { return value_; } 31 // Returns the value.
32 const T& value() const { return value_; } 32 T& operator()() { return value_; }
33 const T& operator()() const { return value_; }
33 34
34 // Adds this field to the dictionary var. 35 // Adds this field to the dictionary var.
35 bool AddTo(VarDictionary_Dev* dict) const { 36 bool AddTo(VarDictionary_Dev* dict) const {
36 if (!dict) 37 if (!dict)
37 return false; 38 return false;
38 39
39 internal::ToVarConverter<T> converter(value_); 40 internal::ToVarConverter<T> converter(value_);
40 return PP_ToBool(dict->Set(Var(key_), converter.var())); 41 return PP_ToBool(dict->Set(Var(key_), converter.var()));
41 } 42 }
42 43
(...skipping 16 matching lines...) Expand all
59 class OptionalDictField { 60 class OptionalDictField {
60 public: 61 public:
61 explicit OptionalDictField(const std::string& key) : key_(key) { 62 explicit OptionalDictField(const std::string& key) : key_(key) {
62 } 63 }
63 64
64 ~OptionalDictField() { 65 ~OptionalDictField() {
65 } 66 }
66 67
67 const std::string& key() const { return key_; } 68 const std::string& key() const { return key_; }
68 69
69 Optional<T>& value() { return value_; } 70 // Returns the value.
70 const Optional<T>& value() const { return value_; } 71 Optional<T>& operator()() { return value_; }
72 const Optional<T>& operator()() const { return value_; }
71 73
72 // Adds this field to the dictionary var, if |value| has been set. 74 // Adds this field to the dictionary var, if |value| has been set.
73 bool MayAddTo(VarDictionary_Dev* dict) const { 75 bool MayAddTo(VarDictionary_Dev* dict) const {
74 if (!dict) 76 if (!dict)
75 return false; 77 return false;
76 if (!value_.IsSet()) 78 if (!value_.IsSet())
77 return true; 79 return true;
78 80
79 internal::ToVarConverter<T> converter(*value_); 81 internal::ToVarConverter<T> converter(*value_);
80 return PP_ToBool(dict->Set(Var(key_), converter.var())); 82 return PP_ToBool(dict->Set(Var(key_), converter.var()));
81 } 83 }
82 84
83 bool Populate(const VarDictionary_Dev& dict) { 85 bool Populate(const VarDictionary_Dev& dict) {
84 Var value_var = dict.Get(Var(key_)); 86 Var value_var = dict.Get(Var(key_));
85 internal::FromVarConverter<Optional<T> > converter(value_var.pp_var()); 87 internal::FromVarConverter<Optional<T> > converter(value_var.pp_var());
86 value_.Swap(&converter.value()); 88 value_.Swap(&converter.value());
87 return true; 89 return true;
88 } 90 }
89 91
90 private: 92 private:
91 std::string key_; 93 std::string key_;
92 Optional<T> value_; 94 Optional<T> value_;
93 }; 95 };
94 96
95 } // namespace ext 97 } // namespace ext
96 } // namespace pp 98 } // namespace pp
97 99
98 #endif // PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_ 100 #endif // PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_
OLDNEW
« no previous file with comments | « chrome/test/data/nacl/nacl_test_data.gyp ('k') | ppapi/ppapi_nacl_test_common.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698