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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 PpapiGlobals* PluginProxyTestHarness::GetGlobals() { | 156 PpapiGlobals* PluginProxyTestHarness::GetGlobals() { |
157 return plugin_globals_.get(); | 157 return plugin_globals_.get(); |
158 } | 158 } |
159 | 159 |
160 Dispatcher* PluginProxyTestHarness::GetDispatcher() { | 160 Dispatcher* PluginProxyTestHarness::GetDispatcher() { |
161 return plugin_dispatcher_.get(); | 161 return plugin_dispatcher_.get(); |
162 } | 162 } |
163 | 163 |
164 void PluginProxyTestHarness::SetUpHarness() { | 164 void PluginProxyTestHarness::SetUpHarness() { |
165 // These must be first since the dispatcher set-up uses them. | 165 // These must be first since the dispatcher set-up uses them. |
166 CreatePluginGlobals(); | 166 CreatePluginGlobals(nullptr /* ipc_task_runner */); |
167 // Some of the methods called during set-up check that the lock is held. | 167 // Some of the methods called during set-up check that the lock is held. |
168 ProxyAutoLock lock; | 168 ProxyAutoLock lock; |
169 | 169 |
170 resource_tracker().DidCreateInstance(pp_instance()); | 170 resource_tracker().DidCreateInstance(pp_instance()); |
171 | 171 |
172 plugin_dispatcher_.reset(new PluginDispatcher( | 172 plugin_dispatcher_.reset(new PluginDispatcher( |
173 &MockGetInterface, | 173 &MockGetInterface, |
174 PpapiPermissions(), | 174 PpapiPermissions(), |
175 false)); | 175 false)); |
176 plugin_dispatcher_->InitWithTestSink(&sink()); | 176 plugin_dispatcher_->InitWithTestSink(&sink()); |
177 // The plugin proxy delegate is needed for | 177 // The plugin proxy delegate is needed for |
178 // |PluginProxyDelegate::GetBrowserSender| which is used | 178 // |PluginProxyDelegate::GetBrowserSender| which is used |
179 // in |ResourceCreationProxy::GetConnection| to get the channel to the | 179 // in |ResourceCreationProxy::GetConnection| to get the channel to the |
180 // browser. In this case we just use the |plugin_dispatcher_| as the channel | 180 // browser. In this case we just use the |plugin_dispatcher_| as the channel |
181 // for test purposes. | 181 // for test purposes. |
182 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 182 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
183 PluginGlobals::Get()->SetPluginProxyDelegate(&plugin_delegate_mock_); | 183 PluginGlobals::Get()->SetPluginProxyDelegate(&plugin_delegate_mock_); |
184 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 184 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
185 } | 185 } |
186 | 186 |
187 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 187 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
188 const IPC::ChannelHandle& channel_handle, | 188 const IPC::ChannelHandle& channel_handle, |
189 base::MessageLoopProxy* ipc_message_loop, | 189 base::MessageLoopProxy* ipc_message_loop, |
190 base::WaitableEvent* shutdown_event, | 190 base::WaitableEvent* shutdown_event, |
191 bool is_client) { | 191 bool is_client) { |
192 // These must be first since the dispatcher set-up uses them. | 192 // These must be first since the dispatcher set-up uses them. |
193 CreatePluginGlobals(); | 193 scoped_refptr<base::TaskRunner> ipc_task_runner(ipc_message_loop); |
| 194 CreatePluginGlobals(ipc_message_loop); |
194 // Some of the methods called during set-up check that the lock is held. | 195 // Some of the methods called during set-up check that the lock is held. |
195 ProxyAutoLock lock; | 196 ProxyAutoLock lock; |
196 | 197 |
197 resource_tracker().DidCreateInstance(pp_instance()); | 198 resource_tracker().DidCreateInstance(pp_instance()); |
198 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); | 199 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); |
199 | 200 |
200 plugin_dispatcher_.reset(new PluginDispatcher( | 201 plugin_dispatcher_.reset(new PluginDispatcher( |
201 &MockGetInterface, | 202 &MockGetInterface, |
202 PpapiPermissions(), | 203 PpapiPermissions(), |
203 false)); | 204 false)); |
(...skipping 12 matching lines...) Expand all Loading... |
216 ProxyAutoLock lock; | 217 ProxyAutoLock lock; |
217 | 218 |
218 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 219 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
219 plugin_dispatcher_.reset(); | 220 plugin_dispatcher_.reset(); |
220 | 221 |
221 resource_tracker().DidDeleteInstance(pp_instance()); | 222 resource_tracker().DidDeleteInstance(pp_instance()); |
222 } | 223 } |
223 plugin_globals_.reset(); | 224 plugin_globals_.reset(); |
224 } | 225 } |
225 | 226 |
226 void PluginProxyTestHarness::CreatePluginGlobals() { | 227 void PluginProxyTestHarness::CreatePluginGlobals( |
| 228 const scoped_refptr<base::TaskRunner>& ipc_task_runner) { |
227 if (globals_config_ == PER_THREAD_GLOBALS) { | 229 if (globals_config_ == PER_THREAD_GLOBALS) { |
228 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); | 230 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest(), |
| 231 ipc_task_runner)); |
229 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 232 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
230 } else { | 233 } else { |
231 plugin_globals_.reset(new PluginGlobals()); | 234 plugin_globals_.reset(new PluginGlobals(ipc_task_runner)); |
232 } | 235 } |
233 } | 236 } |
234 | 237 |
235 base::MessageLoopProxy* | 238 base::MessageLoopProxy* |
236 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 239 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
237 return ipc_message_loop_; | 240 return ipc_message_loop_; |
238 } | 241 } |
239 | 242 |
240 base::WaitableEvent* | 243 base::WaitableEvent* |
241 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 244 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 577 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
575 base::Bind(&RunTaskOnRemoteHarness, | 578 base::Bind(&RunTaskOnRemoteHarness, |
576 task, | 579 task, |
577 &task_complete)); | 580 &task_complete)); |
578 task_complete.Wait(); | 581 task_complete.Wait(); |
579 } | 582 } |
580 | 583 |
581 | 584 |
582 } // namespace proxy | 585 } // namespace proxy |
583 } // namespace ppapi | 586 } // namespace ppapi |
OLD | NEW |