| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HOST_GLOBALS_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "ppapi/shared_impl/callback_tracker.h" | 9 #include "ppapi/shared_impl/callback_tracker.h" |
| 10 #include "ppapi/shared_impl/ppapi_globals.h" | 10 #include "ppapi/shared_impl/ppapi_globals.h" |
| 11 #include "ppapi/shared_impl/resource_tracker.h" | 11 #include "ppapi/shared_impl/resource_tracker.h" |
| 12 #include "ppapi/shared_impl/var_tracker.h" | 12 #include "ppapi/shared_impl/var_tracker.h" |
| 13 #include "webkit/plugins/ppapi/host_var_tracker.h" | 13 #include "webkit/plugins/ppapi/host_var_tracker.h" |
| 14 #include "webkit/plugins/webkit_plugins_export.h" | 14 #include "webkit/plugins/webkit_plugins_export.h" |
| 15 | 15 |
| 16 namespace webkit { | 16 namespace webkit { |
| 17 namespace ppapi { | 17 namespace ppapi { |
| 18 | 18 |
| 19 class PluginInstance; | 19 class PluginInstanceImpl; |
| 20 class PluginModule; | 20 class PluginModule; |
| 21 | 21 |
| 22 class HostGlobals : public ::ppapi::PpapiGlobals { | 22 class HostGlobals : public ::ppapi::PpapiGlobals { |
| 23 public: | 23 public: |
| 24 HostGlobals(); | 24 HostGlobals(); |
| 25 explicit HostGlobals(::ppapi::PpapiGlobals::PerThreadForTest); | 25 explicit HostGlobals(::ppapi::PpapiGlobals::PerThreadForTest); |
| 26 virtual ~HostGlobals(); | 26 virtual ~HostGlobals(); |
| 27 | 27 |
| 28 // Getter for the global singleton. Generally, you should use | 28 // Getter for the global singleton. Generally, you should use |
| 29 // PpapiGlobals::Get() when possible. Use this only when you need some | 29 // PpapiGlobals::Get() when possible. Use this only when you need some |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void ModuleDeleted(PP_Module module); | 72 void ModuleDeleted(PP_Module module); |
| 73 | 73 |
| 74 // Returns a pointer to the plugin modulde object associated with the given | 74 // Returns a pointer to the plugin modulde object associated with the given |
| 75 // modulde handle. The return value will be NULL if the handle is invalid. | 75 // modulde handle. The return value will be NULL if the handle is invalid. |
| 76 PluginModule* GetModule(PP_Module module); | 76 PluginModule* GetModule(PP_Module module); |
| 77 | 77 |
| 78 // PP_Instances -------------------------------------------------------------- | 78 // PP_Instances -------------------------------------------------------------- |
| 79 | 79 |
| 80 // Adds a new plugin instance to the list of tracked instances, and returns a | 80 // Adds a new plugin instance to the list of tracked instances, and returns a |
| 81 // new instance handle to identify it. | 81 // new instance handle to identify it. |
| 82 PP_Instance AddInstance(PluginInstance* instance); | 82 PP_Instance AddInstance(PluginInstanceImpl* instance); |
| 83 | 83 |
| 84 // Called when a plugin instance was deleted and should no longer be tracked. | 84 // Called when a plugin instance was deleted and should no longer be tracked. |
| 85 // The given handle should be one generated by AddInstance. | 85 // The given handle should be one generated by AddInstance. |
| 86 void InstanceDeleted(PP_Instance instance); | 86 void InstanceDeleted(PP_Instance instance); |
| 87 | 87 |
| 88 void InstanceCrashed(PP_Instance instance); | 88 void InstanceCrashed(PP_Instance instance); |
| 89 | 89 |
| 90 // Returns a pointer to the plugin instance object associated with the given | 90 // Returns a pointer to the plugin instance object associated with the given |
| 91 // instance handle. The return value will be NULL if the handle is invalid or | 91 // instance handle. The return value will be NULL if the handle is invalid or |
| 92 // if the instance has crashed. | 92 // if the instance has crashed. |
| 93 WEBKIT_PLUGINS_EXPORT PluginInstance* GetInstance(PP_Instance instance); | 93 WEBKIT_PLUGINS_EXPORT PluginInstanceImpl* GetInstance(PP_Instance instance); |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 // PpapiGlobals overrides. | 96 // PpapiGlobals overrides. |
| 97 virtual bool IsHostGlobals() const OVERRIDE; | 97 virtual bool IsHostGlobals() const OVERRIDE; |
| 98 | 98 |
| 99 WEBKIT_PLUGINS_EXPORT static HostGlobals* host_globals_; | 99 WEBKIT_PLUGINS_EXPORT static HostGlobals* host_globals_; |
| 100 | 100 |
| 101 ::ppapi::ResourceTracker resource_tracker_; | 101 ::ppapi::ResourceTracker resource_tracker_; |
| 102 HostVarTracker host_var_tracker_; | 102 HostVarTracker host_var_tracker_; |
| 103 | 103 |
| 104 // Tracks all live instances and their associated object. | 104 // Tracks all live instances and their associated object. |
| 105 typedef std::map<PP_Instance, PluginInstance*> InstanceMap; | 105 typedef std::map<PP_Instance, PluginInstanceImpl*> InstanceMap; |
| 106 InstanceMap instance_map_; | 106 InstanceMap instance_map_; |
| 107 | 107 |
| 108 // Tracks all live modules. The pointers are non-owning, the PluginModule | 108 // Tracks all live modules. The pointers are non-owning, the PluginModule |
| 109 // destructor will notify us when the module is deleted. | 109 // destructor will notify us when the module is deleted. |
| 110 typedef std::map<PP_Module, PluginModule*> ModuleMap; | 110 typedef std::map<PP_Module, PluginModule*> ModuleMap; |
| 111 ModuleMap module_map_; | 111 ModuleMap module_map_; |
| 112 | 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(HostGlobals); | 113 DISALLOW_COPY_AND_ASSIGN(HostGlobals); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 } // namespace ppapi | 116 } // namespace ppapi |
| 117 } // namespace webkit | 117 } // namespace webkit |
| 118 | 118 |
| 119 #endif // WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ | 119 #endif // WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ |
| OLD | NEW |