| 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" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/process/process_handle.h" | 13 #include "base/process/process_handle.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "ipc/ipc_sync_channel.h" | 15 #include "ipc/ipc_sync_channel.h" |
| 16 #include "ipc/message_filter.h" | 16 #include "ipc/message_filter.h" |
| 17 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
| 18 #include "ppapi/c/private/ppb_proxy_private.h" | 18 #include "ppapi/c/private/ppb_proxy_private.h" |
| 19 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
| 20 #include "ppapi/proxy/ppb_message_loop_proxy.h" | 20 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
| 21 #include "ppapi/shared_impl/proxy_lock.h" | |
| 22 | 21 |
| 23 namespace ppapi { | 22 namespace ppapi { |
| 24 namespace proxy { | 23 namespace proxy { |
| 25 | 24 |
| 26 namespace { | 25 namespace { |
| 27 // HostDispatcher requires a PPB_Proxy_Private, so we always provide a fallback | 26 // HostDispatcher requires a PPB_Proxy_Private, so we always provide a fallback |
| 28 // do-nothing implementation. | 27 // do-nothing implementation. |
| 29 void PluginCrashed(PP_Module module) { | 28 void PluginCrashed(PP_Module module) { |
| 30 NOTREACHED(); | 29 NOTREACHED(); |
| 31 }; | 30 }; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 221 |
| 223 resource_tracker().DidDeleteInstance(pp_instance()); | 222 resource_tracker().DidDeleteInstance(pp_instance()); |
| 224 } | 223 } |
| 225 plugin_globals_.reset(); | 224 plugin_globals_.reset(); |
| 226 } | 225 } |
| 227 | 226 |
| 228 void PluginProxyTestHarness::CreatePluginGlobals() { | 227 void PluginProxyTestHarness::CreatePluginGlobals() { |
| 229 if (globals_config_ == PER_THREAD_GLOBALS) { | 228 if (globals_config_ == PER_THREAD_GLOBALS) { |
| 230 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); | 229 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); |
| 231 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 230 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 232 // Enable locking in case some other unit test ran before us and disabled | |
| 233 // locking. | |
| 234 ProxyLock::EnableLockingOnThreadForTest(); | |
| 235 } else { | 231 } else { |
| 236 plugin_globals_.reset(new PluginGlobals()); | 232 plugin_globals_.reset(new PluginGlobals()); |
| 237 ProxyLock::EnableLockingOnThreadForTest(); | |
| 238 } | 233 } |
| 239 } | 234 } |
| 240 | 235 |
| 241 base::MessageLoopProxy* | 236 base::MessageLoopProxy* |
| 242 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 237 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
| 243 return ipc_message_loop_; | 238 return ipc_message_loop_; |
| 244 } | 239 } |
| 245 | 240 |
| 246 base::WaitableEvent* | 241 base::WaitableEvent* |
| 247 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 242 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 452 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 458 } | 453 } |
| 459 | 454 |
| 460 void HostProxyTestHarness::TearDownHarness() { | 455 void HostProxyTestHarness::TearDownHarness() { |
| 461 HostDispatcher::RemoveForInstance(pp_instance()); | 456 HostDispatcher::RemoveForInstance(pp_instance()); |
| 462 host_dispatcher_.reset(); | 457 host_dispatcher_.reset(); |
| 463 host_globals_.reset(); | 458 host_globals_.reset(); |
| 464 } | 459 } |
| 465 | 460 |
| 466 void HostProxyTestHarness::CreateHostGlobals() { | 461 void HostProxyTestHarness::CreateHostGlobals() { |
| 462 disable_locking_.reset(new ProxyLock::LockingDisablerForTest); |
| 467 if (globals_config_ == PER_THREAD_GLOBALS) { | 463 if (globals_config_ == PER_THREAD_GLOBALS) { |
| 468 host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); | 464 host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); |
| 469 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 465 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 470 // The host side of the proxy does not lock. | |
| 471 ProxyLock::DisableLockingOnThreadForTest(); | |
| 472 } else { | 466 } else { |
| 473 ProxyLock::DisableLockingOnThreadForTest(); | |
| 474 host_globals_.reset(new TestGlobals()); | 467 host_globals_.reset(new TestGlobals()); |
| 475 } | 468 } |
| 476 } | 469 } |
| 477 | 470 |
| 478 base::MessageLoopProxy* | 471 base::MessageLoopProxy* |
| 479 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { | 472 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { |
| 480 return ipc_message_loop_; | 473 return ipc_message_loop_; |
| 481 } | 474 } |
| 482 | 475 |
| 483 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { | 476 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 575 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
| 583 base::Bind(&RunTaskOnRemoteHarness, | 576 base::Bind(&RunTaskOnRemoteHarness, |
| 584 task, | 577 task, |
| 585 &task_complete)); | 578 &task_complete)); |
| 586 task_complete.Wait(); | 579 task_complete.Wait(); |
| 587 } | 580 } |
| 588 | 581 |
| 589 | 582 |
| 590 } // namespace proxy | 583 } // namespace proxy |
| 591 } // namespace ppapi | 584 } // namespace ppapi |
| OLD | NEW |