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_THUNK_ENTER_H_ | 5 #ifndef PPAPI_THUNK_ENTER_H_ |
6 #define PPAPI_THUNK_ENTER_H_ | 6 #define PPAPI_THUNK_ENTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 PPB_Instance_API* functions() { return functions_; } | 242 PPB_Instance_API* functions() { return functions_; } |
243 | 243 |
244 private: | 244 private: |
245 PPB_Instance_API* functions_; | 245 PPB_Instance_API* functions_; |
246 }; | 246 }; |
247 | 247 |
248 // EnterInstanceAPI ------------------------------------------------------------ | 248 // EnterInstanceAPI ------------------------------------------------------------ |
249 | 249 |
250 template<typename ApiT, bool lock_on_entry = true> | 250 template<typename ApiT, bool lock_on_entry = true> |
251 class PPAPI_THUNK_EXPORT EnterInstanceAPI | 251 class EnterInstanceAPI |
252 : public subtle::EnterBase, | 252 : public subtle::EnterBase, |
253 public subtle::LockOnEntry<lock_on_entry> { | 253 public subtle::LockOnEntry<lock_on_entry> { |
254 public: | 254 public: |
255 explicit EnterInstanceAPI(PP_Instance instance) | 255 explicit EnterInstanceAPI(PP_Instance instance) |
256 : EnterBase(), | 256 : EnterBase(), |
257 functions_(NULL) { | 257 functions_(NULL) { |
258 PPB_Instance_API* ppb_instance = | 258 PPB_Instance_API* ppb_instance = |
259 PpapiGlobals::Get()->GetInstanceAPI(instance); | 259 PpapiGlobals::Get()->GetInstanceAPI(instance); |
260 if (ppb_instance) { | 260 if (ppb_instance) { |
261 Resource* resource = | 261 Resource* resource = |
262 ppb_instance->GetSingletonResource(instance, | 262 ppb_instance->GetSingletonResource(instance, |
263 ApiT::kSingletonResourceID); | 263 ApiT::kSingletonResourceID); |
264 if (resource) | 264 if (resource) |
265 functions_ = resource->GetAs<ApiT>(); | 265 functions_ = resource->GetAs<ApiT>(); |
266 } | 266 } |
267 SetStateForFunctionError(instance, functions_, true); | 267 SetStateForFunctionError(instance, functions_, true); |
268 } | 268 } |
269 ~EnterInstanceAPI() {} | 269 ~EnterInstanceAPI() {} |
270 | 270 |
271 bool succeeded() const { return !!functions_; } | 271 bool succeeded() const { return !!functions_; } |
272 bool failed() const { return !functions_; } | 272 bool failed() const { return !functions_; } |
273 | 273 |
274 ApiT* functions() const { return functions_; } | 274 ApiT* functions() const { return functions_; } |
275 | 275 |
276 private: | 276 private: |
277 ApiT* functions_; | 277 ApiT* functions_; |
278 }; | 278 }; |
279 | 279 |
280 template<typename ApiT> | 280 template<typename ApiT> |
281 class PPAPI_THUNK_EXPORT EnterInstanceAPINoLock | 281 class EnterInstanceAPINoLock : public EnterInstanceAPI<ApiT, false> { |
282 : public EnterInstanceAPI<ApiT, false> { | |
283 public: | 282 public: |
284 explicit EnterInstanceAPINoLock(PP_Instance instance) | 283 explicit EnterInstanceAPINoLock(PP_Instance instance) |
285 : EnterInstanceAPI<ApiT, false>(instance) { | 284 : EnterInstanceAPI<ApiT, false>(instance) { |
286 } | 285 } |
287 }; | 286 }; |
288 | 287 |
289 // EnterResourceCreation ------------------------------------------------------- | 288 // EnterResourceCreation ------------------------------------------------------- |
290 | 289 |
291 class PPAPI_THUNK_EXPORT EnterResourceCreation | 290 class PPAPI_THUNK_EXPORT EnterResourceCreation |
292 : public subtle::EnterBase, | 291 : public subtle::EnterBase, |
(...skipping 18 matching lines...) Expand all Loading... |
311 ResourceCreationAPI* functions() { return functions_; } | 310 ResourceCreationAPI* functions() { return functions_; } |
312 | 311 |
313 private: | 312 private: |
314 ResourceCreationAPI* functions_; | 313 ResourceCreationAPI* functions_; |
315 }; | 314 }; |
316 | 315 |
317 } // namespace thunk | 316 } // namespace thunk |
318 } // namespace ppapi | 317 } // namespace ppapi |
319 | 318 |
320 #endif // PPAPI_THUNK_ENTER_H_ | 319 #endif // PPAPI_THUNK_ENTER_H_ |
OLD | NEW |