Index: ppapi/shared_impl/ppapi_globals.h |
diff --git a/ppapi/shared_impl/ppapi_globals.h b/ppapi/shared_impl/ppapi_globals.h |
index b3d7d555514785a41f57891eb5ec872c04427c78..cdbe39faf2dc95a51204ce0b98476b174c72644b 100644 |
--- a/ppapi/shared_impl/ppapi_globals.h |
+++ b/ppapi/shared_impl/ppapi_globals.h |
@@ -6,6 +6,7 @@ |
#define PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_ |
#include "base/basictypes.h" |
+#include "base/threading/thread_local.h" // For testing purposes only. |
#include "ppapi/c/pp_instance.h" |
#include "ppapi/c/pp_module.h" |
#include "ppapi/shared_impl/api_id.h" |
@@ -25,7 +26,15 @@ class PPAPI_SHARED_EXPORT PpapiGlobals { |
virtual ~PpapiGlobals(); |
// Getter for the global singleton. |
- inline static PpapiGlobals* Get() { return ppapi_globals_; } |
+ inline static PpapiGlobals* Get() { |
+ if (ppapi_globals_) |
+ return ppapi_globals_; |
+ return ppapi_globals_for_test_.Get(); |
+ } |
+ static void SetPpapiGlobalsForTest(PpapiGlobals* ptr) { |
+ ppapi_globals_for_test_.Set(ptr); |
+ ppapi_globals_ = NULL; |
+ } |
// Retrieves the corresponding tracker. |
virtual ResourceTracker* GetResourceTracker() = 0; |
@@ -43,6 +52,7 @@ class PPAPI_SHARED_EXPORT PpapiGlobals { |
private: |
static PpapiGlobals* ppapi_globals_; |
+ static base::ThreadLocalPointer<PpapiGlobals> ppapi_globals_for_test_; |
DISALLOW_COPY_AND_ASSIGN(PpapiGlobals); |
}; |