| Index: ppapi/proxy/ppb_var_deprecated_proxy.cc
|
| ===================================================================
|
| --- ppapi/proxy/ppb_var_deprecated_proxy.cc (revision 95769)
|
| +++ ppapi/proxy/ppb_var_deprecated_proxy.cc (working copy)
|
| @@ -14,11 +14,15 @@
|
| #include "ppapi/c/ppb_core.h"
|
| #include "ppapi/proxy/host_dispatcher.h"
|
| #include "ppapi/proxy/plugin_dispatcher.h"
|
| +#include "ppapi/proxy/plugin_resource_tracker.h"
|
| #include "ppapi/proxy/plugin_var_tracker.h"
|
| #include "ppapi/proxy/ppapi_messages.h"
|
| #include "ppapi/proxy/ppp_class_proxy.h"
|
| #include "ppapi/proxy/serialized_var.h"
|
| +#include "ppapi/shared_impl/var.h"
|
|
|
| +using ppapi::StringVar;
|
| +
|
| namespace pp {
|
| namespace proxy {
|
|
|
| @@ -35,17 +39,20 @@
|
| if (exception && exception->type != PP_VARTYPE_UNDEFINED)
|
| return NULL;
|
|
|
| - PluginVarTracker* tracker = PluginVarTracker::GetInstance();
|
| - PluginDispatcher* dispatcher = tracker->DispatcherForPluginObject(object);
|
| - if (dispatcher)
|
| - return dispatcher;
|
|
|
| + if (object.type == PP_VARTYPE_OBJECT) {
|
| + // Get the dispatcher for the object.
|
| + PluginDispatcher* dispatcher = PluginResourceTracker::GetInstance()->
|
| + var_tracker().DispatcherForPluginObject(object);
|
| + if (dispatcher)
|
| + return dispatcher;
|
| + }
|
| +
|
| // The object is invalid. This means we can't figure out which dispatcher
|
| // to use, which is OK because the call will fail anyway. Set the exception.
|
| if (exception) {
|
| - exception->type = PP_VARTYPE_STRING;
|
| - exception->value.as_id =
|
| - tracker->MakeString("Attempting to use an invalid object");
|
| + *exception = StringVar::StringToPPVar(0,
|
| + std::string("Attempting to use an invalid object"));
|
| }
|
| return NULL;
|
| }
|
| @@ -53,27 +60,22 @@
|
| // PPP_Var_Deprecated plugin ---------------------------------------------------
|
|
|
| void AddRefVar(PP_Var var) {
|
| - PluginVarTracker::GetInstance()->AddRef(var);
|
| + PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(var);
|
| }
|
|
|
| void ReleaseVar(PP_Var var) {
|
| - PluginVarTracker::GetInstance()->Release(var);
|
| + PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(var);
|
| }
|
|
|
| PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
|
| - PP_Var ret = {};
|
| - ret.type = PP_VARTYPE_STRING;
|
| - ret.value.as_id = PluginVarTracker::GetInstance()->MakeString(
|
| - data, len);
|
| - return ret;
|
| + return StringVar::StringToPPVar(module, data, len);
|
| }
|
|
|
| const char* VarToUtf8(PP_Var var, uint32_t* len) {
|
| - const std::string* str =
|
| - PluginVarTracker::GetInstance()->GetExistingString(var);
|
| + scoped_refptr<StringVar> str(StringVar::FromPPVar(var));
|
| if (str) {
|
| - *len = static_cast<uint32_t>(str->size());
|
| - return str->c_str();
|
| + *len = static_cast<uint32_t>(str->value().size());
|
| + return str->value().c_str();
|
| }
|
| *len = 0;
|
| return NULL;
|
|
|