OLD | NEW |
---|---|
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/interface_proxy.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 ReceiveSerializedVarReturnValue::ReceiveSerializedVarReturnValue() { | 266 ReceiveSerializedVarReturnValue::ReceiveSerializedVarReturnValue() { |
267 } | 267 } |
268 | 268 |
269 PP_Var ReceiveSerializedVarReturnValue::Return(Dispatcher* dispatcher) { | 269 PP_Var ReceiveSerializedVarReturnValue::Return(Dispatcher* dispatcher) { |
270 inner_->set_serialization_rules(dispatcher->serialization_rules()); | 270 inner_->set_serialization_rules(dispatcher->serialization_rules()); |
271 inner_->SetVar(inner_->serialization_rules()->ReceivePassRef( | 271 inner_->SetVar(inner_->serialization_rules()->ReceivePassRef( |
272 inner_->GetIncompleteVar(), inner_->GetString(), dispatcher)); | 272 inner_->GetIncompleteVar(), inner_->GetString(), dispatcher)); |
273 return inner_->GetVar(); | 273 return inner_->GetVar(); |
274 } | 274 } |
275 | 275 |
276 // static | |
277 PP_Var ReceiveSerializedVarReturnValue::Convert( | |
278 Dispatcher* dispatcher, | |
279 const SerializedVar& serialized) { | |
280 // Emulate how this is called when receiving a return value. | |
281 ReceiveSerializedVarReturnValue ret; | |
282 static_cast<SerializedVar&>(ret) = serialized; | |
piman
2011/02/17 21:25:07
How about adding an explicit constructor for Recei
| |
283 return ret.Return(dispatcher); | |
284 } | |
285 | |
276 // ReceiveSerializedException -------------------------------------------------- | 286 // ReceiveSerializedException -------------------------------------------------- |
277 | 287 |
278 ReceiveSerializedException::ReceiveSerializedException(Dispatcher* dispatcher, | 288 ReceiveSerializedException::ReceiveSerializedException(Dispatcher* dispatcher, |
279 PP_Var* exception) | 289 PP_Var* exception) |
280 : SerializedVar(dispatcher->serialization_rules()), | 290 : SerializedVar(dispatcher->serialization_rules()), |
281 dispatcher_(dispatcher), | 291 dispatcher_(dispatcher), |
282 exception_(exception) { | 292 exception_(exception) { |
283 } | 293 } |
284 | 294 |
285 ReceiveSerializedException::~ReceiveSerializedException() { | 295 ReceiveSerializedException::~ReceiveSerializedException() { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 424 |
415 // Var must clean up after our BeginSendPassRef call. | 425 // Var must clean up after our BeginSendPassRef call. |
416 serialized_->inner_->SetCleanupModeToEndSendPassRef(dispatcher); | 426 serialized_->inner_->SetCleanupModeToEndSendPassRef(dispatcher); |
417 | 427 |
418 serialized_->inner_->SetVar( | 428 serialized_->inner_->SetVar( |
419 dispatcher->serialization_rules()->BeginSendPassRef( | 429 dispatcher->serialization_rules()->BeginSendPassRef( |
420 var, | 430 var, |
421 serialized_->inner_->GetStringPtr())); | 431 serialized_->inner_->GetStringPtr())); |
422 } | 432 } |
423 | 433 |
434 // static | |
435 SerializedVar SerializedVarReturnValue::Convert(Dispatcher* dispatcher, | |
436 const PP_Var& var) { | |
437 // Mimic what happens in the normal case. | |
438 SerializedVar result; | |
439 SerializedVarReturnValue retvalue(&result); | |
440 retvalue.Return(dispatcher, var); | |
441 return result; | |
442 } | |
443 | |
424 // SerializedVarOutParam ------------------------------------------------------- | 444 // SerializedVarOutParam ------------------------------------------------------- |
425 | 445 |
426 SerializedVarOutParam::SerializedVarOutParam(SerializedVar* serialized) | 446 SerializedVarOutParam::SerializedVarOutParam(SerializedVar* serialized) |
427 : serialized_(serialized), | 447 : serialized_(serialized), |
428 writable_var_(PP_MakeUndefined()), | 448 writable_var_(PP_MakeUndefined()), |
429 dispatcher_(NULL) { | 449 dispatcher_(NULL) { |
430 } | 450 } |
431 | 451 |
432 SerializedVarOutParam::~SerializedVarOutParam() { | 452 SerializedVarOutParam::~SerializedVarOutParam() { |
433 if (serialized_->inner_->serialization_rules()) { | 453 if (serialized_->inner_->serialization_rules()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 *inner_->GetStringPtr() = str; | 522 *inner_->GetStringPtr() = str; |
503 } | 523 } |
504 | 524 |
505 SerializedVarTestReader::SerializedVarTestReader(const SerializedVar& var) | 525 SerializedVarTestReader::SerializedVarTestReader(const SerializedVar& var) |
506 : SerializedVar(var) { | 526 : SerializedVar(var) { |
507 } | 527 } |
508 | 528 |
509 } // namespace proxy | 529 } // namespace proxy |
510 } // namespace pp | 530 } // namespace pp |
511 | 531 |
OLD | NEW |