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