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