| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/plugins/ppapi/ppb_var_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_var_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ppapi/c/dev/ppb_var_deprecated.h" | 9 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 10 #include "ppapi/c/ppb_var.h" | 10 #include "ppapi/c/ppb_var.h" |
| 11 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 13 #include "webkit/plugins/ppapi/common.h" | 13 #include "webkit/plugins/ppapi/common.h" |
| 14 #include "webkit/plugins/ppapi/host_globals.h" |
| 14 #include "webkit/plugins/ppapi/npapi_glue.h" | 15 #include "webkit/plugins/ppapi/npapi_glue.h" |
| 15 #include "webkit/plugins/ppapi/npobject_var.h" | 16 #include "webkit/plugins/ppapi/npobject_var.h" |
| 16 #include "webkit/plugins/ppapi/plugin_module.h" | 17 #include "webkit/plugins/ppapi/plugin_module.h" |
| 17 #include "webkit/plugins/ppapi/plugin_object.h" | 18 #include "webkit/plugins/ppapi/plugin_object.h" |
| 18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 19 #include "webkit/plugins/ppapi/resource_tracker.h" | 20 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 20 #include "v8/include/v8.h" | 21 #include "v8/include/v8.h" |
| 21 | 22 |
| 22 using ppapi::NPObjectVar; | 23 using ppapi::NPObjectVar; |
| 24 using ppapi::PpapiGlobals; |
| 23 using ppapi::StringVar; | 25 using ppapi::StringVar; |
| 24 using ppapi::Var; | 26 using ppapi::Var; |
| 25 using WebKit::WebBindings; | 27 using WebKit::WebBindings; |
| 26 | 28 |
| 27 namespace webkit { | 29 namespace webkit { |
| 28 namespace ppapi { | 30 namespace ppapi { |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 const char kInvalidObjectException[] = "Error: Invalid object"; | 34 const char kInvalidObjectException[] = "Error: Invalid object"; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 SetInvalidObjectException(); | 119 SetInvalidObjectException(); |
| 118 } else { | 120 } else { |
| 119 // When the object is valid, we have a valid module to associate | 121 // When the object is valid, we have a valid module to associate |
| 120 set_pp_module(object_->pp_module()); | 122 set_pp_module(object_->pp_module()); |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 NPObjectVar* object() { return object_.get(); } | 126 NPObjectVar* object() { return object_.get(); } |
| 125 | 127 |
| 126 PluginInstance* GetPluginInstance() { | 128 PluginInstance* GetPluginInstance() { |
| 127 return ResourceTracker::Get()->GetInstance(object()->pp_instance()); | 129 return HostGlobals::Get()->host_resource_tracker()->GetInstance( |
| 130 object()->pp_instance()); |
| 128 } | 131 } |
| 129 | 132 |
| 130 protected: | 133 protected: |
| 131 scoped_refptr<NPObjectVar> object_; | 134 scoped_refptr<NPObjectVar> object_; |
| 132 | 135 |
| 133 DISALLOW_COPY_AND_ASSIGN(ObjectAccessorTryCatch); | 136 DISALLOW_COPY_AND_ASSIGN(ObjectAccessorTryCatch); |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 // ObjectAccessiorWithIdentifierTryCatch --------------------------------------- | 139 // ObjectAccessiorWithIdentifierTryCatch --------------------------------------- |
| 137 | 140 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 163 | 166 |
| 164 private: | 167 private: |
| 165 NPIdentifier identifier_; | 168 NPIdentifier identifier_; |
| 166 | 169 |
| 167 DISALLOW_COPY_AND_ASSIGN(ObjectAccessorWithIdentifierTryCatch); | 170 DISALLOW_COPY_AND_ASSIGN(ObjectAccessorWithIdentifierTryCatch); |
| 168 }; | 171 }; |
| 169 | 172 |
| 170 // PPB_Var methods ------------------------------------------------------------- | 173 // PPB_Var methods ------------------------------------------------------------- |
| 171 | 174 |
| 172 void AddRefVar(PP_Var var) { | 175 void AddRefVar(PP_Var var) { |
| 173 ResourceTracker::Get()->GetVarTracker()->AddRefVar(var); | 176 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); |
| 174 } | 177 } |
| 175 | 178 |
| 176 void ReleaseVar(PP_Var var) { | 179 void ReleaseVar(PP_Var var) { |
| 177 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(var); | 180 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); |
| 178 } | 181 } |
| 179 | 182 |
| 180 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { | 183 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { |
| 181 return StringVar::StringToPPVar(module, data, len); | 184 return StringVar::StringToPPVar(module, data, len); |
| 182 } | 185 } |
| 183 | 186 |
| 184 const char* VarToUtf8(PP_Var var, uint32_t* len) { | 187 const char* VarToUtf8(PP_Var var, uint32_t* len) { |
| 185 StringVar* str = StringVar::FromPPVar(var); | 188 StringVar* str = StringVar::FromPPVar(var); |
| 186 if (!str) { | 189 if (!str) { |
| 187 *len = 0; | 190 *len = 0; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 const PPP_Class_Deprecated* ppp_class, | 400 const PPP_Class_Deprecated* ppp_class, |
| 398 void** ppp_class_data) { | 401 void** ppp_class_data) { |
| 399 scoped_refptr<NPObjectVar> object(NPObjectVar::FromPPVar(var)); | 402 scoped_refptr<NPObjectVar> object(NPObjectVar::FromPPVar(var)); |
| 400 if (!object) | 403 if (!object) |
| 401 return false; // Not an object at all. | 404 return false; // Not an object at all. |
| 402 | 405 |
| 403 return PluginObject::IsInstanceOf(object->np_object(), | 406 return PluginObject::IsInstanceOf(object->np_object(), |
| 404 ppp_class, ppp_class_data); | 407 ppp_class, ppp_class_data); |
| 405 } | 408 } |
| 406 | 409 |
| 407 PP_Var CreateObjectDeprecated(PP_Instance instance_id, | 410 PP_Var CreateObjectDeprecated(PP_Instance pp_instance, |
| 408 const PPP_Class_Deprecated* ppp_class, | 411 const PPP_Class_Deprecated* ppp_class, |
| 409 void* ppp_class_data) { | 412 void* ppp_class_data) { |
| 410 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 413 PluginInstance* instance = |
| 414 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
| 411 if (!instance) { | 415 if (!instance) { |
| 412 DLOG(ERROR) << "Create object passed an invalid instance."; | 416 DLOG(ERROR) << "Create object passed an invalid instance."; |
| 413 return PP_MakeNull(); | 417 return PP_MakeNull(); |
| 414 } | 418 } |
| 415 return PluginObject::Create(instance, ppp_class, ppp_class_data); | 419 return PluginObject::Create(instance, ppp_class, ppp_class_data); |
| 416 } | 420 } |
| 417 | 421 |
| 418 PP_Var CreateObjectWithModuleDeprecated(PP_Module module_id, | 422 PP_Var CreateObjectWithModuleDeprecated(PP_Module pp_module, |
| 419 const PPP_Class_Deprecated* ppp_class, | 423 const PPP_Class_Deprecated* ppp_class, |
| 420 void* ppp_class_data) { | 424 void* ppp_class_data) { |
| 421 PluginModule* module = ResourceTracker::Get()->GetModule(module_id); | 425 PluginModule* module = |
| 426 HostGlobals::Get()->host_resource_tracker()->GetModule(pp_module); |
| 422 if (!module) | 427 if (!module) |
| 423 return PP_MakeNull(); | 428 return PP_MakeNull(); |
| 424 return PluginObject::Create(module->GetSomeInstance(), | 429 return PluginObject::Create(module->GetSomeInstance(), |
| 425 ppp_class, ppp_class_data); | 430 ppp_class, ppp_class_data); |
| 426 } | 431 } |
| 427 | 432 |
| 428 const PPB_Var_Deprecated var_deprecated_interface = { | 433 const PPB_Var_Deprecated var_deprecated_interface = { |
| 429 &AddRefVar, | 434 &AddRefVar, |
| 430 &ReleaseVar, | 435 &ReleaseVar, |
| 431 &VarFromUtf8, | 436 &VarFromUtf8, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 458 } | 463 } |
| 459 | 464 |
| 460 // static | 465 // static |
| 461 const PPB_Var_Deprecated* PPB_Var_Impl::GetVarDeprecatedInterface() { | 466 const PPB_Var_Deprecated* PPB_Var_Impl::GetVarDeprecatedInterface() { |
| 462 return &var_deprecated_interface; | 467 return &var_deprecated_interface; |
| 463 } | 468 } |
| 464 | 469 |
| 465 } // namespace ppapi | 470 } // namespace ppapi |
| 466 } // namespace webkit | 471 } // namespace webkit |
| 467 | 472 |
| OLD | NEW |