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

Unified Diff: ppapi/shared_impl/ppapi_globals.cc

Issue 15403002: Remving global statics from the headers, so we can split-link. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding export Created 7 years, 7 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
« no previous file with comments | « ppapi/shared_impl/ppapi_globals.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/ppapi_globals.cc
diff --git a/ppapi/shared_impl/ppapi_globals.cc b/ppapi/shared_impl/ppapi_globals.cc
index 9f4aaa3c3bc1785109eaa28ff4516de8b69b3ebb..f5166c3cab5ed4ba95d3222eababceb54e8b47da 100644
--- a/ppapi/shared_impl/ppapi_globals.cc
+++ b/ppapi/shared_impl/ppapi_globals.cc
@@ -18,29 +18,38 @@ base::LazyInstance<base::ThreadLocalPointer<PpapiGlobals> >::Leaky
tls_ppapi_globals_for_test = LAZY_INSTANCE_INITIALIZER;
} // namespace
-PpapiGlobals* PpapiGlobals::ppapi_globals_ = NULL;
+PpapiGlobals* ppapi_globals = NULL;
PpapiGlobals::PpapiGlobals() {
- DCHECK(!ppapi_globals_);
- ppapi_globals_ = this;
+ DCHECK(!ppapi_globals);
+ ppapi_globals = this;
main_loop_proxy_ = base::MessageLoopProxy::current();
}
PpapiGlobals::PpapiGlobals(PerThreadForTest) {
- DCHECK(!ppapi_globals_);
+ DCHECK(!ppapi_globals);
main_loop_proxy_ = base::MessageLoopProxy::current();
}
PpapiGlobals::~PpapiGlobals() {
- DCHECK(ppapi_globals_ == this || !ppapi_globals_);
- ppapi_globals_ = NULL;
+ DCHECK(ppapi_globals == this || !ppapi_globals);
+ ppapi_globals = NULL;
+}
+
+//Static Getter for the global singleton.
+PpapiGlobals* PpapiGlobals::Get() {
+ if (ppapi_globals)
+ return ppapi_globals;
+ // In unit tests, the following might be valid (see
+ // SetPpapiGlobalsOnThreadForTest). Normally, this will just return NULL.
+ return GetThreadLocalPointer();
}
// static
void PpapiGlobals::SetPpapiGlobalsOnThreadForTest(PpapiGlobals* ptr) {
// If we're using a per-thread PpapiGlobals, we should not have a global one.
// If we allowed it, it would always over-ride the "test" versions.
- DCHECK(!ppapi_globals_);
+ DCHECK(!ppapi_globals);
tls_ppapi_globals_for_test.Pointer()->Set(ptr);
}
« no previous file with comments | « ppapi/shared_impl/ppapi_globals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698