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

Side by Side Diff: ppapi/proxy/serialized_var.cc

Issue 4659001: Convert Chrome PPAPI proxy from bool to PP_Bool. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/proxy/serialized_var.h" 5 #include "ppapi/proxy/serialized_var.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ipc/ipc_message_utils.h" 8 #include "ipc/ipc_message_utils.h"
9 #include "ppapi/proxy/dispatcher.h" 9 #include "ppapi/proxy/dispatcher.h"
10 #include "ppapi/proxy/interface_proxy.h"
10 #include "ppapi/proxy/ppapi_param_traits.h" 11 #include "ppapi/proxy/ppapi_param_traits.h"
11 #include "ppapi/proxy/var_serialization_rules.h" 12 #include "ppapi/proxy/var_serialization_rules.h"
12 13
13 namespace pp { 14 namespace pp {
14 namespace proxy { 15 namespace proxy {
15 16
16 // SerializedVar::Inner -------------------------------------------------------- 17 // SerializedVar::Inner --------------------------------------------------------
17 18
18 SerializedVar::Inner::Inner() 19 SerializedVar::Inner::Inner()
19 : serialization_rules_(NULL), 20 : serialization_rules_(NULL),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 DCHECK(var_.type == PP_VARTYPE_STRING || string_value_.empty()); 116 DCHECK(var_.type == PP_VARTYPE_STRING || string_value_.empty());
116 117
117 m->WriteInt(static_cast<int>(var_.type)); 118 m->WriteInt(static_cast<int>(var_.type));
118 switch (var_.type) { 119 switch (var_.type) {
119 case PP_VARTYPE_UNDEFINED: 120 case PP_VARTYPE_UNDEFINED:
120 case PP_VARTYPE_NULL: 121 case PP_VARTYPE_NULL:
121 // These don't need any data associated with them other than the type we 122 // These don't need any data associated with them other than the type we
122 // just serialized. 123 // just serialized.
123 break; 124 break;
124 case PP_VARTYPE_BOOL: 125 case PP_VARTYPE_BOOL:
125 m->WriteBool(var_.value.as_bool); 126 m->WriteBool(var_.value.as_bool);
dmichael(do not use this one) 2010/11/08 15:31:19 This part compiles okay on Windows? I might have
brettw 2010/11/08 15:59:19 This doesn't build on Windows (yet), but thanks fo
126 break; 127 break;
127 case PP_VARTYPE_INT32: 128 case PP_VARTYPE_INT32:
128 m->WriteInt(var_.value.as_int); 129 m->WriteInt(var_.value.as_int);
129 break; 130 break;
130 case PP_VARTYPE_DOUBLE: 131 case PP_VARTYPE_DOUBLE:
131 IPC::ParamTraits<double>::Write(m, var_.value.as_double); 132 IPC::ParamTraits<double>::Write(m, var_.value.as_double);
132 break; 133 break;
133 case PP_VARTYPE_STRING: 134 case PP_VARTYPE_STRING:
134 // TODO(brettw) in the case of an invalid string ID, it would be nice 135 // TODO(brettw) in the case of an invalid string ID, it would be nice
135 // to send something to the other side such that a 0 ID would be 136 // to send something to the other side such that a 0 ID would be
(...skipping 28 matching lines...) Expand all
164 return false; 165 return false;
165 166
166 bool success = false; 167 bool success = false;
167 switch (type) { 168 switch (type) {
168 case PP_VARTYPE_UNDEFINED: 169 case PP_VARTYPE_UNDEFINED:
169 case PP_VARTYPE_NULL: 170 case PP_VARTYPE_NULL:
170 // These don't have any data associated with them other than the type we 171 // These don't have any data associated with them other than the type we
171 // just serialized. 172 // just serialized.
172 success = true; 173 success = true;
173 break; 174 break;
174 case PP_VARTYPE_BOOL: 175 case PP_VARTYPE_BOOL: {
175 success = m->ReadBool(iter, &var_.value.as_bool); 176 bool bool_value;
177 success = m->ReadBool(iter, &bool_value);
dmichael(do not use this one) 2010/11/08 15:31:19 Maybe this would be premature optimization, but yo
brettw 2010/11/08 15:51:02 The plugin might be malicious or have a bug and wr
dmichael(do not use this one) 2010/11/08 16:11:51 Good point. May warrant a comment, then, to fend
178 var_.value.as_bool = BoolToPPBool(bool_value);
176 break; 179 break;
180 }
177 case PP_VARTYPE_INT32: 181 case PP_VARTYPE_INT32:
178 success = m->ReadInt(iter, &var_.value.as_int); 182 success = m->ReadInt(iter, &var_.value.as_int);
179 break; 183 break;
180 case PP_VARTYPE_DOUBLE: 184 case PP_VARTYPE_DOUBLE:
181 success = IPC::ParamTraits<double>::Read(m, iter, &var_.value.as_double); 185 success = IPC::ParamTraits<double>::Read(m, iter, &var_.value.as_double);
182 break; 186 break;
183 case PP_VARTYPE_STRING: 187 case PP_VARTYPE_STRING:
184 success = m->ReadString(iter, &string_value_); 188 success = m->ReadString(iter, &string_value_);
185 var_.value.as_id = 0; 189 var_.value.as_id = 0;
186 break; 190 break;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 460
457 PP_Var** SerializedVarVectorOutParam::ArrayOutParam(Dispatcher* dispatcher) { 461 PP_Var** SerializedVarVectorOutParam::ArrayOutParam(Dispatcher* dispatcher) {
458 DCHECK(!dispatcher_); // Should only be called once. 462 DCHECK(!dispatcher_); // Should only be called once.
459 dispatcher_ = dispatcher; 463 dispatcher_ = dispatcher;
460 return &array_; 464 return &array_;
461 } 465 }
462 466
463 } // namespace proxy 467 } // namespace proxy
464 } // namespace pp 468 } // namespace pp
465 469
OLDNEW
« ppapi/proxy/ppb_core_proxy.cc ('K') | « ppapi/proxy/ppp_instance_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698