[email protected] | 7309756 | 2012-01-12 19:38:55 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ppapi/proxy/ppapi_proxy_test.h" |
| 6 | |
tzik | a0f614d | 2016-03-08 00:35:15 | [diff] [blame] | 7 | #include <tuple> |
[email protected] | b75673fe | 2012-10-17 17:59:14 | [diff] [blame] | 8 | |
[email protected] | 1f6581c | 2011-10-04 23:10:15 | [diff] [blame] | 9 | #include "base/bind.h" |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 10 | #include "base/bind_helpers.h" |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 11 | #include "base/location.h" |
Carlos Caballero | dd8bf7b04 | 2019-07-30 14:14:15 | [diff] [blame^] | 12 | #include "base/message_loop/message_pump_type.h" |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 13 | #include "base/observer_list.h" |
rvargas | 079d184 | 2014-10-17 22:32:16 | [diff] [blame] | 14 | #include "base/process/process_handle.h" |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 15 | #include "base/run_loop.h" |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 16 | #include "base/single_thread_task_runner.h" |
gab | b19326e | 2016-05-11 18:10:31 | [diff] [blame] | 17 | #include "base/threading/thread_task_runner_handle.h" |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 18 | #include "ipc/ipc_sync_channel.h" |
dmichael | 6b328f3d | 2014-09-29 23:49:02 | [diff] [blame] | 19 | #include "ipc/message_filter.h" |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 20 | #include "ppapi/c/pp_errors.h" |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 21 | #include "ppapi/c/private/ppb_proxy_private.h" |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 22 | #include "ppapi/proxy/ppapi_messages.h" |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 23 | #include "ppapi/proxy/ppb_message_loop_proxy.h" |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 24 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 25 | namespace ppapi { |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 26 | namespace proxy { |
| 27 | |
| 28 | namespace { |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 29 | // HostDispatcher requires a PPB_Proxy_Private, so we always provide a fallback |
| 30 | // do-nothing implementation. |
| 31 | void PluginCrashed(PP_Module module) { |
| 32 | NOTREACHED(); |
Nico Weber | e779c82 | 2019-02-12 20:19:08 | [diff] [blame] | 33 | } |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 34 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 35 | PP_Instance GetInstanceForResource(PP_Resource resource) { |
| 36 | // If a test relies on this, we need to implement it. |
| 37 | NOTREACHED(); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | void SetReserveInstanceIDCallback(PP_Module module, |
| 42 | PP_Bool (*is_seen)(PP_Module, PP_Instance)) { |
| 43 | // This function gets called in HostDispatcher's constructor. We simply don't |
| 44 | // worry about Instance uniqueness in tests, so we can ignore the call. |
| 45 | } |
| 46 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 47 | void AddRefModule(PP_Module module) {} |
| 48 | void ReleaseModule(PP_Module module) {} |
[email protected] | fa4dd291 | 2011-10-17 21:23:29 | [diff] [blame] | 49 | PP_Bool IsInModuleDestructor(PP_Module module) { return PP_FALSE; } |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 50 | |
[email protected] | fa4dd291 | 2011-10-17 21:23:29 | [diff] [blame] | 51 | PPB_Proxy_Private ppb_proxy_private = { |
| 52 | &PluginCrashed, |
| 53 | &GetInstanceForResource, |
| 54 | &SetReserveInstanceIDCallback, |
[email protected] | fa4dd291 | 2011-10-17 21:23:29 | [diff] [blame] | 55 | &AddRefModule, |
| 56 | &ReleaseModule, |
| 57 | &IsInModuleDestructor |
| 58 | }; |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 59 | |
| 60 | // We allow multiple harnesses at a time to respond to 'GetInterface' calls. |
| 61 | // We assume that only 1 harness's GetInterface function will ever support a |
| 62 | // given interface name. In practice, there will either be only 1 GetInterface |
| 63 | // handler (for PluginProxyTest or HostProxyTest), or there will be only 2 |
| 64 | // GetInterface handlers (for TwoWayTest). In the latter case, one handler is |
| 65 | // for the PluginProxyTestHarness and should only respond for PPP interfaces, |
| 66 | // and the other handler is for the HostProxyTestHarness which should only |
| 67 | // ever respond for PPB interfaces. |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 68 | base::ObserverList<ProxyTestHarnessBase>::Unchecked get_interface_handlers_; |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 69 | |
| 70 | const void* MockGetInterface(const char* name) { |
dcheng | 9fae5022 | 2016-10-14 03:21:04 | [diff] [blame] | 71 | for (auto& observer : get_interface_handlers_) { |
| 72 | const void* interface = observer.GetInterface(name); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 73 | if (interface) |
| 74 | return interface; |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 75 | } |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 76 | if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) |
| 77 | return &ppb_proxy_private; |
| 78 | return NULL; |
| 79 | } |
| 80 | |
| 81 | void SetUpRemoteHarness(ProxyTestHarnessBase* harness, |
| 82 | const IPC::ChannelHandle& handle, |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 83 | base::SingleThreadTaskRunner* ipc_task_runner, |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 84 | base::WaitableEvent* shutdown_event, |
| 85 | base::WaitableEvent* harness_set_up) { |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 86 | harness->SetUpHarnessWithChannel(handle, ipc_task_runner, shutdown_event, |
| 87 | false); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 88 | harness_set_up->Signal(); |
| 89 | } |
| 90 | |
| 91 | void TearDownRemoteHarness(ProxyTestHarnessBase* harness, |
| 92 | base::WaitableEvent* harness_torn_down) { |
| 93 | harness->TearDownHarness(); |
| 94 | harness_torn_down->Signal(); |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 95 | } |
| 96 | |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 97 | void RunTaskOnRemoteHarness(const base::Closure& task, |
| 98 | base::WaitableEvent* task_complete) { |
| 99 | task.Run(); |
| 100 | task_complete->Signal(); |
| 101 | } |
| 102 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 103 | } // namespace |
| 104 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 105 | // ProxyTestHarnessBase -------------------------------------------------------- |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 106 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 107 | ProxyTestHarnessBase::ProxyTestHarnessBase() : pp_module_(0x98765), |
| 108 | pp_instance_(0x12345) { |
| 109 | get_interface_handlers_.AddObserver(this); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 110 | } |
| 111 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 112 | ProxyTestHarnessBase::~ProxyTestHarnessBase() { |
| 113 | get_interface_handlers_.RemoveObserver(this); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 114 | } |
| 115 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 116 | const void* ProxyTestHarnessBase::GetInterface(const char* name) { |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 117 | return registered_interfaces_[name]; |
| 118 | } |
| 119 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 120 | void ProxyTestHarnessBase::RegisterTestInterface(const char* name, |
[email protected] | 99ff993 | 2011-09-07 14:14:54 | [diff] [blame] | 121 | const void* test_interface) { |
| 122 | registered_interfaces_[name] = test_interface; |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 123 | } |
| 124 | |
kareng | 1c62eeb | 2014-11-08 16:35:03 | [diff] [blame] | 125 | bool ProxyTestHarnessBase::SupportsInterface(const char* name) { |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 126 | sink().ClearMessages(); |
| 127 | |
| 128 | // IPC doesn't actually write to this when we send a message manually |
| 129 | // not actually using IPC. |
| 130 | bool unused_result = false; |
kareng | 1c62eeb | 2014-11-08 16:35:03 | [diff] [blame] | 131 | PpapiMsg_SupportsInterface msg(name, &unused_result); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 132 | GetDispatcher()->OnMessageReceived(msg); |
| 133 | |
| 134 | const IPC::Message* reply_msg = |
| 135 | sink().GetUniqueMessageMatching(IPC_REPLY_ID); |
| 136 | EXPECT_TRUE(reply_msg); |
| 137 | if (!reply_msg) |
| 138 | return false; |
| 139 | |
mdempsky | 390ab1e | 2016-03-07 22:18:35 | [diff] [blame] | 140 | PpapiMsg_SupportsInterface::ReplyParam reply_data; |
kareng | 1c62eeb | 2014-11-08 16:35:03 | [diff] [blame] | 141 | EXPECT_TRUE(PpapiMsg_SupportsInterface::ReadReplyParam( |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 142 | reply_msg, &reply_data)); |
| 143 | |
| 144 | sink().ClearMessages(); |
tzik | a0f614d | 2016-03-08 00:35:15 | [diff] [blame] | 145 | return std::get<0>(reply_data); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 146 | } |
| 147 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 148 | // PluginProxyTestHarness ------------------------------------------------------ |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 149 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 150 | PluginProxyTestHarness::PluginProxyTestHarness( |
| 151 | GlobalsConfiguration globals_config) |
| 152 | : globals_config_(globals_config) { |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 153 | } |
| 154 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 155 | PluginProxyTestHarness::~PluginProxyTestHarness() { |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 156 | } |
| 157 | |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 158 | PpapiGlobals* PluginProxyTestHarness::GetGlobals() { |
| 159 | return plugin_globals_.get(); |
| 160 | } |
| 161 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 162 | Dispatcher* PluginProxyTestHarness::GetDispatcher() { |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 163 | return plugin_dispatcher_.get(); |
| 164 | } |
| 165 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 166 | void PluginProxyTestHarness::SetUpHarness() { |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 167 | // These must be first since the dispatcher set-up uses them. |
dmichael | b11ca7b | 2015-04-02 16:59:40 | [diff] [blame] | 168 | CreatePluginGlobals(nullptr /* ipc_task_runner */); |
[email protected] | b73c659 | 2013-03-30 17:08:13 | [diff] [blame] | 169 | // Some of the methods called during set-up check that the lock is held. |
| 170 | ProxyAutoLock lock; |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 171 | |
[email protected] | 794d83cd | 2011-10-20 19:09:20 | [diff] [blame] | 172 | resource_tracker().DidCreateInstance(pp_instance()); |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 173 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 174 | plugin_dispatcher_.reset(new PluginDispatcher( |
[email protected] | bc2eeb4 | 2012-05-02 22:35:53 | [diff] [blame] | 175 | &MockGetInterface, |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 176 | PpapiPermissions(), |
[email protected] | bc2eeb4 | 2012-05-02 22:35:53 | [diff] [blame] | 177 | false)); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 178 | plugin_dispatcher_->InitWithTestSink(&sink()); |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 179 | // The plugin proxy delegate is needed for |
| 180 | // |PluginProxyDelegate::GetBrowserSender| which is used |
| 181 | // in |ResourceCreationProxy::GetConnection| to get the channel to the |
| 182 | // browser. In this case we just use the |plugin_dispatcher_| as the channel |
| 183 | // for test purposes. |
| 184 | plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
dmichael | fee3a51 | 2014-09-18 21:32:13 | [diff] [blame] | 185 | PluginGlobals::Get()->SetPluginProxyDelegate(&plugin_delegate_mock_); |
[email protected] | 22fdaa6 | 2012-11-30 01:55:44 | [diff] [blame] | 186 | plugin_dispatcher_->DidCreateInstance(pp_instance()); |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 187 | } |
| 188 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 189 | void PluginProxyTestHarness::SetUpHarnessWithChannel( |
| 190 | const IPC::ChannelHandle& channel_handle, |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 191 | base::SingleThreadTaskRunner* ipc_task_runner, |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 192 | base::WaitableEvent* shutdown_event, |
| 193 | bool is_client) { |
| 194 | // These must be first since the dispatcher set-up uses them. |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 195 | CreatePluginGlobals(ipc_task_runner); |
[email protected] | b73c659 | 2013-03-30 17:08:13 | [diff] [blame] | 196 | // Some of the methods called during set-up check that the lock is held. |
| 197 | ProxyAutoLock lock; |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 198 | |
[email protected] | 794d83cd | 2011-10-20 19:09:20 | [diff] [blame] | 199 | resource_tracker().DidCreateInstance(pp_instance()); |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 200 | plugin_delegate_mock_.Init(ipc_task_runner, shutdown_event); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 201 | |
| 202 | plugin_dispatcher_.reset(new PluginDispatcher( |
[email protected] | bc2eeb4 | 2012-05-02 22:35:53 | [diff] [blame] | 203 | &MockGetInterface, |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 204 | PpapiPermissions(), |
[email protected] | bc2eeb4 | 2012-05-02 22:35:53 | [diff] [blame] | 205 | false)); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 206 | plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, |
[email protected] | 108fd34 | 2013-01-04 20:46:54 | [diff] [blame] | 207 | base::kNullProcessId, |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 208 | channel_handle, |
| 209 | is_client); |
[email protected] | 22fdaa6 | 2012-11-30 01:55:44 | [diff] [blame] | 210 | plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
dmichael | fee3a51 | 2014-09-18 21:32:13 | [diff] [blame] | 211 | PluginGlobals::Get()->SetPluginProxyDelegate(&plugin_delegate_mock_); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 212 | plugin_dispatcher_->DidCreateInstance(pp_instance()); |
| 213 | } |
| 214 | |
| 215 | void PluginProxyTestHarness::TearDownHarness() { |
[email protected] | b73c659 | 2013-03-30 17:08:13 | [diff] [blame] | 216 | { |
| 217 | // Some of the methods called during tear-down check that the lock is held. |
| 218 | ProxyAutoLock lock; |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 219 | |
[email protected] | b73c659 | 2013-03-30 17:08:13 | [diff] [blame] | 220 | plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
| 221 | plugin_dispatcher_.reset(); |
| 222 | |
| 223 | resource_tracker().DidDeleteInstance(pp_instance()); |
| 224 | } |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 225 | plugin_globals_.reset(); |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 226 | } |
| 227 | |
dmichael | b11ca7b | 2015-04-02 16:59:40 | [diff] [blame] | 228 | void PluginProxyTestHarness::CreatePluginGlobals( |
| 229 | const scoped_refptr<base::TaskRunner>& ipc_task_runner) { |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 230 | if (globals_config_ == PER_THREAD_GLOBALS) { |
dmichael | b11ca7b | 2015-04-02 16:59:40 | [diff] [blame] | 231 | plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest(), |
| 232 | ipc_task_runner)); |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 233 | PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 234 | } else { |
dmichael | b11ca7b | 2015-04-02 16:59:40 | [diff] [blame] | 235 | plugin_globals_.reset(new PluginGlobals(ipc_task_runner)); |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | |
skyostil | 12262cf | 2015-05-21 14:49:31 | [diff] [blame] | 239 | base::SingleThreadTaskRunner* |
| 240 | PluginProxyTestHarness::PluginDelegateMock::GetIPCTaskRunner() { |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 241 | return ipc_task_runner_; |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | base::WaitableEvent* |
| 245 | PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
| 246 | return shutdown_event_; |
| 247 | } |
| 248 | |
[email protected] | f0ecb55 | 2012-05-11 22:09:11 | [diff] [blame] | 249 | IPC::PlatformFileForTransit |
| 250 | PluginProxyTestHarness::PluginDelegateMock::ShareHandleWithRemote( |
| 251 | base::PlatformFile handle, |
[email protected] | 108fd34 | 2013-01-04 20:46:54 | [diff] [blame] | 252 | base::ProcessId /* remote_pid */, |
[email protected] | f0ecb55 | 2012-05-11 22:09:11 | [diff] [blame] | 253 | bool should_close_source) { |
erikchen | 09b4003 | 2016-04-06 18:51:55 | [diff] [blame] | 254 | return IPC::GetPlatformFileForTransit(handle, |
| 255 | should_close_source); |
[email protected] | f0ecb55 | 2012-05-11 22:09:11 | [diff] [blame] | 256 | } |
| 257 | |
erikchen | 4fc32d5 | 2015-06-02 02:16:38 | [diff] [blame] | 258 | base::SharedMemoryHandle |
| 259 | PluginProxyTestHarness::PluginDelegateMock::ShareSharedMemoryHandleWithRemote( |
| 260 | const base::SharedMemoryHandle& handle, |
erikchen | fc29ad99 | 2015-06-04 20:44:18 | [diff] [blame] | 261 | base::ProcessId /* remote_pid */) { |
| 262 | return base::SharedMemory::DuplicateHandle(handle); |
erikchen | 4fc32d5 | 2015-06-02 02:16:38 | [diff] [blame] | 263 | } |
| 264 | |
Alexandr Ilin | c7d975f | 2018-06-01 09:25:41 | [diff] [blame] | 265 | base::UnsafeSharedMemoryRegion PluginProxyTestHarness::PluginDelegateMock:: |
| 266 | ShareUnsafeSharedMemoryRegionWithRemote( |
| 267 | const base::UnsafeSharedMemoryRegion& region, |
| 268 | base::ProcessId /* remote_pid */) { |
| 269 | return region.Duplicate(); |
| 270 | } |
| 271 | |
| 272 | base::ReadOnlySharedMemoryRegion PluginProxyTestHarness::PluginDelegateMock:: |
| 273 | ShareReadOnlySharedMemoryRegionWithRemote( |
| 274 | const base::ReadOnlySharedMemoryRegion& region, |
| 275 | base::ProcessId /* remote_pid */) { |
| 276 | return region.Duplicate(); |
| 277 | } |
| 278 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 279 | std::set<PP_Instance>* |
| 280 | PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() { |
| 281 | return &instance_id_set_; |
| 282 | } |
| 283 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 284 | uint32_t PluginProxyTestHarness::PluginDelegateMock::Register( |
[email protected] | 6fc87e0 | 2011-12-20 19:18:45 | [diff] [blame] | 285 | PluginDispatcher* plugin_dispatcher) { |
| 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | void PluginProxyTestHarness::PluginDelegateMock::Unregister( |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 290 | uint32_t plugin_dispatcher_id) {} |
[email protected] | 6fc87e0 | 2011-12-20 19:18:45 | [diff] [blame] | 291 | |
[email protected] | 93df81e | 2012-08-10 22:22:46 | [diff] [blame] | 292 | IPC::Sender* PluginProxyTestHarness::PluginDelegateMock::GetBrowserSender() { |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 293 | return browser_sender_; |
[email protected] | 93df81e | 2012-08-10 22:22:46 | [diff] [blame] | 294 | } |
| 295 | |
[email protected] | 2306303a | 2012-06-11 18:10:37 | [diff] [blame] | 296 | std::string PluginProxyTestHarness::PluginDelegateMock::GetUILanguage() { |
| 297 | return std::string("en-US"); |
| 298 | } |
| 299 | |
mgiuca | 8ca5918 | 2015-07-08 02:10:21 | [diff] [blame] | 300 | void PluginProxyTestHarness::PluginDelegateMock::PreCacheFontForFlash( |
[email protected] | 6fc87e0 | 2011-12-20 19:18:45 | [diff] [blame] | 301 | const void* logfontw) { |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 302 | } |
[email protected] | 7f801d8 | 2011-07-08 23:30:11 | [diff] [blame] | 303 | |
[email protected] | 72a1072 | 2012-06-27 19:30:58 | [diff] [blame] | 304 | void PluginProxyTestHarness::PluginDelegateMock::SetActiveURL( |
| 305 | const std::string& url) { |
| 306 | } |
| 307 | |
[email protected] | 1d14806 | 2013-07-25 20:25:45 | [diff] [blame] | 308 | PP_Resource PluginProxyTestHarness::PluginDelegateMock::CreateBrowserFont( |
| 309 | Connection connection, |
| 310 | PP_Instance instance, |
| 311 | const PP_BrowserFont_Trusted_Description& desc, |
| 312 | const Preferences& prefs) { |
| 313 | return 0; |
| 314 | } |
| 315 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 316 | // PluginProxyTest ------------------------------------------------------------- |
| 317 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 318 | PluginProxyTest::PluginProxyTest() : PluginProxyTestHarness(SINGLETON_GLOBALS) { |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | PluginProxyTest::~PluginProxyTest() { |
| 322 | } |
| 323 | |
| 324 | void PluginProxyTest::SetUp() { |
| 325 | SetUpHarness(); |
| 326 | } |
| 327 | |
| 328 | void PluginProxyTest::TearDown() { |
| 329 | TearDownHarness(); |
| 330 | } |
| 331 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 332 | // PluginProxyMultiThreadTest -------------------------------------------------- |
| 333 | |
| 334 | PluginProxyMultiThreadTest::PluginProxyMultiThreadTest() { |
| 335 | } |
| 336 | |
| 337 | PluginProxyMultiThreadTest::~PluginProxyMultiThreadTest() { |
| 338 | } |
| 339 | |
| 340 | void PluginProxyMultiThreadTest::RunTest() { |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 341 | main_thread_task_runner_ = PpapiGlobals::Get()->GetMainThreadMessageLoop(); |
| 342 | ASSERT_EQ(main_thread_task_runner_.get(), |
| 343 | base::ThreadTaskRunnerHandle::Get().get()); |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 344 | nested_main_thread_message_loop_.reset(new base::RunLoop()); |
| 345 | |
| 346 | secondary_thread_.reset(new base::DelegateSimpleThread( |
| 347 | this, "PluginProxyMultiThreadTest")); |
| 348 | |
| 349 | { |
| 350 | ProxyAutoLock auto_lock; |
| 351 | |
| 352 | // MessageLoopResource assumes that the proxy lock has been acquired. |
| 353 | secondary_thread_message_loop_ = new MessageLoopResource(pp_instance()); |
| 354 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 355 | ASSERT_EQ(PP_OK, |
| 356 | secondary_thread_message_loop_->PostWork( |
| 357 | PP_MakeCompletionCallback( |
| 358 | &PluginProxyMultiThreadTest::InternalSetUpTestOnSecondaryThread, |
| 359 | this), |
| 360 | 0)); |
| 361 | } |
| 362 | |
| 363 | SetUpTestOnMainThread(); |
| 364 | |
| 365 | secondary_thread_->Start(); |
| 366 | nested_main_thread_message_loop_->Run(); |
| 367 | secondary_thread_->Join(); |
| 368 | |
| 369 | { |
| 370 | ProxyAutoLock auto_lock; |
| 371 | |
| 372 | // The destruction requires a valid PpapiGlobals instance, so we should |
| 373 | // explicitly release it. |
| 374 | secondary_thread_message_loop_ = NULL; |
| 375 | } |
| 376 | |
| 377 | secondary_thread_.reset(NULL); |
| 378 | nested_main_thread_message_loop_.reset(NULL); |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 379 | main_thread_task_runner_ = NULL; |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | void PluginProxyMultiThreadTest::CheckOnThread(ThreadType thread_type) { |
| 383 | ProxyAutoLock auto_lock; |
| 384 | if (thread_type == MAIN_THREAD) { |
| 385 | ASSERT_TRUE(MessageLoopResource::GetCurrent()->is_main_thread_loop()); |
| 386 | } else { |
| 387 | ASSERT_EQ(secondary_thread_message_loop_.get(), |
| 388 | MessageLoopResource::GetCurrent()); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | void PluginProxyMultiThreadTest::PostQuitForMainThread() { |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 393 | main_thread_task_runner_->PostTask( |
kylechar | 444859b | 2019-02-20 04:32:19 | [diff] [blame] | 394 | FROM_HERE, base::BindOnce(&PluginProxyMultiThreadTest::QuitNestedLoop, |
| 395 | base::Unretained(this))); |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | void PluginProxyMultiThreadTest::PostQuitForSecondaryThread() { |
| 399 | ProxyAutoLock auto_lock; |
| 400 | secondary_thread_message_loop_->PostQuit(PP_TRUE); |
| 401 | } |
| 402 | |
| 403 | void PluginProxyMultiThreadTest::Run() { |
| 404 | ProxyAutoLock auto_lock; |
| 405 | ASSERT_EQ(PP_OK, secondary_thread_message_loop_->AttachToCurrentThread()); |
| 406 | ASSERT_EQ(PP_OK, secondary_thread_message_loop_->Run()); |
[email protected] | 1b77701 | 2013-07-15 20:42:38 | [diff] [blame] | 407 | secondary_thread_message_loop_->DetachFromThread(); |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | void PluginProxyMultiThreadTest::QuitNestedLoop() { |
| 411 | nested_main_thread_message_loop_->Quit(); |
| 412 | } |
| 413 | |
| 414 | // static |
| 415 | void PluginProxyMultiThreadTest::InternalSetUpTestOnSecondaryThread( |
| 416 | void* user_data, |
| 417 | int32_t result) { |
| 418 | EXPECT_EQ(PP_OK, result); |
| 419 | PluginProxyMultiThreadTest* thiz = |
| 420 | static_cast<PluginProxyMultiThreadTest*>(user_data); |
| 421 | thiz->CheckOnThread(SECONDARY_THREAD); |
| 422 | thiz->SetUpTestOnSecondaryThread(); |
| 423 | } |
| 424 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 425 | // HostProxyTestHarness -------------------------------------------------------- |
| 426 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 427 | HostProxyTestHarness::HostProxyTestHarness(GlobalsConfiguration globals_config) |
dmichael | 6b328f3d | 2014-09-29 23:49:02 | [diff] [blame] | 428 | : globals_config_(globals_config) { |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | HostProxyTestHarness::~HostProxyTestHarness() { |
| 432 | } |
| 433 | |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 434 | PpapiGlobals* HostProxyTestHarness::GetGlobals() { |
| 435 | return host_globals_.get(); |
| 436 | } |
| 437 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 438 | Dispatcher* HostProxyTestHarness::GetDispatcher() { |
| 439 | return host_dispatcher_.get(); |
| 440 | } |
| 441 | |
| 442 | void HostProxyTestHarness::SetUpHarness() { |
[email protected] | 7309756 | 2012-01-12 19:38:55 | [diff] [blame] | 443 | // These must be first since the dispatcher set-up uses them. |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 444 | CreateHostGlobals(); |
| 445 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 446 | host_dispatcher_.reset(new HostDispatcher( |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 447 | pp_module(), |
[email protected] | 8be4584 | 2012-04-13 19:49:29 | [diff] [blame] | 448 | &MockGetInterface, |
[email protected] | 73e20db | 2012-12-12 22:27:06 | [diff] [blame] | 449 | PpapiPermissions::AllPermissions())); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 450 | host_dispatcher_->InitWithTestSink(&sink()); |
| 451 | HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 452 | } |
| 453 | |
| 454 | void HostProxyTestHarness::SetUpHarnessWithChannel( |
| 455 | const IPC::ChannelHandle& channel_handle, |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 456 | base::SingleThreadTaskRunner* ipc_task_runner, |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 457 | base::WaitableEvent* shutdown_event, |
| 458 | bool is_client) { |
[email protected] | 7309756 | 2012-01-12 19:38:55 | [diff] [blame] | 459 | // These must be first since the dispatcher set-up uses them. |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 460 | CreateHostGlobals(); |
| 461 | |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 462 | delegate_mock_.Init(ipc_task_runner, shutdown_event); |
[email protected] | 7309756 | 2012-01-12 19:38:55 | [diff] [blame] | 463 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 464 | host_dispatcher_.reset(new HostDispatcher( |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 465 | pp_module(), |
[email protected] | 8be4584 | 2012-04-13 19:49:29 | [diff] [blame] | 466 | &MockGetInterface, |
[email protected] | 73e20db | 2012-12-12 22:27:06 | [diff] [blame] | 467 | PpapiPermissions::AllPermissions())); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 468 | ppapi::Preferences preferences; |
Hajime Hoshi | 5959c54f | 2019-01-09 01:42:12 | [diff] [blame] | 469 | host_dispatcher_->InitHostWithChannel(&delegate_mock_, base::kNullProcessId, |
| 470 | channel_handle, is_client, preferences, |
| 471 | base::ThreadTaskRunnerHandle::Get()); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 472 | HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 473 | } |
| 474 | |
| 475 | void HostProxyTestHarness::TearDownHarness() { |
| 476 | HostDispatcher::RemoveForInstance(pp_instance()); |
| 477 | host_dispatcher_.reset(); |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 478 | host_globals_.reset(); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 479 | } |
| 480 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 481 | void HostProxyTestHarness::CreateHostGlobals() { |
dmichael | bd96c1e | 2015-02-12 00:58:08 | [diff] [blame] | 482 | disable_locking_.reset(new ProxyLock::LockingDisablerForTest); |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 483 | if (globals_config_ == PER_THREAD_GLOBALS) { |
| 484 | host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); |
| 485 | PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 486 | } else { |
| 487 | host_globals_.reset(new TestGlobals()); |
| 488 | } |
| 489 | } |
| 490 | |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 491 | base::SingleThreadTaskRunner* |
| 492 | HostProxyTestHarness::DelegateMock::GetIPCTaskRunner() { |
| 493 | return ipc_task_runner_; |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { |
| 497 | return shutdown_event_; |
| 498 | } |
| 499 | |
[email protected] | f0ecb55 | 2012-05-11 22:09:11 | [diff] [blame] | 500 | IPC::PlatformFileForTransit |
| 501 | HostProxyTestHarness::DelegateMock::ShareHandleWithRemote( |
| 502 | base::PlatformFile handle, |
[email protected] | 108fd34 | 2013-01-04 20:46:54 | [diff] [blame] | 503 | base::ProcessId /* remote_pid */, |
[email protected] | f0ecb55 | 2012-05-11 22:09:11 | [diff] [blame] | 504 | bool should_close_source) { |
erikchen | 09b4003 | 2016-04-06 18:51:55 | [diff] [blame] | 505 | return IPC::GetPlatformFileForTransit(handle, |
| 506 | should_close_source); |
[email protected] | f0ecb55 | 2012-05-11 22:09:11 | [diff] [blame] | 507 | } |
| 508 | |
erikchen | 4fc32d5 | 2015-06-02 02:16:38 | [diff] [blame] | 509 | base::SharedMemoryHandle |
| 510 | HostProxyTestHarness::DelegateMock::ShareSharedMemoryHandleWithRemote( |
| 511 | const base::SharedMemoryHandle& handle, |
erikchen | fc29ad99 | 2015-06-04 20:44:18 | [diff] [blame] | 512 | base::ProcessId /*remote_pid*/) { |
| 513 | return base::SharedMemory::DuplicateHandle(handle); |
erikchen | 4fc32d5 | 2015-06-02 02:16:38 | [diff] [blame] | 514 | } |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 515 | |
Alexandr Ilin | c7d975f | 2018-06-01 09:25:41 | [diff] [blame] | 516 | base::UnsafeSharedMemoryRegion |
| 517 | HostProxyTestHarness::DelegateMock::ShareUnsafeSharedMemoryRegionWithRemote( |
| 518 | const base::UnsafeSharedMemoryRegion& region, |
| 519 | base::ProcessId /*remote_pid*/) { |
| 520 | return region.Duplicate(); |
| 521 | } |
| 522 | |
| 523 | base::ReadOnlySharedMemoryRegion |
| 524 | HostProxyTestHarness::DelegateMock::ShareReadOnlySharedMemoryRegionWithRemote( |
| 525 | const base::ReadOnlySharedMemoryRegion& region, |
| 526 | base::ProcessId /*remote_pid*/) { |
| 527 | return region.Duplicate(); |
| 528 | } |
| 529 | |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 530 | // HostProxyTest --------------------------------------------------------------- |
| 531 | |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 532 | HostProxyTest::HostProxyTest() : HostProxyTestHarness(SINGLETON_GLOBALS) { |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | HostProxyTest::~HostProxyTest() { |
| 536 | } |
| 537 | |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 538 | void HostProxyTest::SetUp() { |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 539 | SetUpHarness(); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | void HostProxyTest::TearDown() { |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 543 | TearDownHarness(); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 544 | } |
| 545 | |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 546 | // TwoWayTest --------------------------------------------------------------- |
| 547 | |
| 548 | TwoWayTest::TwoWayTest(TwoWayTest::TwoWayTestMode test_mode) |
| 549 | : test_mode_(test_mode), |
[email protected] | 7ef6b79b | 2013-01-17 02:38:24 | [diff] [blame] | 550 | host_(ProxyTestHarnessBase::PER_THREAD_GLOBALS), |
| 551 | plugin_(ProxyTestHarnessBase::PER_THREAD_GLOBALS), |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 552 | io_thread_("TwoWayTest_IOThread"), |
| 553 | plugin_thread_("TwoWayTest_PluginThread"), |
| 554 | remote_harness_(NULL), |
| 555 | local_harness_(NULL), |
gab | f40c0a5e | 2016-06-01 20:10:46 | [diff] [blame] | 556 | channel_created_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 557 | base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 558 | shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 559 | base::WaitableEvent::InitialState::NOT_SIGNALED) { |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 560 | if (test_mode == TEST_PPP_INTERFACE) { |
| 561 | remote_harness_ = &plugin_; |
| 562 | local_harness_ = &host_; |
| 563 | } else { |
| 564 | remote_harness_ = &host_; |
| 565 | local_harness_ = &plugin_; |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | TwoWayTest::~TwoWayTest() { |
| 570 | shutdown_event_.Signal(); |
| 571 | } |
| 572 | |
| 573 | void TwoWayTest::SetUp() { |
| 574 | base::Thread::Options options; |
Carlos Caballero | dd8bf7b04 | 2019-07-30 14:14:15 | [diff] [blame^] | 575 | options.message_pump_type = base::MessagePumpType::IO; |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 576 | io_thread_.StartWithOptions(options); |
| 577 | plugin_thread_.Start(); |
| 578 | |
sammc | 9bf370c | 2016-11-14 03:29:08 | [diff] [blame] | 579 | mojo::MessagePipe pipe; |
gab | f40c0a5e | 2016-06-01 20:10:46 | [diff] [blame] | 580 | base::WaitableEvent remote_harness_set_up( |
| 581 | base::WaitableEvent::ResetPolicy::MANUAL, |
| 582 | base::WaitableEvent::InitialState::NOT_SIGNALED); |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 583 | plugin_thread_.task_runner()->PostTask( |
kylechar | 444859b | 2019-02-20 04:32:19 | [diff] [blame] | 584 | FROM_HERE, base::BindOnce(&SetUpRemoteHarness, remote_harness_, |
| 585 | pipe.handle0.release(), |
| 586 | base::RetainedRef(io_thread_.task_runner()), |
| 587 | &shutdown_event_, &remote_harness_set_up)); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 588 | remote_harness_set_up.Wait(); |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 589 | local_harness_->SetUpHarnessWithChannel( |
sammc | 9bf370c | 2016-11-14 03:29:08 | [diff] [blame] | 590 | pipe.handle1.release(), io_thread_.task_runner().get(), &shutdown_event_, |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 591 | true); // is_client |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | void TwoWayTest::TearDown() { |
gab | f40c0a5e | 2016-06-01 20:10:46 | [diff] [blame] | 595 | base::WaitableEvent remote_harness_torn_down( |
| 596 | base::WaitableEvent::ResetPolicy::MANUAL, |
| 597 | base::WaitableEvent::InitialState::NOT_SIGNALED); |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 598 | plugin_thread_.task_runner()->PostTask( |
kylechar | 444859b | 2019-02-20 04:32:19 | [diff] [blame] | 599 | FROM_HERE, base::BindOnce(&TearDownRemoteHarness, remote_harness_, |
| 600 | &remote_harness_torn_down)); |
[email protected] | 912f3d6c | 2011-06-29 18:26:36 | [diff] [blame] | 601 | remote_harness_torn_down.Wait(); |
| 602 | |
| 603 | local_harness_->TearDownHarness(); |
| 604 | |
| 605 | io_thread_.Stop(); |
| 606 | } |
| 607 | |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 608 | void TwoWayTest::PostTaskOnRemoteHarness(const base::Closure& task) { |
gab | f40c0a5e | 2016-06-01 20:10:46 | [diff] [blame] | 609 | base::WaitableEvent task_complete( |
| 610 | base::WaitableEvent::ResetPolicy::MANUAL, |
| 611 | base::WaitableEvent::InitialState::NOT_SIGNALED); |
skyostil | 23490d4 | 2015-06-12 12:54:26 | [diff] [blame] | 612 | plugin_thread_.task_runner()->PostTask( |
kylechar | 444859b | 2019-02-20 04:32:19 | [diff] [blame] | 613 | FROM_HERE, base::BindOnce(&RunTaskOnRemoteHarness, task, &task_complete)); |
[email protected] | d57fd38 | 2012-09-19 00:55:42 | [diff] [blame] | 614 | task_complete.Wait(); |
| 615 | } |
| 616 | |
| 617 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 618 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 619 | } // namespace ppapi |