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/host_globals.h" |
11 #include "webkit/plugins/ppapi/host_var_tracker.h" | 11 #include "webkit/plugins/ppapi/host_var_tracker.h" |
12 | 12 |
13 using webkit::ppapi::HostGlobals; | 13 using webkit::ppapi::HostGlobals; |
14 using WebKit::WebBindings; | 14 using WebKit::WebBindings; |
15 | 15 |
16 namespace ppapi { | 16 namespace ppapi { |
17 | 17 |
18 // NPObjectVar ----------------------------------------------------------------- | 18 // NPObjectVar ----------------------------------------------------------------- |
19 | 19 |
20 NPObjectVar::NPObjectVar(PP_Module module, | 20 NPObjectVar::NPObjectVar(PP_Instance instance, |
21 PP_Instance instance, | |
22 NPObject* np_object) | 21 NPObject* np_object) |
23 : Var(module), | 22 : pp_instance_(instance), |
24 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_var_tracker()->AddNPObjectVar(this); | 25 HostGlobals::Get()->host_var_tracker()->AddNPObjectVar(this); |
28 } | 26 } |
29 | 27 |
30 NPObjectVar::~NPObjectVar() { | 28 NPObjectVar::~NPObjectVar() { |
31 if (pp_instance()) | 29 if (pp_instance()) |
32 HostGlobals::Get()->host_var_tracker()->RemoveNPObjectVar(this); | 30 HostGlobals::Get()->host_var_tracker()->RemoveNPObjectVar(this); |
33 WebBindings::releaseObject(np_object_); | 31 WebBindings::releaseObject(np_object_); |
34 } | 32 } |
(...skipping 27 matching lines...) Expand all Loading... |
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 PpapiGlobals::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 |