OLD | NEW |
---|---|
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 "content/renderer/pepper/message_channel.h" | 5 #include "content/renderer/pepper/message_channel.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 plugin_message_queue_.push_back(VarConversionResult()); | 287 plugin_message_queue_.push_back(VarConversionResult()); |
288 if (variant->type == NPVariantType_Object) { | 288 if (variant->type == NPVariantType_Object) { |
289 // Convert NPVariantType_Object in to an appropriate PP_Var like Dictionary, | 289 // Convert NPVariantType_Object in to an appropriate PP_Var like Dictionary, |
290 // Array, etc. Note NPVariantToVar would convert to an "Object" PP_Var, | 290 // Array, etc. Note NPVariantToVar would convert to an "Object" PP_Var, |
291 // which we don't support for Messaging. | 291 // which we don't support for Messaging. |
292 | 292 |
293 // Calling WebBindings::toV8Value creates a wrapper around NPVariant so it | 293 // Calling WebBindings::toV8Value creates a wrapper around NPVariant so it |
294 // won't result in a deep copy. | 294 // won't result in a deep copy. |
295 v8::Handle<v8::Value> v8_value = WebBindings::toV8Value(variant); | 295 v8::Handle<v8::Value> v8_value = WebBindings::toV8Value(variant); |
296 V8VarConverter v8_var_converter(instance_->pp_instance()); | 296 V8VarConverter v8_var_converter(instance_->pp_instance()); |
297 v8_var_converter.FromV8Value( | 297 V8VarConverter::VarConversionResult conversion_result = |
dmichael (off chromium)
2014/06/13 17:24:48
Being nested, maybe it would be enough to call it
raymes
2014/06/16 02:59:25
Done. Well caught - I didn't notice the local clas
| |
298 v8_value, | 298 v8_var_converter.FromV8Value( |
299 v8::Isolate::GetCurrent()->GetCurrentContext(), | 299 v8_value, |
300 base::Bind(&MessageChannel::FromV8ValueComplete, | 300 v8::Isolate::GetCurrent()->GetCurrentContext(), |
301 weak_ptr_factory_.GetWeakPtr(), | 301 base::Bind(&MessageChannel::FromV8ValueComplete, |
302 &plugin_message_queue_.back())); | 302 weak_ptr_factory_.GetWeakPtr(), |
303 &plugin_message_queue_.back())); | |
304 if (conversion_result.completed_synchronously) { | |
305 plugin_message_queue_.back().ConversionCompleted( | |
306 conversion_result.var, | |
307 conversion_result.success); | |
308 } | |
303 } else { | 309 } else { |
304 plugin_message_queue_.back().ConversionCompleted( | 310 plugin_message_queue_.back().ConversionCompleted( |
305 ScopedPPVar(ScopedPPVar::PassRef(), | 311 ScopedPPVar(ScopedPPVar::PassRef(), |
306 NPVariantToPPVar(instance(), variant)), | 312 NPVariantToPPVar(instance(), variant)), |
307 true); | 313 true); |
308 DCHECK(plugin_message_queue_.back().var().get().type != PP_VARTYPE_OBJECT); | 314 DCHECK(plugin_message_queue_.back().var().get().type != PP_VARTYPE_OBJECT); |
309 } | 315 } |
310 } | 316 } |
311 | 317 |
312 void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { | 318 void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 return true; | 479 return true; |
474 } | 480 } |
475 return false; | 481 return false; |
476 } | 482 } |
477 | 483 |
478 void MessageChannel::SetReadOnlyProperty(PP_Var key, PP_Var value) { | 484 void MessageChannel::SetReadOnlyProperty(PP_Var key, PP_Var value) { |
479 internal_properties_[PPVarToNPIdentifier(key)] = ScopedPPVar(value); | 485 internal_properties_[PPVarToNPIdentifier(key)] = ScopedPPVar(value); |
480 } | 486 } |
481 | 487 |
482 } // namespace content | 488 } // namespace content |
OLD | NEW |