Disable content detection tests on Android
[chromium-blink-merge.git] / webkit / plugins / ppapi / host_globals.h
blob31c22ed0ff7a231265804041a9ce52c75adc1455
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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_
6 #define WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_
8 #include "base/compiler_specific.h"
9 #include "ppapi/shared_impl/callback_tracker.h"
10 #include "ppapi/shared_impl/ppapi_globals.h"
11 #include "ppapi/shared_impl/resource_tracker.h"
12 #include "ppapi/shared_impl/var_tracker.h"
13 #include "webkit/plugins/ppapi/host_var_tracker.h"
14 #include "webkit/plugins/webkit_plugins_export.h"
16 namespace webkit {
17 namespace ppapi {
19 class PluginInstance;
20 class PluginModule;
22 class HostGlobals : public ::ppapi::PpapiGlobals {
23 public:
24 HostGlobals();
25 explicit HostGlobals(::ppapi::PpapiGlobals::PerThreadForTest);
26 virtual ~HostGlobals();
28 // Getter for the global singleton. Generally, you should use
29 // PpapiGlobals::Get() when possible. Use this only when you need some
30 // host-specific functionality.
31 inline static HostGlobals* Get() {
32 DCHECK(PpapiGlobals::Get()->IsHostGlobals());
33 return static_cast<HostGlobals*>(PpapiGlobals::Get());
36 // PpapiGlobals implementation.
37 virtual ::ppapi::ResourceTracker* GetResourceTracker() OVERRIDE;
38 virtual ::ppapi::VarTracker* GetVarTracker() OVERRIDE;
39 virtual ::ppapi::CallbackTracker* GetCallbackTrackerForInstance(
40 PP_Instance instance) OVERRIDE;
41 virtual ::ppapi::thunk::PPB_Instance_API* GetInstanceAPI(
42 PP_Instance instance) OVERRIDE;
43 virtual ::ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI(
44 PP_Instance instance) OVERRIDE;
45 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
46 virtual std::string GetCmdLine() OVERRIDE;
47 virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE;
48 virtual base::Lock* GetProxyLock() OVERRIDE;
49 virtual void LogWithSource(PP_Instance instance,
50 PP_LogLevel level,
51 const std::string& source,
52 const std::string& value) OVERRIDE;
53 virtual void BroadcastLogWithSource(PP_Module module,
54 PP_LogLevel level,
55 const std::string& source,
56 const std::string& value) OVERRIDE;
57 virtual ::ppapi::MessageLoopShared* GetCurrentMessageLoop() OVERRIDE;
59 HostVarTracker* host_var_tracker() {
60 return &host_var_tracker_;
63 // PP_Modules ----------------------------------------------------------------
65 // Adds a new plugin module to the list of tracked module, and returns a new
66 // module handle to identify it.
67 PP_Module AddModule(PluginModule* module);
69 // Called when a plugin modulde was deleted and should no longer be tracked.
70 // The given handle should be one generated by AddModule.
71 void ModuleDeleted(PP_Module module);
73 // Returns a pointer to the plugin modulde object associated with the given
74 // modulde handle. The return value will be NULL if the handle is invalid.
75 PluginModule* GetModule(PP_Module module);
77 // PP_Instances --------------------------------------------------------------
79 // Adds a new plugin instance to the list of tracked instances, and returns a
80 // new instance handle to identify it.
81 PP_Instance AddInstance(PluginInstance* instance);
83 // Called when a plugin instance was deleted and should no longer be tracked.
84 // The given handle should be one generated by AddInstance.
85 void InstanceDeleted(PP_Instance instance);
87 void InstanceCrashed(PP_Instance instance);
89 // Returns a pointer to the plugin instance object associated with the given
90 // instance handle. The return value will be NULL if the handle is invalid or
91 // if the instance has crashed.
92 WEBKIT_PLUGINS_EXPORT PluginInstance* GetInstance(PP_Instance instance);
94 private:
95 // PpapiGlobals overrides.
96 virtual bool IsHostGlobals() const OVERRIDE;
98 WEBKIT_PLUGINS_EXPORT static HostGlobals* host_globals_;
100 ::ppapi::ResourceTracker resource_tracker_;
101 HostVarTracker host_var_tracker_;
103 // Tracks all live instances and their associated object.
104 typedef std::map<PP_Instance, PluginInstance*> InstanceMap;
105 InstanceMap instance_map_;
107 // Tracks all live modules. The pointers are non-owning, the PluginModule
108 // destructor will notify us when the module is deleted.
109 typedef std::map<PP_Module, PluginModule*> ModuleMap;
110 ModuleMap module_map_;
112 DISALLOW_COPY_AND_ASSIGN(HostGlobals);
115 } // namespace ppapi
116 } // namespace webkit
118 #endif // WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_