| 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 CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ | 6 #define CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "content/renderer/pepper/host_var_tracker.h" | 9 #include "content/renderer/pepper/host_var_tracker.h" |
| 10 #include "ppapi/shared_impl/callback_tracker.h" | 10 #include "ppapi/shared_impl/callback_tracker.h" |
| 11 #include "ppapi/shared_impl/ppapi_globals.h" | 11 #include "ppapi/shared_impl/ppapi_globals.h" |
| 12 #include "ppapi/shared_impl/resource_tracker.h" | 12 #include "ppapi/shared_impl/resource_tracker.h" |
| 13 #include "ppapi/shared_impl/var_tracker.h" | 13 #include "ppapi/shared_impl/var_tracker.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class PepperPluginInstanceImpl; | 17 class PepperPluginInstanceImpl; |
| 18 class PluginModule; | 18 class PluginModule; |
| 19 | 19 |
| 20 class HostGlobals : public ppapi::PpapiGlobals { | 20 class HostGlobals : public ppapi::PpapiGlobals { |
| 21 public: | 21 public: |
| 22 HostGlobals(); | 22 HostGlobals(); |
| 23 virtual ~HostGlobals(); | 23 ~HostGlobals() override; |
| 24 | 24 |
| 25 // Getter for the global singleton. Generally, you should use | 25 // Getter for the global singleton. Generally, you should use |
| 26 // PpapiGlobals::Get() when possible. Use this only when you need some | 26 // PpapiGlobals::Get() when possible. Use this only when you need some |
| 27 // host-specific functionality. | 27 // host-specific functionality. |
| 28 inline static HostGlobals* Get() { | 28 inline static HostGlobals* Get() { |
| 29 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); | 29 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); |
| 30 return static_cast<HostGlobals*>(PpapiGlobals::Get()); | 30 return static_cast<HostGlobals*>(PpapiGlobals::Get()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // PpapiGlobals implementation. | 33 // PpapiGlobals implementation. |
| 34 virtual ppapi::ResourceTracker* GetResourceTracker() override; | 34 ppapi::ResourceTracker* GetResourceTracker() override; |
| 35 virtual ppapi::VarTracker* GetVarTracker() override; | 35 ppapi::VarTracker* GetVarTracker() override; |
| 36 virtual ppapi::CallbackTracker* GetCallbackTrackerForInstance( | 36 ppapi::CallbackTracker* GetCallbackTrackerForInstance( |
| 37 PP_Instance instance) override; | 37 PP_Instance instance) override; |
| 38 virtual ppapi::thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) | 38 ppapi::thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) override; |
| 39 override; | 39 ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI( |
| 40 virtual ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI( | |
| 41 PP_Instance instance) override; | 40 PP_Instance instance) override; |
| 42 virtual PP_Module GetModuleForInstance(PP_Instance instance) override; | 41 PP_Module GetModuleForInstance(PP_Instance instance) override; |
| 43 virtual std::string GetCmdLine() override; | 42 std::string GetCmdLine() override; |
| 44 virtual void PreCacheFontForFlash(const void* logfontw) override; | 43 void PreCacheFontForFlash(const void* logfontw) override; |
| 45 virtual void LogWithSource(PP_Instance instance, | 44 void LogWithSource(PP_Instance instance, |
| 46 PP_LogLevel level, | 45 PP_LogLevel level, |
| 47 const std::string& source, | 46 const std::string& source, |
| 48 const std::string& value) override; | 47 const std::string& value) override; |
| 49 virtual void BroadcastLogWithSource(PP_Module module, | 48 void BroadcastLogWithSource(PP_Module module, |
| 50 PP_LogLevel level, | 49 PP_LogLevel level, |
| 51 const std::string& source, | 50 const std::string& source, |
| 52 const std::string& value) override; | 51 const std::string& value) override; |
| 53 virtual ppapi::MessageLoopShared* GetCurrentMessageLoop() override; | 52 ppapi::MessageLoopShared* GetCurrentMessageLoop() override; |
| 54 virtual base::TaskRunner* GetFileTaskRunner() override; | 53 base::TaskRunner* GetFileTaskRunner() override; |
| 55 | 54 |
| 56 HostVarTracker* host_var_tracker() { return &host_var_tracker_; } | 55 HostVarTracker* host_var_tracker() { return &host_var_tracker_; } |
| 57 | 56 |
| 58 // PP_Modules ---------------------------------------------------------------- | 57 // PP_Modules ---------------------------------------------------------------- |
| 59 | 58 |
| 60 // Adds a new plugin module to the list of tracked module, and returns a new | 59 // Adds a new plugin module to the list of tracked module, and returns a new |
| 61 // module handle to identify it. | 60 // module handle to identify it. |
| 62 PP_Module AddModule(PluginModule* module); | 61 PP_Module AddModule(PluginModule* module); |
| 63 | 62 |
| 64 // Called when a plugin modulde was deleted and should no longer be tracked. | 63 // Called when a plugin modulde was deleted and should no longer be tracked. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 81 | 80 |
| 82 void InstanceCrashed(PP_Instance instance); | 81 void InstanceCrashed(PP_Instance instance); |
| 83 | 82 |
| 84 // Returns a pointer to the plugin instance object associated with the given | 83 // Returns a pointer to the plugin instance object associated with the given |
| 85 // instance handle. The return value will be NULL if the handle is invalid or | 84 // instance handle. The return value will be NULL if the handle is invalid or |
| 86 // if the instance has crashed. | 85 // if the instance has crashed. |
| 87 PepperPluginInstanceImpl* GetInstance(PP_Instance instance); | 86 PepperPluginInstanceImpl* GetInstance(PP_Instance instance); |
| 88 | 87 |
| 89 private: | 88 private: |
| 90 // PpapiGlobals overrides. | 89 // PpapiGlobals overrides. |
| 91 virtual bool IsHostGlobals() const override; | 90 bool IsHostGlobals() const override; |
| 92 | 91 |
| 93 static HostGlobals* host_globals_; | 92 static HostGlobals* host_globals_; |
| 94 | 93 |
| 95 ppapi::ResourceTracker resource_tracker_; | 94 ppapi::ResourceTracker resource_tracker_; |
| 96 HostVarTracker host_var_tracker_; | 95 HostVarTracker host_var_tracker_; |
| 97 | 96 |
| 98 // Tracks all live instances and their associated object. | 97 // Tracks all live instances and their associated object. |
| 99 typedef std::map<PP_Instance, PepperPluginInstanceImpl*> InstanceMap; | 98 typedef std::map<PP_Instance, PepperPluginInstanceImpl*> InstanceMap; |
| 100 InstanceMap instance_map_; | 99 InstanceMap instance_map_; |
| 101 | 100 |
| 102 // Tracks all live modules. The pointers are non-owning, the PluginModule | 101 // Tracks all live modules. The pointers are non-owning, the PluginModule |
| 103 // destructor will notify us when the module is deleted. | 102 // destructor will notify us when the module is deleted. |
| 104 typedef std::map<PP_Module, PluginModule*> ModuleMap; | 103 typedef std::map<PP_Module, PluginModule*> ModuleMap; |
| 105 ModuleMap module_map_; | 104 ModuleMap module_map_; |
| 106 | 105 |
| 107 DISALLOW_COPY_AND_ASSIGN(HostGlobals); | 106 DISALLOW_COPY_AND_ASSIGN(HostGlobals); |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 } // namespace content | 109 } // namespace content |
| 111 | 110 |
| 112 #endif // CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ | 111 #endif // CONTENT_RENDERER_PEPPER_HOST_GLOBALS_H_ |
| OLD | NEW |