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

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

Issue 9373032: PPAPI: Proxy VarArrayBuffer for out-of-process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/ref_counted.h"
8 #include "ipc/ipc_message_utils.h" 9 #include "ipc/ipc_message_utils.h"
9 #include "ppapi/proxy/dispatcher.h" 10 #include "ppapi/proxy/dispatcher.h"
10 #include "ppapi/proxy/interface_proxy.h" 11 #include "ppapi/proxy/interface_proxy.h"
11 #include "ppapi/proxy/ppapi_param_traits.h" 12 #include "ppapi/proxy/ppapi_param_traits.h"
12 #include "ppapi/proxy/var_serialization_rules.h" 13 #include "ppapi/proxy/var_serialization_rules.h"
14 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/var.h" 15 #include "ppapi/shared_impl/var.h"
14 16
15 namespace ppapi { 17 namespace ppapi {
16 namespace proxy { 18 namespace proxy {
17 19
18 // SerializedVar::Inner -------------------------------------------------------- 20 // SerializedVar::Inner --------------------------------------------------------
19 21
20 SerializedVar::Inner::Inner() 22 SerializedVar::Inner::Inner()
21 : serialization_rules_(NULL), 23 : serialization_rules_(NULL),
22 var_(PP_MakeUndefined()), 24 var_(PP_MakeUndefined()),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 case PP_VARTYPE_STRING: { 111 case PP_VARTYPE_STRING: {
110 // TODO(brettw) in the case of an invalid string ID, it would be nice 112 // TODO(brettw) in the case of an invalid string ID, it would be nice
111 // to send something to the other side such that a 0 ID would be 113 // to send something to the other side such that a 0 ID would be
112 // generated there. Then the function implementing the interface can 114 // generated there. Then the function implementing the interface can
113 // handle the invalid string as if it was in process rather than seeing 115 // handle the invalid string as if it was in process rather than seeing
114 // what looks like a valid empty string. 116 // what looks like a valid empty string.
115 StringVar* string_var = StringVar::FromPPVar(var_); 117 StringVar* string_var = StringVar::FromPPVar(var_);
116 m->WriteString(string_var ? *string_var->ptr() : std::string()); 118 m->WriteString(string_var ? *string_var->ptr() : std::string());
117 break; 119 break;
118 } 120 }
119 case PP_VARTYPE_ARRAY_BUFFER: 121 case PP_VARTYPE_ARRAY_BUFFER: {
120 // TODO(dmichael): Proxy ArrayBuffer. 122 // TODO(dmichael) in the case of an invalid var ID, it would be nice
121 NOTIMPLEMENTED(); 123 // to send something to the other side such that a 0 ID would be
124 // generated there. Then the function implementing the interface can
125 // handle the invalid string as if it was in process rather than seeing
126 // what looks like a valid empty ArraryBuffer
brettw 2012/02/09 19:23:22 Can you also put a TODO in here for unmapping if i
127 ArrayBufferVar* buffer_var = ArrayBufferVar::FromPPVar(var_);
128 if (buffer_var) {
129 m->WriteData(static_cast<const char*>(buffer_var->Map()),
130 buffer_var->ByteLength());
131 } else {
132 m->WriteData(NULL, 0);
133 }
122 break; 134 break;
135 }
123 case PP_VARTYPE_OBJECT: 136 case PP_VARTYPE_OBJECT:
124 m->WriteInt64(var_.value.as_id); 137 m->WriteInt64(var_.value.as_id);
125 break; 138 break;
126 case PP_VARTYPE_ARRAY: 139 case PP_VARTYPE_ARRAY:
127 case PP_VARTYPE_DICTIONARY: 140 case PP_VARTYPE_DICTIONARY:
128 // TODO(brettw) when these are supported, implement this. 141 // TODO(brettw) when these are supported, implement this.
129 NOTIMPLEMENTED(); 142 NOTIMPLEMENTED();
130 break; 143 break;
131 } 144 }
132 } 145 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 break; 182 break;
170 case PP_VARTYPE_DOUBLE: 183 case PP_VARTYPE_DOUBLE:
171 success = IPC::ParamTraits<double>::Read(m, iter, &var_.value.as_double); 184 success = IPC::ParamTraits<double>::Read(m, iter, &var_.value.as_double);
172 break; 185 break;
173 case PP_VARTYPE_STRING: { 186 case PP_VARTYPE_STRING: {
174 std::string string_from_ipc; 187 std::string string_from_ipc;
175 success = m->ReadString(iter, &string_from_ipc); 188 success = m->ReadString(iter, &string_from_ipc);
176 var_ = StringVar::SwapValidatedUTF8StringIntoPPVar(&string_from_ipc); 189 var_ = StringVar::SwapValidatedUTF8StringIntoPPVar(&string_from_ipc);
177 break; 190 break;
178 } 191 }
192 case PP_VARTYPE_ARRAY_BUFFER: {
193 int length = 0;
194 const char* message_bytes = NULL;
195 success = m->ReadData(iter, &message_bytes, &length);
196 if (success) {
197 var_ = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
198 length, message_bytes);
199 }
200 break;
201 }
179 case PP_VARTYPE_OBJECT: 202 case PP_VARTYPE_OBJECT:
180 success = m->ReadInt64(iter, &var_.value.as_id); 203 success = m->ReadInt64(iter, &var_.value.as_id);
181 break; 204 break;
182 case PP_VARTYPE_ARRAY: 205 case PP_VARTYPE_ARRAY:
183 case PP_VARTYPE_DICTIONARY: 206 case PP_VARTYPE_DICTIONARY:
184 // TODO(brettw) when these types are supported, implement this. 207 // TODO(brettw) when these types are supported, implement this.
185 NOTIMPLEMENTED(); 208 NOTIMPLEMENTED();
186 break; 209 break;
187 default: 210 default:
188 // Leave success as false. 211 // Leave success as false.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 inner_->ForceSetVarValueForTest(StringVar::StringToPPVar(str)); 511 inner_->ForceSetVarValueForTest(StringVar::StringToPPVar(str));
489 } 512 }
490 513
491 SerializedVarTestReader::SerializedVarTestReader(const SerializedVar& var) 514 SerializedVarTestReader::SerializedVarTestReader(const SerializedVar& var)
492 : SerializedVar(var) { 515 : SerializedVar(var) {
493 } 516 }
494 517
495 } // namespace proxy 518 } // namespace proxy
496 } // namespace ppapi 519 } // namespace ppapi
497 520
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698