Reland 9034035: Make it possible to have 1 PpapiGlobals per thread.
Original CL: r117399, http://codereview.chromium.org/9034035/
Reverted in r117414, http://codereview.chromium.org/9139054/ due to a static initializer.
This is the same as r117399 except using a LazyInstance to eliminate the static initializer.
BUG=
TEST=
[email protected]
Review URL: http://codereview.chromium.org/9187055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117475 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc
index 8ab8c36..15dc967 100644
--- a/ppapi/proxy/ppapi_proxy_test.cc
+++ b/ppapi/proxy/ppapi_proxy_test.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.
@@ -139,7 +139,8 @@
// PluginProxyTestHarness ------------------------------------------------------
-PluginProxyTestHarness::PluginProxyTestHarness() {
+PluginProxyTestHarness::PluginProxyTestHarness()
+ : plugin_globals_(PpapiGlobals::ForTest()) {
}
PluginProxyTestHarness::~PluginProxyTestHarness() {
@@ -151,6 +152,7 @@
void PluginProxyTestHarness::SetUpHarness() {
// These must be first since the dispatcher set-up uses them.
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
resource_tracker().DidCreateInstance(pp_instance());
plugin_dispatcher_.reset(new PluginDispatcher(
@@ -166,6 +168,7 @@
base::WaitableEvent* shutdown_event,
bool is_client) {
// These must be first since the dispatcher set-up uses them.
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
resource_tracker().DidCreateInstance(pp_instance());
plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event);
@@ -248,7 +251,8 @@
// HostProxyTestHarness --------------------------------------------------------
-HostProxyTestHarness::HostProxyTestHarness() {
+HostProxyTestHarness::HostProxyTestHarness()
+ : host_globals_(PpapiGlobals::ForTest()) {
}
HostProxyTestHarness::~HostProxyTestHarness() {
@@ -259,6 +263,8 @@
}
void HostProxyTestHarness::SetUpHarness() {
+ // These must be first since the dispatcher set-up uses them.
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
host_dispatcher_.reset(new HostDispatcher(
base::Process::Current().handle(),
pp_module(),
@@ -272,7 +278,10 @@
base::MessageLoopProxy* ipc_message_loop,
base::WaitableEvent* shutdown_event,
bool is_client) {
+ // These must be first since the dispatcher set-up uses them.
+ PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
delegate_mock_.Init(ipc_message_loop, shutdown_event);
+
host_dispatcher_.reset(new HostDispatcher(
base::Process::Current().handle(),
pp_module(),
@@ -345,7 +354,6 @@
IPC::ChannelHandle handle;
handle.name = "TwoWayTestChannel";
-
base::WaitableEvent remote_harness_set_up(true, false);
plugin_thread_.message_loop_proxy()->PostTask(
FROM_HERE,