| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 void PluginProxyTestHarness::SetUpHarness() { | 163 void PluginProxyTestHarness::SetUpHarness() { |
| 164 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); | 164 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); |
| 165 | 165 |
| 166 // These must be first since the dispatcher set-up uses them. | 166 // These must be first since the dispatcher set-up uses them. |
| 167 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 167 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 168 resource_tracker().DidCreateInstance(pp_instance()); | 168 resource_tracker().DidCreateInstance(pp_instance()); |
| 169 | 169 |
| 170 plugin_dispatcher_.reset(new PluginDispatcher( | 170 plugin_dispatcher_.reset(new PluginDispatcher( |
| 171 &MockGetInterface, | 171 &MockGetInterface, |
| 172 PpapiPermissions(), |
| 172 false)); | 173 false)); |
| 173 plugin_dispatcher_->InitWithTestSink(&sink()); | 174 plugin_dispatcher_->InitWithTestSink(&sink()); |
| 174 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 175 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
| 175 // The plugin proxy delegate is needed for | 176 // The plugin proxy delegate is needed for |
| 176 // |PluginProxyDelegate::GetBrowserSender| which is used | 177 // |PluginProxyDelegate::GetBrowserSender| which is used |
| 177 // in |ResourceCreationProxy::GetConnection| to get the channel to the | 178 // in |ResourceCreationProxy::GetConnection| to get the channel to the |
| 178 // browser. In this case we just use the |plugin_dispatcher_| as the channel | 179 // browser. In this case we just use the |plugin_dispatcher_| as the channel |
| 179 // for test purposes. | 180 // for test purposes. |
| 180 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 181 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
| 181 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 182 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 185 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
| 185 const IPC::ChannelHandle& channel_handle, | 186 const IPC::ChannelHandle& channel_handle, |
| 186 base::MessageLoopProxy* ipc_message_loop, | 187 base::MessageLoopProxy* ipc_message_loop, |
| 187 base::WaitableEvent* shutdown_event, | 188 base::WaitableEvent* shutdown_event, |
| 188 bool is_client) { | 189 bool is_client) { |
| 189 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); | 190 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); |
| 190 | 191 |
| 191 // These must be first since the dispatcher set-up uses them. | 192 // These must be first since the dispatcher set-up uses them. |
| 192 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 193 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 193 resource_tracker().DidCreateInstance(pp_instance()); | 194 resource_tracker().DidCreateInstance(pp_instance()); |
| 194 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); | 195 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); |
| 195 | 196 |
| 196 plugin_dispatcher_.reset(new PluginDispatcher( | 197 plugin_dispatcher_.reset(new PluginDispatcher( |
| 197 &MockGetInterface, | 198 &MockGetInterface, |
| 199 PpapiPermissions(), |
| 198 false)); | 200 false)); |
| 199 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, | 201 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, |
| 200 channel_handle, | 202 channel_handle, |
| 201 is_client); | 203 is_client); |
| 202 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 204 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
| 203 } | 205 } |
| 204 | 206 |
| 205 void PluginProxyTestHarness::TearDownHarness() { | 207 void PluginProxyTestHarness::TearDownHarness() { |
| 206 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 208 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
| 207 plugin_dispatcher_.reset(); | 209 plugin_dispatcher_.reset(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 309 } |
| 308 | 310 |
| 309 void HostProxyTestHarness::SetUpHarness() { | 311 void HostProxyTestHarness::SetUpHarness() { |
| 310 host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); | 312 host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); |
| 311 | 313 |
| 312 // These must be first since the dispatcher set-up uses them. | 314 // These must be first since the dispatcher set-up uses them. |
| 313 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 315 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 314 host_dispatcher_.reset(new HostDispatcher( | 316 host_dispatcher_.reset(new HostDispatcher( |
| 315 pp_module(), | 317 pp_module(), |
| 316 &MockGetInterface, | 318 &MockGetInterface, |
| 317 status_receiver_.release())); | 319 status_receiver_.release(), |
| 320 PpapiPermissions())); |
| 318 host_dispatcher_->InitWithTestSink(&sink()); | 321 host_dispatcher_->InitWithTestSink(&sink()); |
| 319 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 322 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 320 } | 323 } |
| 321 | 324 |
| 322 void HostProxyTestHarness::SetUpHarnessWithChannel( | 325 void HostProxyTestHarness::SetUpHarnessWithChannel( |
| 323 const IPC::ChannelHandle& channel_handle, | 326 const IPC::ChannelHandle& channel_handle, |
| 324 base::MessageLoopProxy* ipc_message_loop, | 327 base::MessageLoopProxy* ipc_message_loop, |
| 325 base::WaitableEvent* shutdown_event, | 328 base::WaitableEvent* shutdown_event, |
| 326 bool is_client) { | 329 bool is_client) { |
| 327 host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); | 330 host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); |
| 328 | 331 |
| 329 // These must be first since the dispatcher set-up uses them. | 332 // These must be first since the dispatcher set-up uses them. |
| 330 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | 333 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 331 delegate_mock_.Init(ipc_message_loop, shutdown_event); | 334 delegate_mock_.Init(ipc_message_loop, shutdown_event); |
| 332 | 335 |
| 333 host_dispatcher_.reset(new HostDispatcher( | 336 host_dispatcher_.reset(new HostDispatcher( |
| 334 pp_module(), | 337 pp_module(), |
| 335 &MockGetInterface, | 338 &MockGetInterface, |
| 336 status_receiver_.release())); | 339 status_receiver_.release(), |
| 340 PpapiPermissions())); |
| 337 ppapi::Preferences preferences; | 341 ppapi::Preferences preferences; |
| 338 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle, | 342 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle, |
| 339 is_client, preferences); | 343 is_client, preferences); |
| 340 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 344 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 341 } | 345 } |
| 342 | 346 |
| 343 void HostProxyTestHarness::TearDownHarness() { | 347 void HostProxyTestHarness::TearDownHarness() { |
| 344 HostDispatcher::RemoveForInstance(pp_instance()); | 348 HostDispatcher::RemoveForInstance(pp_instance()); |
| 345 host_dispatcher_.reset(); | 349 host_dispatcher_.reset(); |
| 346 host_globals_.reset(); | 350 host_globals_.reset(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 452 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
| 449 base::Bind(&RunTaskOnRemoteHarness, | 453 base::Bind(&RunTaskOnRemoteHarness, |
| 450 task, | 454 task, |
| 451 &task_complete)); | 455 &task_complete)); |
| 452 task_complete.Wait(); | 456 task_complete.Wait(); |
| 453 } | 457 } |
| 454 | 458 |
| 455 | 459 |
| 456 } // namespace proxy | 460 } // namespace proxy |
| 457 } // namespace ppapi | 461 } // namespace ppapi |
| OLD | NEW |