OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/v8_var_converter.h" | 5 #include "content/renderer/pepper/v8_var_converter.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 return false; | 388 return false; |
389 } | 389 } |
390 } | 390 } |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 *result = handle_scope.Escape(root); | 394 *result = handle_scope.Escape(root); |
395 return true; | 395 return true; |
396 } | 396 } |
397 | 397 |
398 void V8VarConverter::FromV8Value( | 398 V8VarConverter::VarResult V8VarConverter::FromV8Value( |
399 v8::Handle<v8::Value> val, | 399 v8::Handle<v8::Value> val, |
400 v8::Handle<v8::Context> context, | 400 v8::Handle<v8::Context> context, |
401 const base::Callback<void(const ScopedPPVar&, bool)>& callback) { | 401 const base::Callback<void(const ScopedPPVar&, bool)>& callback) { |
402 ScopedPPVar result_var; | 402 VarResult result; |
403 if (FromV8ValueInternal(val, context, &result_var)) { | 403 result.success = FromV8ValueInternal(val, context, &result.var); |
404 resource_converter_->Flush(base::Bind(callback, result_var)); | 404 if (!result.success) |
405 } else { | 405 resource_converter_->Reset(); |
406 message_loop_proxy_->PostTask( | 406 result.completed_synchronously = !resource_converter_->NeedsFlush(); |
407 FROM_HERE, | 407 if (!result.completed_synchronously) |
408 base::Bind(callback, result_var, false)); | 408 resource_converter_->Flush(base::Bind(callback, result.var)); |
409 } | 409 |
| 410 return result; |
410 } | 411 } |
411 | 412 |
412 bool V8VarConverter::FromV8ValueInternal( | 413 bool V8VarConverter::FromV8ValueInternal( |
413 v8::Handle<v8::Value> val, | 414 v8::Handle<v8::Value> val, |
414 v8::Handle<v8::Context> context, | 415 v8::Handle<v8::Context> context, |
415 ppapi::ScopedPPVar* result_var) { | 416 ppapi::ScopedPPVar* result_var) { |
416 v8::Context::Scope context_scope(context); | 417 v8::Context::Scope context_scope(context); |
417 v8::HandleScope handle_scope(context->GetIsolate()); | 418 v8::HandleScope handle_scope(context->GetIsolate()); |
418 | 419 |
419 HandleVarMap visited_handles; | 420 HandleVarMap visited_handles; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 std::string(*name_utf8, name_utf8.length()), child_var); | 542 std::string(*name_utf8, name_utf8.length()), child_var); |
542 DCHECK(success); | 543 DCHECK(success); |
543 } | 544 } |
544 } | 545 } |
545 } | 546 } |
546 *result_var = root; | 547 *result_var = root; |
547 return true; | 548 return true; |
548 } | 549 } |
549 | 550 |
550 } // namespace content | 551 } // namespace content |
OLD | NEW |