Chromium Code Reviews| Index: ppapi/thunk/enter.h |
| diff --git a/ppapi/thunk/enter.h b/ppapi/thunk/enter.h |
| index 276f0457647d07d08f367cbced88430fdf781c3c..094d10e484a7d3ff63bf58b7b39c4c5a655afd2f 100644 |
| --- a/ppapi/thunk/enter.h |
| +++ b/ppapi/thunk/enter.h |
| @@ -245,6 +245,47 @@ class PPAPI_THUNK_EXPORT EnterInstanceNoLock |
| PPB_Instance_API* functions_; |
| }; |
| +// EnterInstanceAPI ------------------------------------------------------------ |
| + |
| +template<typename ApiT, bool lock_on_entry = true> |
| +class PPAPI_THUNK_EXPORT EnterInstanceAPI |
| + : public subtle::EnterBase, |
| + public subtle::LockOnEntry<lock_on_entry> { |
| + public: |
| + EnterInstanceAPI(PP_Instance instance, |
| + SingletonResourceID singleton_resource_id) : EnterBase() { |
|
yzshen1
2012/11/20 21:47:25
We can deduce the SingletonResourceID from ApiT, r
raymes
2012/11/20 23:30:23
Yes I was considering whether or not I wanted to d
|
| + functions_ = NULL; |
| + PPB_Instance_API* ppb_instance = |
| + PpapiGlobals::Get()->GetInstanceAPI(instance); |
| + if (ppb_instance) { |
| + Resource* resource = |
| + ppb_instance->GetSingletonResource(instance, singleton_resource_id); |
| + if (resource) |
| + functions_ = resource->GetAs<ApiT>(); |
| + } |
| + SetStateForFunctionError(instance, functions_, true); |
| + } |
| + ~EnterInstanceAPI() {} |
| + |
| + bool succeeded() const { return !!functions_; } |
| + bool failed() const { return !functions_; } |
| + |
| + ApiT* functions() { return functions_; } |
| + |
| + private: |
| + ApiT* functions_; |
| +}; |
| + |
| +template<typename ApiT> |
| +class PPAPI_THUNK_EXPORT EnterInstanceAPINoLock |
| + : public EnterInstanceAPI<ApiT, false> { |
| + public: |
| + EnterInstanceAPINoLock(PP_Instance instance, |
| + SingletonResourceID singleton_resource_id) |
| + : EnterInstanceAPI<ApiT, false>(instance, singleton_resource_id) { |
| + } |
| +}; |
| + |
| // EnterResourceCreation ------------------------------------------------------- |
| class PPAPI_THUNK_EXPORT EnterResourceCreation |