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 "webkit/glue/plugins/pepper_var.h" | 5 #include "webkit/glue/plugins/pepper_var.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 return StringVar::StringToPPVar(module, string_value); | 707 return StringVar::StringToPPVar(module, string_value); |
708 | 708 |
709 return PP_MakeInt32(int_value); | 709 return PP_MakeInt32(int_value); |
710 } | 710 } |
711 | 711 |
712 // static | 712 // static |
713 void Var::PluginAddRefPPVar(PP_Var var) { | 713 void Var::PluginAddRefPPVar(PP_Var var) { |
714 if (var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT) { | 714 if (var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT) { |
715 // TODO(brettw) consider checking that the ID is actually a var ID rather | 715 // TODO(brettw) consider checking that the ID is actually a var ID rather |
716 // than some random other resource ID. | 716 // than some random other resource ID. |
717 if (!ResourceTracker::Get()->AddRefResource(var.value.as_id)) | 717 PP_Resource resource = static_cast<PP_Resource>(var.value.as_id); |
| 718 if (!ResourceTracker::Get()->AddRefResource(resource)) |
718 DLOG(WARNING) << "AddRefVar()ing a nonexistant string/object var."; | 719 DLOG(WARNING) << "AddRefVar()ing a nonexistant string/object var."; |
719 } | 720 } |
720 } | 721 } |
721 | 722 |
722 // static | 723 // static |
723 void Var::PluginReleasePPVar(PP_Var var) { | 724 void Var::PluginReleasePPVar(PP_Var var) { |
724 if (var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT) { | 725 if (var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT) { |
725 // TODO(brettw) consider checking that the ID is actually a var ID rather | 726 // TODO(brettw) consider checking that the ID is actually a var ID rather |
726 // than some random other resource ID. | 727 // than some random other resource ID. |
727 if (!ResourceTracker::Get()->UnrefResource(var.value.as_id)) | 728 PP_Resource resource = static_cast<PP_Resource>(var.value.as_id); |
| 729 if (!ResourceTracker::Get()->UnrefResource(resource)) |
728 DLOG(WARNING) << "ReleaseVar()ing a nonexistant string/object var."; | 730 DLOG(WARNING) << "ReleaseVar()ing a nonexistant string/object var."; |
729 } | 731 } |
730 } | 732 } |
731 | 733 |
732 // static | 734 // static |
733 const PPB_Var_Deprecated* Var::GetDeprecatedInterface() { | 735 const PPB_Var_Deprecated* Var::GetDeprecatedInterface() { |
734 return &var_deprecated_interface; | 736 return &var_deprecated_interface; |
735 } | 737 } |
736 | 738 |
737 const PPB_Var* Var::GetInterface() { | 739 const PPB_Var* Var::GetInterface() { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 | 771 |
770 // The caller takes ownership now. | 772 // The caller takes ownership now. |
771 ret.value.as_id = str->GetReference(); | 773 ret.value.as_id = str->GetReference(); |
772 return ret; | 774 return ret; |
773 } | 775 } |
774 | 776 |
775 // static | 777 // static |
776 scoped_refptr<StringVar> StringVar::FromPPVar(PP_Var var) { | 778 scoped_refptr<StringVar> StringVar::FromPPVar(PP_Var var) { |
777 if (var.type != PP_VARTYPE_STRING) | 779 if (var.type != PP_VARTYPE_STRING) |
778 return scoped_refptr<StringVar>(NULL); | 780 return scoped_refptr<StringVar>(NULL); |
779 return Resource::GetAs<StringVar>(var.value.as_id); | 781 PP_Resource resource = static_cast<PP_Resource>(var.value.as_id); |
| 782 return Resource::GetAs<StringVar>(resource); |
780 } | 783 } |
781 | 784 |
782 // ObjectVar ------------------------------------------------------------- | 785 // ObjectVar ------------------------------------------------------------- |
783 | 786 |
784 ObjectVar::ObjectVar(PluginModule* module, NPObject* np_object) | 787 ObjectVar::ObjectVar(PluginModule* module, NPObject* np_object) |
785 : Var(module), | 788 : Var(module), |
786 np_object_(np_object) { | 789 np_object_(np_object) { |
787 WebBindings::retainObject(np_object_); | 790 WebBindings::retainObject(np_object_); |
788 module->AddNPObjectVar(this); | 791 module->AddNPObjectVar(this); |
789 } | 792 } |
(...skipping 20 matching lines...) Expand all Loading... |
810 PP_Var result; | 813 PP_Var result; |
811 result.type = PP_VARTYPE_OBJECT; | 814 result.type = PP_VARTYPE_OBJECT; |
812 result.value.as_id = object_var->GetReference(); | 815 result.value.as_id = object_var->GetReference(); |
813 return result; | 816 return result; |
814 } | 817 } |
815 | 818 |
816 // static | 819 // static |
817 scoped_refptr<ObjectVar> ObjectVar::FromPPVar(PP_Var var) { | 820 scoped_refptr<ObjectVar> ObjectVar::FromPPVar(PP_Var var) { |
818 if (var.type != PP_VARTYPE_OBJECT) | 821 if (var.type != PP_VARTYPE_OBJECT) |
819 return scoped_refptr<ObjectVar>(NULL); | 822 return scoped_refptr<ObjectVar>(NULL); |
820 return Resource::GetAs<ObjectVar>(var.value.as_id); | 823 PP_Resource resource = static_cast<PP_Resource>(var.value.as_id); |
| 824 return Resource::GetAs<ObjectVar>(resource); |
821 } | 825 } |
822 | 826 |
823 // TryCatch -------------------------------------------------------------------- | 827 // TryCatch -------------------------------------------------------------------- |
824 | 828 |
825 TryCatch::TryCatch(PluginModule* module, PP_Var* exception) | 829 TryCatch::TryCatch(PluginModule* module, PP_Var* exception) |
826 : module_(module), | 830 : module_(module), |
827 has_exception_(exception && exception->type != PP_VARTYPE_UNDEFINED), | 831 has_exception_(exception && exception->type != PP_VARTYPE_UNDEFINED), |
828 exception_(exception) { | 832 exception_(exception) { |
829 WebBindings::pushExceptionHandler(&TryCatch::Catch, this); | 833 WebBindings::pushExceptionHandler(&TryCatch::Catch, this); |
830 } | 834 } |
(...skipping 25 matching lines...) Expand all Loading... |
856 *exception_ = PP_MakeInt32(1); | 860 *exception_ = PP_MakeInt32(1); |
857 } | 861 } |
858 } | 862 } |
859 | 863 |
860 // static | 864 // static |
861 void TryCatch::Catch(void* self, const char* message) { | 865 void TryCatch::Catch(void* self, const char* message) { |
862 static_cast<TryCatch*>(self)->SetException(message); | 866 static_cast<TryCatch*>(self)->SetException(message); |
863 } | 867 } |
864 | 868 |
865 } // namespace pepper | 869 } // namespace pepper |
OLD | NEW |