| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/proxy/ppapi_proxy_test.h" | 5 #include "ppapi/proxy/ppapi_proxy_test.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 resource_tracker().DidDeleteInstance(pp_instance()); | 223 resource_tracker().DidDeleteInstance(pp_instance()); |
| 224 } | 224 } |
| 225 plugin_globals_.reset(); | 225 plugin_globals_.reset(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void PluginProxyTestHarness::CreatePluginGlobals() { | 228 void PluginProxyTestHarness::CreatePluginGlobals() { |
| 229 if (globals_config_ == PER_THREAD_GLOBALS) { | 229 if (globals_config_ == PER_THREAD_GLOBALS) { |
| 230 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); | 230 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); |
| 231 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 231 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 232 // Enable locking in case some other unit test ran before us and disabled |
| 233 // locking. |
| 234 ProxyLock::EnableLockingOnThreadForTest(); |
| 232 } else { | 235 } else { |
| 233 plugin_globals_.reset(new PluginGlobals()); | 236 plugin_globals_.reset(new PluginGlobals()); |
| 237 ProxyLock::EnableLockingOnThreadForTest(); |
| 234 } | 238 } |
| 235 } | 239 } |
| 236 | 240 |
| 237 base::MessageLoopProxy* | 241 base::MessageLoopProxy* |
| 238 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 242 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
| 239 return ipc_message_loop_; | 243 return ipc_message_loop_; |
| 240 } | 244 } |
| 241 | 245 |
| 242 base::WaitableEvent* | 246 base::WaitableEvent* |
| 243 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 247 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 ppapi::Preferences preferences; | 453 ppapi::Preferences preferences; |
| 450 host_dispatcher_->InitHostWithChannel(&delegate_mock_, | 454 host_dispatcher_->InitHostWithChannel(&delegate_mock_, |
| 451 base::kNullProcessId, channel_handle, | 455 base::kNullProcessId, channel_handle, |
| 452 is_client, preferences); | 456 is_client, preferences); |
| 453 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 457 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 454 } | 458 } |
| 455 | 459 |
| 456 void HostProxyTestHarness::TearDownHarness() { | 460 void HostProxyTestHarness::TearDownHarness() { |
| 457 HostDispatcher::RemoveForInstance(pp_instance()); | 461 HostDispatcher::RemoveForInstance(pp_instance()); |
| 458 host_dispatcher_.reset(); | 462 host_dispatcher_.reset(); |
| 459 // Set the proxy lock back to the default, which is locking. | |
| 460 ProxyLock::EnableLockingOnThreadForTest(); | |
| 461 host_globals_.reset(); | 463 host_globals_.reset(); |
| 462 } | 464 } |
| 463 | 465 |
| 464 void HostProxyTestHarness::CreateHostGlobals() { | 466 void HostProxyTestHarness::CreateHostGlobals() { |
| 465 if (globals_config_ == PER_THREAD_GLOBALS) { | 467 if (globals_config_ == PER_THREAD_GLOBALS) { |
| 466 host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); | 468 host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); |
| 467 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 469 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 468 // The host side of the proxy does not lock. | 470 // The host side of the proxy does not lock. |
| 469 ProxyLock::DisableLockingOnThreadForTest(); | 471 ProxyLock::DisableLockingOnThreadForTest(); |
| 470 } else { | 472 } else { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 582 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
| 581 base::Bind(&RunTaskOnRemoteHarness, | 583 base::Bind(&RunTaskOnRemoteHarness, |
| 582 task, | 584 task, |
| 583 &task_complete)); | 585 &task_complete)); |
| 584 task_complete.Wait(); | 586 task_complete.Wait(); |
| 585 } | 587 } |
| 586 | 588 |
| 587 | 589 |
| 588 } // namespace proxy | 590 } // namespace proxy |
| 589 } // namespace ppapi | 591 } // namespace ppapi |
| OLD | NEW |