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