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 #ifndef WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "ppapi/c/pp_instance.h" | 11 #include "ppapi/c/pp_instance.h" |
12 #include "ppapi/c/pp_module.h" | |
13 #include "ppapi/shared_impl/var.h" | 12 #include "ppapi/shared_impl/var.h" |
14 #include "webkit/plugins/webkit_plugins_export.h" | 13 #include "webkit/plugins/webkit_plugins_export.h" |
15 | 14 |
16 typedef struct NPObject NPObject; | 15 typedef struct NPObject NPObject; |
17 typedef struct _NPVariant NPVariant; | 16 typedef struct _NPVariant NPVariant; |
18 typedef void* NPIdentifier; | 17 typedef void* NPIdentifier; |
19 | 18 |
20 namespace ppapi { | 19 namespace ppapi { |
21 | 20 |
22 // NPObjectVar ----------------------------------------------------------------- | 21 // NPObjectVar ----------------------------------------------------------------- |
23 | 22 |
24 // Represents a JavaScript object Var. By itself, this represents random | 23 // Represents a JavaScript object Var. By itself, this represents random |
25 // NPObjects that a given plugin (identified by the resource's module) wants to | 24 // NPObjects that a given plugin (identified by the resource's module) wants to |
26 // reference. If two different modules reference the same NPObject (like the | 25 // reference. If two different modules reference the same NPObject (like the |
27 // "window" object), then there will be different NPObjectVar's (and hence | 26 // "window" object), then there will be different NPObjectVar's (and hence |
28 // PP_Var IDs) for each module. This allows us to track all references owned by | 27 // PP_Var IDs) for each module. This allows us to track all references owned by |
29 // a given module and free them when the plugin exits independently of other | 28 // a given module and free them when the plugin exits independently of other |
30 // plugins that may be running at the same time. | 29 // plugins that may be running at the same time. |
31 class NPObjectVar : public Var { | 30 class NPObjectVar : public Var { |
32 public: | 31 public: |
33 // You should always use FromNPObject to create an NPObjectVar. This function | 32 // You should always use FromNPObject to create an NPObjectVar. This function |
34 // guarantees that we maintain the 1:1 mapping between NPObject and | 33 // guarantees that we maintain the 1:1 mapping between NPObject and |
35 // NPObjectVar. | 34 // NPObjectVar. |
36 NPObjectVar(PP_Module module, PP_Instance instance, NPObject* np_object); | 35 NPObjectVar(PP_Instance instance, NPObject* np_object); |
37 | 36 |
38 virtual ~NPObjectVar(); | 37 virtual ~NPObjectVar(); |
39 | 38 |
40 // Var overrides. | 39 // Var overrides. |
41 virtual NPObjectVar* AsNPObjectVar() OVERRIDE; | 40 virtual NPObjectVar* AsNPObjectVar() OVERRIDE; |
42 virtual PP_Var GetPPVar() OVERRIDE; | 41 virtual PP_Var GetPPVar() OVERRIDE; |
43 virtual PP_VarType GetType() const OVERRIDE; | 42 virtual PP_VarType GetType() const OVERRIDE; |
44 | 43 |
45 // Returns the underlying NPObject corresponding to this NPObjectVar. | 44 // Returns the underlying NPObject corresponding to this NPObjectVar. |
46 // Guaranteed non-NULL. | 45 // Guaranteed non-NULL. |
(...skipping 17 matching lines...) Expand all Loading... |
64 // Guaranteed non-NULL, this is the underlying object used by WebKit. We | 63 // Guaranteed non-NULL, this is the underlying object used by WebKit. We |
65 // hold a reference to this object. | 64 // hold a reference to this object. |
66 NPObject* np_object_; | 65 NPObject* np_object_; |
67 | 66 |
68 DISALLOW_COPY_AND_ASSIGN(NPObjectVar); | 67 DISALLOW_COPY_AND_ASSIGN(NPObjectVar); |
69 }; | 68 }; |
70 | 69 |
71 } // namespace | 70 } // namespace |
72 | 71 |
73 #endif // WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_ | 72 #endif // WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_ |
OLD | NEW |