summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/ppapi_globals.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi/shared_impl/ppapi_globals.cc')
-rw-r--r--ppapi/shared_impl/ppapi_globals.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/ppapi/shared_impl/ppapi_globals.cc b/ppapi/shared_impl/ppapi_globals.cc
index 9b5e9a8..477d50a 100644
--- a/ppapi/shared_impl/ppapi_globals.cc
+++ b/ppapi/shared_impl/ppapi_globals.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,12 @@
namespace ppapi {
+namespace {
+
+base::ThreadLocalPointer<PpapiGlobals> tls_ppapi_globals_for_test;
+
+} // namespace
+
PpapiGlobals* PpapiGlobals::ppapi_globals_ = NULL;
PpapiGlobals::PpapiGlobals() {
@@ -15,9 +21,34 @@ PpapiGlobals::PpapiGlobals() {
ppapi_globals_ = this;
}
+PpapiGlobals::PpapiGlobals(ForTest) {
+ DCHECK(!ppapi_globals_);
+}
+
PpapiGlobals::~PpapiGlobals() {
- DCHECK(ppapi_globals_ == this);
+ DCHECK(ppapi_globals_ == this || !ppapi_globals_);
ppapi_globals_ = NULL;
}
+// 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_);
+ tls_ppapi_globals_for_test.Set(ptr);
+}
+
+bool PpapiGlobals::IsHostGlobals() const {
+ return false;
+}
+
+bool PpapiGlobals::IsPluginGlobals() const {
+ return false;
+}
+
+// static
+PpapiGlobals* PpapiGlobals::GetThreadLocalPointer() {
+ return tls_ppapi_globals_for_test.Get();
+}
+
} // namespace ppapi