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