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

Side by Side Diff: webkit/plugins/ppapi/var.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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
OLDNEW
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/plugins/ppapi/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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "ppapi/c/dev/ppb_var_deprecated.h" 12 #include "ppapi/c/dev/ppb_var_deprecated.h"
13 #include "ppapi/c/ppb_var.h" 13 #include "ppapi/c/ppb_var.h"
14 #include "ppapi/c/pp_var.h" 14 #include "ppapi/c/pp_var.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
16 #include "webkit/glue/plugins/pepper_common.h" 16 #include "webkit/plugins/ppapi/common.h"
17 #include "webkit/glue/plugins/pepper_plugin_instance.h" 17 #include "webkit/plugins/ppapi/plugin_instance.h"
18 #include "webkit/glue/plugins/pepper_plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
19 #include "webkit/glue/plugins/pepper_plugin_object.h" 19 #include "webkit/plugins/ppapi/plugin_object.h"
20 #include "v8/include/v8.h" 20 #include "v8/include/v8.h"
21 21
22 using WebKit::WebBindings; 22 using WebKit::WebBindings;
23 23
24 namespace pepper { 24 namespace webkit {
25 namespace plugins {
26 namespace ppapi {
25 27
26 namespace { 28 namespace {
27 29
28 const char kInvalidObjectException[] = "Error: Invalid object"; 30 const char kInvalidObjectException[] = "Error: Invalid object";
29 const char kInvalidPropertyException[] = "Error: Invalid property"; 31 const char kInvalidPropertyException[] = "Error: Invalid property";
30 const char kInvalidValueException[] = "Error: Invalid value"; 32 const char kInvalidValueException[] = "Error: Invalid value";
31 const char kUnableToGetPropertyException[] = "Error: Unable to get property"; 33 const char kUnableToGetPropertyException[] = "Error: Unable to get property";
32 const char kUnableToSetPropertyException[] = "Error: Unable to set property"; 34 const char kUnableToSetPropertyException[] = "Error: Unable to set property";
33 const char kUnableToRemovePropertyException[] = 35 const char kUnableToRemovePropertyException[] =
34 "Error: Unable to remove property"; 36 "Error: Unable to remove property";
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } // namespace 647 } // namespace
646 648
647 // Var ------------------------------------------------------------------------- 649 // Var -------------------------------------------------------------------------
648 650
649 Var::Var(PluginModule* module) : Resource(module) { 651 Var::Var(PluginModule* module) : Resource(module) {
650 } 652 }
651 653
652 Var::~Var() { 654 Var::~Var() {
653 } 655 }
654 656
657 Var* Var::AsVar() {
658 return this;
659 }
660
655 // static 661 // static
656 PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) { 662 PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) {
657 switch (variant->type) { 663 switch (variant->type) {
658 case NPVariantType_Void: 664 case NPVariantType_Void:
659 return PP_MakeUndefined(); 665 return PP_MakeUndefined();
660 case NPVariantType_Null: 666 case NPVariantType_Null:
661 return PP_MakeNull(); 667 return PP_MakeNull();
662 case NPVariantType_Bool: 668 case NPVariantType_Bool:
663 return BoolToPPVar(NPVARIANT_TO_BOOLEAN(*variant)); 669 return BoolToPPVar(NPVARIANT_TO_BOOLEAN(*variant));
664 case NPVariantType_Int32: 670 case NPVariantType_Int32:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // StringVar ------------------------------------------------------------------- 743 // StringVar -------------------------------------------------------------------
738 744
739 StringVar::StringVar(PluginModule* module, const char* str, uint32 len) 745 StringVar::StringVar(PluginModule* module, const char* str, uint32 len)
740 : Var(module), 746 : Var(module),
741 value_(str, len) { 747 value_(str, len) {
742 } 748 }
743 749
744 StringVar::~StringVar() { 750 StringVar::~StringVar() {
745 } 751 }
746 752
753 StringVar* StringVar::AsStringVar() {
754 return this;
755 }
756
747 // static 757 // static
748 PP_Var StringVar::StringToPPVar(PluginModule* module, const std::string& var) { 758 PP_Var StringVar::StringToPPVar(PluginModule* module, const std::string& var) {
749 return StringToPPVar(module, var.c_str(), var.size()); 759 return StringToPPVar(module, var.c_str(), var.size());
750 } 760 }
751 761
752 // static 762 // static
753 PP_Var StringVar::StringToPPVar(PluginModule* module, 763 PP_Var StringVar::StringToPPVar(PluginModule* module,
754 const char* data, uint32 len) { 764 const char* data, uint32 len) {
755 scoped_refptr<StringVar> str(new StringVar(module, data, len)); 765 scoped_refptr<StringVar> str(new StringVar(module, data, len));
756 if (!str || !IsStringUTF8(str->value())) 766 if (!str || !IsStringUTF8(str->value()))
(...skipping 21 matching lines...) Expand all
778 np_object_(np_object) { 788 np_object_(np_object) {
779 WebBindings::retainObject(np_object_); 789 WebBindings::retainObject(np_object_);
780 module->AddNPObjectVar(this); 790 module->AddNPObjectVar(this);
781 } 791 }
782 792
783 ObjectVar::~ObjectVar() { 793 ObjectVar::~ObjectVar() {
784 module()->RemoveNPObjectVar(this); 794 module()->RemoveNPObjectVar(this);
785 WebBindings::releaseObject(np_object_); 795 WebBindings::releaseObject(np_object_);
786 } 796 }
787 797
798 ObjectVar* ObjectVar::AsObjectVar() {
799 return this;
800 }
801
788 // static 802 // static
789 PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) { 803 PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) {
790 scoped_refptr<ObjectVar> object_var(module->ObjectVarForNPObject(object)); 804 scoped_refptr<ObjectVar> object_var(module->ObjectVarForNPObject(object));
791 if (!object_var) // No object for this module yet, make a new one. 805 if (!object_var) // No object for this module yet, make a new one.
792 object_var = new ObjectVar(module, object); 806 object_var = new ObjectVar(module, object);
793 807
794 if (!object_var) 808 if (!object_var)
795 return PP_MakeUndefined(); 809 return PP_MakeUndefined();
796 810
797 // Convert to a PP_Var, GetReference will AddRef for us. 811 // Convert to a PP_Var, GetReference will AddRef for us.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 if (exception_) 857 if (exception_)
844 *exception_ = PP_MakeInt32(1); 858 *exception_ = PP_MakeInt32(1);
845 } 859 }
846 } 860 }
847 861
848 // static 862 // static
849 void TryCatch::Catch(void* self, const char* message) { 863 void TryCatch::Catch(void* self, const char* message) {
850 static_cast<TryCatch*>(self)->SetException(message); 864 static_cast<TryCatch*>(self)->SetException(message);
851 } 865 }
852 866
853 } // namespace pepper 867 } // namespace ppapi
868 } // namespace plugins
869 } // namespace webkit
870
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698