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