Index: ppapi/proxy/ppb_var_unittest.cc |
diff --git a/ppapi/proxy/ppb_var_unittest.cc b/ppapi/proxy/ppb_var_unittest.cc |
index bf6147d89a59e27a02e0f5200cfbe412826923c0..74ed45380540957a553ed7b9816c46bfcf98fef3 100644 |
--- a/ppapi/proxy/ppb_var_unittest.cc |
+++ b/ppapi/proxy/ppb_var_unittest.cc |
@@ -10,6 +10,7 @@ |
#include "ppapi/c/pp_var.h" |
#include "ppapi/c/ppb_var.h" |
#include "ppapi/proxy/ppapi_proxy_test.h" |
+#include "ppapi/shared_impl/ppapi_globals.h" |
#include "ppapi/shared_impl/ppb_var_shared.h" |
namespace { |
@@ -96,12 +97,13 @@ class CreateVarThreadDelegate : public base::PlatformThread::Delegate { |
// read the var back out to |strings_out[i]|. |
CreateVarThreadDelegate(PP_Module pp_module, const std::string* strings_in, |
PP_Var* vars_out, std::string* strings_out, |
- size_t size) |
+ size_t size, PpapiGlobals* globals) |
: pp_module_(pp_module), strings_in_(strings_in), vars_out_(vars_out), |
- strings_out_(strings_out), size_(size) { |
+ strings_out_(strings_out), size_(size), globals_(globals) { |
} |
virtual ~CreateVarThreadDelegate() {} |
virtual void ThreadMain() { |
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(globals_); |
const PPB_Var* ppb_var = ppapi::PPB_Var_Shared::GetVarInterface1_1(); |
for (size_t i = 0; i < size_; ++i) { |
vars_out_[i] = ppb_var->VarFromUtf8(strings_in_[i].c_str(), |
@@ -115,16 +117,20 @@ class CreateVarThreadDelegate : public base::PlatformThread::Delegate { |
PP_Var* vars_out_; |
std::string* strings_out_; |
size_t size_; |
+ PpapiGlobals* globals_; |
}; |
// A thread that will increment and decrement the reference count of every var |
// multiple times. |
class ChangeRefVarThreadDelegate : public base::PlatformThread::Delegate { |
public: |
- ChangeRefVarThreadDelegate(const std::vector<PP_Var>& vars) : vars_(vars) { |
+ ChangeRefVarThreadDelegate(const std::vector<PP_Var>& vars, |
+ PpapiGlobals* globals) |
+ : vars_(vars), globals_(globals) { |
} |
virtual ~ChangeRefVarThreadDelegate() {} |
virtual void ThreadMain() { |
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(globals_); |
const PPB_Var* ppb_var = ppapi::PPB_Var_Shared::GetVarInterface1_1(); |
// Increment and decrement the reference count for each var kRefsToAdd |
// times. Note that we always AddRef once before doing the matching Release, |
@@ -144,15 +150,19 @@ class ChangeRefVarThreadDelegate : public base::PlatformThread::Delegate { |
} |
private: |
std::vector<PP_Var> vars_; |
+ PpapiGlobals* globals_; |
}; |
// A thread that will decrement the reference count of every var once. |
class RemoveRefVarThreadDelegate : public base::PlatformThread::Delegate { |
public: |
- RemoveRefVarThreadDelegate(const std::vector<PP_Var>& vars) : vars_(vars) { |
+ RemoveRefVarThreadDelegate(const std::vector<PP_Var>& vars, |
+ PpapiGlobals* globals) |
+ : vars_(vars), globals_(globals) { |
} |
virtual ~RemoveRefVarThreadDelegate() {} |
virtual void ThreadMain() { |
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(globals_); |
const PPB_Var* ppb_var = ppapi::PPB_Var_Shared::GetVarInterface1_1(); |
for (size_t i = 0; i < kNumStrings; ++i) { |
ppb_var->Release(vars_[i]); |
@@ -160,6 +170,7 @@ class RemoveRefVarThreadDelegate : public base::PlatformThread::Delegate { |
} |
private: |
std::vector<PP_Var> vars_; |
+ PpapiGlobals* globals_; |
}; |
} // namespace |
@@ -186,7 +197,8 @@ TEST_F(PPB_VarTest, DISABLED_Threads) { |
&vars_[slice_start], |
&strings_out[slice_start], |
std::min(strings_per_thread, |
- kNumStrings - slice_start))); |
+ kNumStrings - slice_start), |
+ GetGlobals())); |
} |
// Now run then join all the threads. |
for (size_t i = 0; i < kNumThreads; ++i) |
@@ -201,7 +213,8 @@ TEST_F(PPB_VarTest, DISABLED_Threads) { |
std::vector<base::PlatformThreadHandle> change_ref_var_threads(kNumThreads); |
std::vector<ChangeRefVarThreadDelegate> change_ref_var_delegates; |
for (size_t i = 0; i < kNumThreads; ++i) |
- change_ref_var_delegates.push_back(ChangeRefVarThreadDelegate(vars_)); |
+ change_ref_var_delegates.push_back( |
+ ChangeRefVarThreadDelegate(vars_, GetGlobals())); |
for (size_t i = 0; i < kNumThreads; ++i) { |
base::PlatformThread::Create(0, &change_ref_var_delegates[i], |
&change_ref_var_threads[i]); |
@@ -224,7 +237,8 @@ TEST_F(PPB_VarTest, DISABLED_Threads) { |
std::vector<base::PlatformThreadHandle> remove_ref_var_threads(kNumThreads); |
std::vector<RemoveRefVarThreadDelegate> remove_ref_var_delegates; |
for (size_t i = 0; i < kNumThreads; ++i) |
- remove_ref_var_delegates.push_back(RemoveRefVarThreadDelegate(vars_)); |
+ remove_ref_var_delegates.push_back( |
+ RemoveRefVarThreadDelegate(vars_, GetGlobals())); |
for (size_t i = 0; i < kNumThreads; ++i) { |
base::PlatformThread::Create(0, &remove_ref_var_delegates[i], |
&remove_ref_var_threads[i]); |