Chromium Code Reviews| Index: ppapi/thunk/enter.h |
| diff --git a/ppapi/thunk/enter.h b/ppapi/thunk/enter.h |
| index 276f0457647d07d08f367cbced88430fdf781c3c..9c43a6d76bd5481c53daef6c53bc16e04e629621 100644 |
| --- a/ppapi/thunk/enter.h |
| +++ b/ppapi/thunk/enter.h |
| @@ -245,6 +245,46 @@ 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) : EnterBase() { |
|
dmichael (off chromium)
2012/11/21 17:26:26
nit: explicit
raymes
2012/11/21 20:59:10
Done.
|
| + functions_ = NULL; |
|
dmichael (off chromium)
2012/11/21 17:26:26
nit: Why not initialize this in the initializer li
raymes
2012/11/21 20:59:10
Done.
|
| + PPB_Instance_API* ppb_instance = |
| + PpapiGlobals::Get()->GetInstanceAPI(instance); |
| + if (ppb_instance) { |
| + Resource* resource = |
| + ppb_instance->GetSingletonResource(instance, |
| + ApiT::kSingletonResourceID); |
| + 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_; } |
|
dmichael (off chromium)
2012/11/21 17:26:26
I'm noticing we don't do this in EnterInstance eit
raymes
2012/11/21 20:59:10
As discussed, we can't return const ApiT* because
|
| + |
| + private: |
| + ApiT* functions_; |
| +}; |
| + |
| +template<typename ApiT> |
| +class PPAPI_THUNK_EXPORT EnterInstanceAPINoLock |
| + : public EnterInstanceAPI<ApiT, false> { |
| + public: |
| + EnterInstanceAPINoLock(PP_Instance instance) |
| + : EnterInstanceAPI<ApiT, false>(instance) { |
| + } |
| +}; |
| + |
| // EnterResourceCreation ------------------------------------------------------- |
| class PPAPI_THUNK_EXPORT EnterResourceCreation |