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() { |
+ functions_ = NULL; |
+ 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_; } |
+ |
+ 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 |