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

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: merge... again 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
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/shared_impl/var_tracker.h » ('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) 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.
127 ArrayBufferVar* buffer_var = ArrayBufferVar::FromPPVar(var_);
128 if (buffer_var) {
129 // TODO(dmichael): If it wasn't already Mapped, Unmap it. (Though once
130 // we use shared memory, this will probably be
131 // completely different anyway).
132 m->WriteData(static_cast<const char*>(buffer_var->Map()),
133 buffer_var->ByteLength());
134 } else {
135 m->WriteData(NULL, 0);
136 }
122 break; 137 break;
138 }
123 case PP_VARTYPE_OBJECT: 139 case PP_VARTYPE_OBJECT:
124 m->WriteInt64(var_.value.as_id); 140 m->WriteInt64(var_.value.as_id);
125 break; 141 break;
126 case PP_VARTYPE_ARRAY: 142 case PP_VARTYPE_ARRAY:
127 case PP_VARTYPE_DICTIONARY: 143 case PP_VARTYPE_DICTIONARY:
128 // TODO(brettw) when these are supported, implement this. 144 // TODO(brettw) when these are supported, implement this.
129 NOTIMPLEMENTED(); 145 NOTIMPLEMENTED();
130 break; 146 break;
131 } 147 }
132 } 148 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 break; 185 break;
170 case PP_VARTYPE_DOUBLE: 186 case PP_VARTYPE_DOUBLE:
171 success = IPC::ParamTraits<double>::Read(m, iter, &var_.value.as_double); 187 success = IPC::ParamTraits<double>::Read(m, iter, &var_.value.as_double);
172 break; 188 break;
173 case PP_VARTYPE_STRING: { 189 case PP_VARTYPE_STRING: {
174 std::string string_from_ipc; 190 std::string string_from_ipc;
175 success = m->ReadString(iter, &string_from_ipc); 191 success = m->ReadString(iter, &string_from_ipc);
176 var_ = StringVar::SwapValidatedUTF8StringIntoPPVar(&string_from_ipc); 192 var_ = StringVar::SwapValidatedUTF8StringIntoPPVar(&string_from_ipc);
177 break; 193 break;
178 } 194 }
195 case PP_VARTYPE_ARRAY_BUFFER: {
196 int length = 0;
197 const char* message_bytes = NULL;
198 success = m->ReadData(iter, &message_bytes, &length);
199 if (success) {
200 var_ = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
201 length, message_bytes);
202 }
203 break;
204 }
179 case PP_VARTYPE_OBJECT: 205 case PP_VARTYPE_OBJECT:
180 success = m->ReadInt64(iter, &var_.value.as_id); 206 success = m->ReadInt64(iter, &var_.value.as_id);
181 break; 207 break;
182 case PP_VARTYPE_ARRAY: 208 case PP_VARTYPE_ARRAY:
183 case PP_VARTYPE_DICTIONARY: 209 case PP_VARTYPE_DICTIONARY:
184 // TODO(brettw) when these types are supported, implement this. 210 // TODO(brettw) when these types are supported, implement this.
185 NOTIMPLEMENTED(); 211 NOTIMPLEMENTED();
186 break; 212 break;
187 default: 213 default:
188 // Leave success as false. 214 // Leave success as false.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 inner_->ForceSetVarValueForTest(StringVar::StringToPPVar(str)); 514 inner_->ForceSetVarValueForTest(StringVar::StringToPPVar(str));
489 } 515 }
490 516
491 SerializedVarTestReader::SerializedVarTestReader(const SerializedVar& var) 517 SerializedVarTestReader::SerializedVarTestReader(const SerializedVar& var)
492 : SerializedVar(var) { 518 : SerializedVar(var) {
493 } 519 }
494 520
495 } // namespace proxy 521 } // namespace proxy
496 } // namespace ppapi 522 } // namespace ppapi
497 523
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/shared_impl/var_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698