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 PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ |
6 #define PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ | 6 #define PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
9 #include "base/threading/thread_local.h" // For testing purposes only. | 10 #include "base/threading/thread_local.h" // For testing purposes only. |
10 #include "ppapi/c/pp_instance.h" | 11 #include "ppapi/c/pp_instance.h" |
11 #include "ppapi/c/pp_module.h" | 12 #include "ppapi/c/pp_module.h" |
12 #include "ppapi/shared_impl/api_id.h" | 13 #include "ppapi/shared_impl/api_id.h" |
13 #include "ppapi/shared_impl/ppapi_shared_export.h" | 14 #include "ppapi/shared_impl/ppapi_shared_export.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class Lock; | 17 class Lock; |
17 } | 18 } |
18 | 19 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // the same process, e.g. for having 1 thread emulate the "host" and 1 thread | 54 // the same process, e.g. for having 1 thread emulate the "host" and 1 thread |
54 // emulate the "plugin". | 55 // emulate the "plugin". |
55 // | 56 // |
56 // PpapiGlobals object must have been constructed using the "ForTest" | 57 // PpapiGlobals object must have been constructed using the "ForTest" |
57 // parameter. | 58 // parameter. |
58 static void SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr); | 59 static void SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr); |
59 | 60 |
60 // Retrieves the corresponding tracker. | 61 // Retrieves the corresponding tracker. |
61 virtual ResourceTracker* GetResourceTracker() = 0; | 62 virtual ResourceTracker* GetResourceTracker() = 0; |
62 virtual VarTracker* GetVarTracker() = 0; | 63 virtual VarTracker* GetVarTracker() = 0; |
63 virtual CallbackTracker* GetCallbackTrackerForInstance( | 64 virtual scoped_refptr<CallbackTracker> GetCallbackTrackerForInstance( |
64 PP_Instance instance) = 0; | 65 PP_Instance instance) = 0; |
65 virtual base::Lock* GetProxyLock() = 0; | 66 virtual base::Lock* GetProxyLock() = 0; |
66 | 67 |
67 // Returns the function object corresponding to the given ID, or NULL if | 68 // Returns the function object corresponding to the given ID, or NULL if |
68 // there isn't one. | 69 // there isn't one. |
69 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, ApiID id) = 0; | 70 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, ApiID id) = 0; |
70 | 71 |
71 // Returns the PP_Module associated with the given PP_Instance, or 0 on | 72 // Returns the PP_Module associated with the given PP_Instance, or 0 on |
72 // failure. | 73 // failure. |
73 virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0; | 74 virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0; |
74 | 75 |
75 virtual bool IsHostGlobals() const; | 76 virtual bool IsHostGlobals() const; |
76 virtual bool IsPluginGlobals() const; | 77 virtual bool IsPluginGlobals() const; |
77 | 78 |
78 private: | 79 private: |
79 // Return the thread-local pointer which is used only for unit testing. It | 80 // Return the thread-local pointer which is used only for unit testing. It |
80 // should always be NULL when running in production. It allows separate | 81 // should always be NULL when running in production. It allows separate |
81 // threads to have distinct "globals". | 82 // threads to have distinct "globals". |
82 static PpapiGlobals* GetThreadLocalPointer(); | 83 static PpapiGlobals* GetThreadLocalPointer(); |
83 | 84 |
84 static PpapiGlobals* ppapi_globals_; | 85 static PpapiGlobals* ppapi_globals_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(PpapiGlobals); | 87 DISALLOW_COPY_AND_ASSIGN(PpapiGlobals); |
87 }; | 88 }; |
88 | 89 |
89 } // namespace ppapi | 90 } // namespace ppapi |
90 | 91 |
91 #endif // PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ | 92 #endif // PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ |
OLD | NEW |