Chromium Code Reviews| Index: ppapi/thunk/enter.h |
| diff --git a/ppapi/thunk/enter.h b/ppapi/thunk/enter.h |
| index 276f0457647d07d08f367cbced88430fdf781c3c..54b3578c59decfdcc49f1b74be4804a4351c7ddb 100644 |
| --- a/ppapi/thunk/enter.h |
| +++ b/ppapi/thunk/enter.h |
| @@ -216,7 +216,7 @@ class PPAPI_THUNK_EXPORT EnterInstance |
| : public subtle::EnterBase, |
| public subtle::LockOnEntry<true> { |
| public: |
| - EnterInstance(PP_Instance instance); |
| + explicit EnterInstance(PP_Instance instance); |
| EnterInstance(PP_Instance instance, |
| const PP_CompletionCallback& callback); |
| ~EnterInstance(); |
| @@ -224,7 +224,7 @@ class PPAPI_THUNK_EXPORT EnterInstance |
| bool succeeded() const { return !!functions_; } |
| bool failed() const { return !functions_; } |
| - PPB_Instance_API* functions() { return functions_; } |
| + PPB_Instance_API* functions() const { return functions_; } |
| private: |
| PPB_Instance_API* functions_; |
| @@ -234,7 +234,7 @@ class PPAPI_THUNK_EXPORT EnterInstanceNoLock |
| : public subtle::EnterBase, |
| public subtle::LockOnEntry<false> { |
| public: |
| - EnterInstanceNoLock(PP_Instance instance); |
| + explicit EnterInstanceNoLock(PP_Instance instance); |
| EnterInstanceNoLock(PP_Instance instance, |
| const PP_CompletionCallback& callback); |
| ~EnterInstanceNoLock(); |
| @@ -245,13 +245,53 @@ 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: |
| + explicit EnterInstanceAPI(PP_Instance instance) : EnterBase(), |
|
brettw
2012/11/27 05:55:10
The style guide either puts everything on one line
raymes
2012/11/27 17:48:45
Done.
|
| + 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() const { return functions_; } |
| + |
| + private: |
| + ApiT* functions_; |
| +}; |
| + |
| +template<typename ApiT> |
| +class PPAPI_THUNK_EXPORT EnterInstanceAPINoLock |
| + : public EnterInstanceAPI<ApiT, false> { |
| + public: |
| + explicit EnterInstanceAPINoLock(PP_Instance instance) |
| + : EnterInstanceAPI<ApiT, false>(instance) { |
| + } |
| +}; |
| + |
| // EnterResourceCreation ------------------------------------------------------- |
| class PPAPI_THUNK_EXPORT EnterResourceCreation |
| : public subtle::EnterBase, |
| public subtle::LockOnEntry<true> { |
| public: |
| - EnterResourceCreation(PP_Instance instance); |
| + explicit EnterResourceCreation(PP_Instance instance); |
| ~EnterResourceCreation(); |
| ResourceCreationAPI* functions() { return functions_; } |
| @@ -264,7 +304,7 @@ class PPAPI_THUNK_EXPORT EnterResourceCreationNoLock |
| : public subtle::EnterBase, |
| public subtle::LockOnEntry<false> { |
| public: |
| - EnterResourceCreationNoLock(PP_Instance instance); |
| + explicit EnterResourceCreationNoLock(PP_Instance instance); |
| ~EnterResourceCreationNoLock(); |
| ResourceCreationAPI* functions() { return functions_; } |