| 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/npobject_var.h" | 5 #include "webkit/plugins/ppapi/npobject_var.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 10 #include "webkit/plugins/ppapi/host_globals.h" |
| 10 #include "webkit/plugins/ppapi/resource_tracker.h" | 11 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 11 | 12 |
| 13 using webkit::ppapi::HostGlobals; |
| 12 using WebKit::WebBindings; | 14 using WebKit::WebBindings; |
| 13 | 15 |
| 14 namespace ppapi { | 16 namespace ppapi { |
| 15 | 17 |
| 16 // NPObjectVar ----------------------------------------------------------------- | 18 // NPObjectVar ----------------------------------------------------------------- |
| 17 | 19 |
| 18 NPObjectVar::NPObjectVar(PP_Module module, | 20 NPObjectVar::NPObjectVar(PP_Module module, |
| 19 PP_Instance instance, | 21 PP_Instance instance, |
| 20 NPObject* np_object) | 22 NPObject* np_object) |
| 21 : Var(module), | 23 : Var(module), |
| 22 pp_instance_(instance), | 24 pp_instance_(instance), |
| 23 np_object_(np_object) { | 25 np_object_(np_object) { |
| 24 WebBindings::retainObject(np_object_); | 26 WebBindings::retainObject(np_object_); |
| 25 webkit::ppapi::ResourceTracker::Get()->AddNPObjectVar(this); | 27 HostGlobals::Get()->host_resource_tracker()->AddNPObjectVar(this); |
| 26 } | 28 } |
| 27 | 29 |
| 28 NPObjectVar::~NPObjectVar() { | 30 NPObjectVar::~NPObjectVar() { |
| 29 if (pp_instance()) | 31 if (pp_instance()) |
| 30 webkit::ppapi::ResourceTracker::Get()->RemoveNPObjectVar(this); | 32 HostGlobals::Get()->host_resource_tracker()->RemoveNPObjectVar(this); |
| 31 WebBindings::releaseObject(np_object_); | 33 WebBindings::releaseObject(np_object_); |
| 32 } | 34 } |
| 33 | 35 |
| 34 NPObjectVar* NPObjectVar::AsNPObjectVar() { | 36 NPObjectVar* NPObjectVar::AsNPObjectVar() { |
| 35 return this; | 37 return this; |
| 36 } | 38 } |
| 37 | 39 |
| 38 PP_Var NPObjectVar::GetPPVar() { | 40 PP_Var NPObjectVar::GetPPVar() { |
| 39 int32 id = GetOrCreateVarID(); | 41 int32 id = GetOrCreateVarID(); |
| 40 if (!id) | 42 if (!id) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 53 void NPObjectVar::InstanceDeleted() { | 55 void NPObjectVar::InstanceDeleted() { |
| 54 DCHECK(pp_instance_); | 56 DCHECK(pp_instance_); |
| 55 pp_instance_ = 0; | 57 pp_instance_ = 0; |
| 56 } | 58 } |
| 57 | 59 |
| 58 // static | 60 // static |
| 59 scoped_refptr<NPObjectVar> NPObjectVar::FromPPVar(PP_Var var) { | 61 scoped_refptr<NPObjectVar> NPObjectVar::FromPPVar(PP_Var var) { |
| 60 if (var.type != PP_VARTYPE_OBJECT) | 62 if (var.type != PP_VARTYPE_OBJECT) |
| 61 return scoped_refptr<NPObjectVar>(NULL); | 63 return scoped_refptr<NPObjectVar>(NULL); |
| 62 scoped_refptr<Var> var_object( | 64 scoped_refptr<Var> var_object( |
| 63 webkit::ppapi::ResourceTracker::Get()->GetVarTracker()->GetVar(var)); | 65 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); |
| 64 if (!var_object) | 66 if (!var_object) |
| 65 return scoped_refptr<NPObjectVar>(); | 67 return scoped_refptr<NPObjectVar>(); |
| 66 return scoped_refptr<NPObjectVar>(var_object->AsNPObjectVar()); | 68 return scoped_refptr<NPObjectVar>(var_object->AsNPObjectVar()); |
| 67 } | 69 } |
| 68 | 70 |
| 69 } // namespace ppapi | 71 } // namespace ppapi |
| OLD | NEW |