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

Side by Side Diff: content/renderer/pepper/message_channel.cc

Issue 331593002: Change V8VarConverter::FromV8Value to complete synchronously if possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « no previous file | content/renderer/pepper/resource_converter.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 "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
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::VarResult conversion_result =
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
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
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/resource_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698