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

Side by Side Diff: src/trusted/plugin/method_map.cc

Issue 5622003: Restructure the structs/unions involved in SRPC argument passing. This will... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years 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 | « src/trusted/plugin/desc_based_handle.cc ('k') | src/trusted/plugin/npapi/plugin_npapi.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Native Client Authors. All rights reserved. 2 * Copyright 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "native_client/src/include/checked_cast.h" 10 #include "native_client/src/include/checked_cast.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 MethodInfo::~MethodInfo() { 127 MethodInfo::~MethodInfo() {
128 free(reinterpret_cast<void*>(name_)); 128 free(reinterpret_cast<void*>(name_));
129 free(reinterpret_cast<void*>(ins_)); 129 free(reinterpret_cast<void*>(ins_));
130 free(reinterpret_cast<void*>(outs_)); 130 free(reinterpret_cast<void*>(outs_));
131 } 131 }
132 132
133 bool InitSrpcArgArray(NaClSrpcArg* arr, int size) { 133 bool InitSrpcArgArray(NaClSrpcArg* arr, int size) {
134 arr->tag = NACL_SRPC_ARG_TYPE_VARIANT_ARRAY; 134 arr->tag = NACL_SRPC_ARG_TYPE_VARIANT_ARRAY;
135 arr->u.vaval.varr = reinterpret_cast<NaClSrpcArg*>( 135 arr->arrays.varr = reinterpret_cast<NaClSrpcArg*>(
136 calloc(size, sizeof(*(arr->u.vaval.varr)))); 136 calloc(size, sizeof(*(arr->arrays.varr))));
137 if (NULL == arr->u.vaval.varr) { 137 if (NULL == arr->arrays.varr) {
138 arr->u.vaval.count = 0; 138 arr->u.count = 0;
139 return false; 139 return false;
140 } 140 }
141 arr->u.vaval.count = size; 141 arr->u.count = size;
142 return true; 142 return true;
143 } 143 }
144 144
145 void FreeSrpcArg(NaClSrpcArg* arg) { 145 void FreeSrpcArg(NaClSrpcArg* arg) {
146 switch (arg->tag) { 146 switch (arg->tag) {
147 case NACL_SRPC_ARG_TYPE_CHAR_ARRAY: 147 case NACL_SRPC_ARG_TYPE_CHAR_ARRAY:
148 free(arg->u.caval.carr); 148 free(arg->arrays.carr);
149 break; 149 break;
150 case NACL_SRPC_ARG_TYPE_DOUBLE_ARRAY: 150 case NACL_SRPC_ARG_TYPE_DOUBLE_ARRAY:
151 free(arg->u.daval.darr); 151 free(arg->arrays.darr);
152 break; 152 break;
153 case NACL_SRPC_ARG_TYPE_HANDLE: 153 case NACL_SRPC_ARG_TYPE_HANDLE:
154 break; 154 break;
155 case NACL_SRPC_ARG_TYPE_INT_ARRAY: 155 case NACL_SRPC_ARG_TYPE_INT_ARRAY:
156 free(arg->u.iaval.iarr); 156 free(arg->arrays.iarr);
157 break; 157 break;
158 case NACL_SRPC_ARG_TYPE_LONG_ARRAY: 158 case NACL_SRPC_ARG_TYPE_LONG_ARRAY:
159 free(arg->u.laval.larr); 159 free(arg->arrays.larr);
160 break; 160 break;
161 case NACL_SRPC_ARG_TYPE_STRING: 161 case NACL_SRPC_ARG_TYPE_STRING:
162 // All strings that are passed in SrpcArg must be allocated using 162 // All strings that are passed in SrpcArg must be allocated using
163 // malloc! We cannot use browser's allocation API 163 // malloc! We cannot use browser's allocation API
164 // since some of SRPC arguments is handled outside of the plugin code. 164 // since some of SRPC arguments is handled outside of the plugin code.
165 free(arg->u.sval.str); 165 free(arg->arrays.str);
166 break; 166 break;
167 case NACL_SRPC_ARG_TYPE_VARIANT_ARRAY: 167 case NACL_SRPC_ARG_TYPE_VARIANT_ARRAY:
168 if (arg->u.vaval.varr) { 168 if (arg->arrays.varr) {
169 for (uint32_t i = 0; i < arg->u.vaval.count; i++) { 169 for (uint32_t i = 0; i < arg->u.count; i++) {
170 FreeSrpcArg(&arg->u.vaval.varr[i]); 170 FreeSrpcArg(&arg->arrays.varr[i]);
171 } 171 }
172 } 172 }
173 break; 173 break;
174 case NACL_SRPC_ARG_TYPE_OBJECT: 174 case NACL_SRPC_ARG_TYPE_OBJECT:
175 // This is a pointer to a scriptable object and should be released 175 // This is a pointer to a scriptable object and should be released
176 // by the browser 176 // by the browser
177 break; 177 break;
178 case NACL_SRPC_ARG_TYPE_BOOL: 178 case NACL_SRPC_ARG_TYPE_BOOL:
179 case NACL_SRPC_ARG_TYPE_DOUBLE: 179 case NACL_SRPC_ARG_TYPE_DOUBLE:
180 case NACL_SRPC_ARG_TYPE_INT: 180 case NACL_SRPC_ARG_TYPE_INT:
(...skipping 19 matching lines...) Expand all
200 void MethodMap::AddMethod(uintptr_t method_id, MethodInfo *info) { 200 void MethodMap::AddMethod(uintptr_t method_id, MethodInfo *info) {
201 if (method_map_.find(method_id) != method_map_.end()) { 201 if (method_map_.find(method_id) != method_map_.end()) {
202 // the method already exists 202 // the method already exists
203 abort(); 203 abort();
204 } 204 }
205 method_map_[method_id] = info; 205 method_map_[method_id] = info;
206 method_map_keys_.push_back(method_id); 206 method_map_keys_.push_back(method_id);
207 } 207 }
208 208
209 } // namespace plugin 209 } // namespace plugin
OLDNEW
« no previous file with comments | « src/trusted/plugin/desc_based_handle.cc ('k') | src/trusted/plugin/npapi/plugin_npapi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698