Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: ppapi/shared_impl/ppapi_globals.h

Issue 9034035: Make it possible to have 1 PpapiGlobals per thread. Update unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove perftest stuff from this CL Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};

Powered by Google App Engine
This is Rietveld 408576698