| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/thread_local.h" // For testing purposes only. | 14 #include "base/threading/thread_local.h" // For testing purposes only. |
| 15 #include "ppapi/c/pp_instance.h" | 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/c/pp_module.h" | 16 #include "ppapi/c/pp_module.h" |
| 17 #include "ppapi/c/ppb_console.h" | 17 #include "ppapi/c/ppb_console.h" |
| 18 #include "ppapi/shared_impl/api_id.h" | 18 #include "ppapi/shared_impl/api_id.h" |
| 19 #include "ppapi/shared_impl/ppapi_shared_export.h" | 19 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 20 #include "ui/events/latency_info.h" | 20 #include "ui/events/latency_info.h" |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class MessageLoopProxy; | 23 class SingleThreadTaskRunner; |
| 24 class TaskRunner; | 24 class TaskRunner; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace ppapi { | 27 namespace ppapi { |
| 28 | 28 |
| 29 class CallbackTracker; | 29 class CallbackTracker; |
| 30 class MessageLoopShared; | 30 class MessageLoopShared; |
| 31 class ResourceTracker; | 31 class ResourceTracker; |
| 32 class VarTracker; | 32 class VarTracker; |
| 33 | 33 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // Returns the given API object associated with the given instance, or NULL | 94 // Returns the given API object associated with the given instance, or NULL |
| 95 // if the instance is invalid. | 95 // if the instance is invalid. |
| 96 virtual thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) = 0; | 96 virtual thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) = 0; |
| 97 virtual thunk::ResourceCreationAPI* GetResourceCreationAPI( | 97 virtual thunk::ResourceCreationAPI* GetResourceCreationAPI( |
| 98 PP_Instance instance) = 0; | 98 PP_Instance instance) = 0; |
| 99 | 99 |
| 100 // Returns the PP_Module associated with the given PP_Instance, or 0 on | 100 // Returns the PP_Module associated with the given PP_Instance, or 0 on |
| 101 // failure. | 101 // failure. |
| 102 virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0; | 102 virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0; |
| 103 | 103 |
| 104 // Returns the base::MessageLoopProxy for the main thread. This is set in the | 104 // Returns the base::SingleThreadTaskRunner for the main thread. This is set |
| 105 // constructor, so PpapiGlobals must be created on the main thread. | 105 // in the constructor, so PpapiGlobals must be created on the main thread. |
| 106 base::MessageLoopProxy* GetMainThreadMessageLoop(); | 106 base::SingleThreadTaskRunner* GetMainThreadMessageLoop(); |
| 107 | 107 |
| 108 // In tests, the PpapiGlobals object persists across tests but the MLP pointer | 108 // In tests, the PpapiGlobals object persists across tests but the MLP pointer |
| 109 // it hangs on will go stale and the next PPAPI test will crash because of | 109 // it hangs on will go stale and the next PPAPI test will crash because of |
| 110 // thread checks. This resets the pointer to be the current MLP object. | 110 // thread checks. This resets the pointer to be the current MLP object. |
| 111 void ResetMainThreadMessageLoopForTesting(); | 111 void ResetMainThreadMessageLoopForTesting(); |
| 112 | 112 |
| 113 // Return the MessageLoopShared of the current thread, if any. This will | 113 // Return the MessageLoopShared of the current thread, if any. This will |
| 114 // always return NULL on the host side, where PPB_MessageLoop is not | 114 // always return NULL on the host side, where PPB_MessageLoop is not |
| 115 // supported. | 115 // supported. |
| 116 virtual MessageLoopShared* GetCurrentMessageLoop() = 0; | 116 virtual MessageLoopShared* GetCurrentMessageLoop() = 0; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 143 // Transfers plugin |instance|'s latency info into |latency_info|. | 143 // Transfers plugin |instance|'s latency info into |latency_info|. |
| 144 void TransferLatencyInfoTo(std::vector<ui::LatencyInfo>* latency_info, | 144 void TransferLatencyInfoTo(std::vector<ui::LatencyInfo>* latency_info, |
| 145 PP_Instance instance); | 145 PP_Instance instance); |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 // Return the thread-local pointer which is used only for unit testing. It | 148 // Return the thread-local pointer which is used only for unit testing. It |
| 149 // should always be NULL when running in production. It allows separate | 149 // should always be NULL when running in production. It allows separate |
| 150 // threads to have distinct "globals". | 150 // threads to have distinct "globals". |
| 151 static PpapiGlobals* GetThreadLocalPointer(); | 151 static PpapiGlobals* GetThreadLocalPointer(); |
| 152 | 152 |
| 153 scoped_refptr<base::MessageLoopProxy> main_loop_proxy_; | 153 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 154 | 154 |
| 155 // If an input event is believed to have caused rendering damage, its latency | 155 // If an input event is believed to have caused rendering damage, its latency |
| 156 // info is cached in |latency_info_for_frame_| indexed by instance. These | 156 // info is cached in |latency_info_for_frame_| indexed by instance. These |
| 157 // latency info will be passed back to renderer with the next plugin frame. | 157 // latency info will be passed back to renderer with the next plugin frame. |
| 158 std::map<PP_Instance, std::vector<ui::LatencyInfo> > latency_info_for_frame_; | 158 std::map<PP_Instance, std::vector<ui::LatencyInfo> > latency_info_for_frame_; |
| 159 | 159 |
| 160 DISALLOW_COPY_AND_ASSIGN(PpapiGlobals); | 160 DISALLOW_COPY_AND_ASSIGN(PpapiGlobals); |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 } // namespace ppapi | 163 } // namespace ppapi |
| 164 | 164 |
| 165 #endif // PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ | 165 #endif // PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ |
| OLD | NEW |