| 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/compiler_specific.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/run_loop.h" |
| 14 #include "ipc/ipc_sync_channel.h" | 15 #include "ipc/ipc_sync_channel.h" |
| 15 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
| 16 #include "ppapi/c/private/ppb_proxy_private.h" | 17 #include "ppapi/c/private/ppb_proxy_private.h" |
| 17 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| 19 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
| 20 #include "ppapi/shared_impl/proxy_lock.h" |
| 18 | 21 |
| 19 namespace ppapi { | 22 namespace ppapi { |
| 20 namespace proxy { | 23 namespace proxy { |
| 21 | 24 |
| 22 namespace { | 25 namespace { |
| 23 // HostDispatcher requires a PPB_Proxy_Private, so we always provide a fallback | 26 // HostDispatcher requires a PPB_Proxy_Private, so we always provide a fallback |
| 24 // do-nothing implementation. | 27 // do-nothing implementation. |
| 25 void PluginCrashed(PP_Module module) { | 28 void PluginCrashed(PP_Module module) { |
| 26 NOTREACHED(); | 29 NOTREACHED(); |
| 27 }; | 30 }; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 TupleTypes<PpapiMsg_SupportsInterface::ReplyParam>::ValueTuple reply_data; | 145 TupleTypes<PpapiMsg_SupportsInterface::ReplyParam>::ValueTuple reply_data; |
| 143 EXPECT_TRUE(PpapiMsg_SupportsInterface::ReadReplyParam( | 146 EXPECT_TRUE(PpapiMsg_SupportsInterface::ReadReplyParam( |
| 144 reply_msg, &reply_data)); | 147 reply_msg, &reply_data)); |
| 145 | 148 |
| 146 sink().ClearMessages(); | 149 sink().ClearMessages(); |
| 147 return reply_data.a; | 150 return reply_data.a; |
| 148 } | 151 } |
| 149 | 152 |
| 150 // PluginProxyTestHarness ------------------------------------------------------ | 153 // PluginProxyTestHarness ------------------------------------------------------ |
| 151 | 154 |
| 152 PluginProxyTestHarness::PluginProxyTestHarness() { | 155 PluginProxyTestHarness::PluginProxyTestHarness( |
| 156 GlobalsConfiguration globals_config) |
| 157 : globals_config_(globals_config) { |
| 153 } | 158 } |
| 154 | 159 |
| 155 PluginProxyTestHarness::~PluginProxyTestHarness() { | 160 PluginProxyTestHarness::~PluginProxyTestHarness() { |
| 156 } | 161 } |
| 157 | 162 |
| 158 PpapiGlobals* PluginProxyTestHarness::GetGlobals() { | 163 PpapiGlobals* PluginProxyTestHarness::GetGlobals() { |
| 159 return plugin_globals_.get(); | 164 return plugin_globals_.get(); |
| 160 } | 165 } |
| 161 | 166 |
| 162 Dispatcher* PluginProxyTestHarness::GetDispatcher() { | 167 Dispatcher* PluginProxyTestHarness::GetDispatcher() { |
| 163 return plugin_dispatcher_.get(); | 168 return plugin_dispatcher_.get(); |
| 164 } | 169 } |
| 165 | 170 |
| 166 void PluginProxyTestHarness::SetUpHarness() { | 171 void PluginProxyTestHarness::SetUpHarness() { |
| 167 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); | 172 // These must be first since the dispatcher set-up uses them. |
| 173 CreatePluginGlobals(); |
| 168 | 174 |
| 169 // These must be first since the dispatcher set-up uses them. | |
| 170 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | |
| 171 resource_tracker().DidCreateInstance(pp_instance()); | 175 resource_tracker().DidCreateInstance(pp_instance()); |
| 172 | 176 |
| 173 plugin_dispatcher_.reset(new PluginDispatcher( | 177 plugin_dispatcher_.reset(new PluginDispatcher( |
| 174 &MockGetInterface, | 178 &MockGetInterface, |
| 175 PpapiPermissions(), | 179 PpapiPermissions(), |
| 176 false)); | 180 false)); |
| 177 plugin_dispatcher_->InitWithTestSink(&sink()); | 181 plugin_dispatcher_->InitWithTestSink(&sink()); |
| 178 // The plugin proxy delegate is needed for | 182 // The plugin proxy delegate is needed for |
| 179 // |PluginProxyDelegate::GetBrowserSender| which is used | 183 // |PluginProxyDelegate::GetBrowserSender| which is used |
| 180 // in |ResourceCreationProxy::GetConnection| to get the channel to the | 184 // in |ResourceCreationProxy::GetConnection| to get the channel to the |
| 181 // 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 |
| 182 // for test purposes. | 186 // for test purposes. |
| 183 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 187 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
| 184 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 188 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
| 185 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 189 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
| 186 } | 190 } |
| 187 | 191 |
| 188 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 192 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
| 189 const IPC::ChannelHandle& channel_handle, | 193 const IPC::ChannelHandle& channel_handle, |
| 190 base::MessageLoopProxy* ipc_message_loop, | 194 base::MessageLoopProxy* ipc_message_loop, |
| 191 base::WaitableEvent* shutdown_event, | 195 base::WaitableEvent* shutdown_event, |
| 192 bool is_client) { | 196 bool is_client) { |
| 193 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); | 197 // These must be first since the dispatcher set-up uses them. |
| 198 CreatePluginGlobals(); |
| 194 | 199 |
| 195 // These must be first since the dispatcher set-up uses them. | |
| 196 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | |
| 197 resource_tracker().DidCreateInstance(pp_instance()); | 200 resource_tracker().DidCreateInstance(pp_instance()); |
| 198 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); | 201 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); |
| 199 | 202 |
| 200 plugin_dispatcher_.reset(new PluginDispatcher( | 203 plugin_dispatcher_.reset(new PluginDispatcher( |
| 201 &MockGetInterface, | 204 &MockGetInterface, |
| 202 PpapiPermissions(), | 205 PpapiPermissions(), |
| 203 false)); | 206 false)); |
| 204 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, | 207 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, |
| 205 base::kNullProcessId, | 208 base::kNullProcessId, |
| 206 channel_handle, | 209 channel_handle, |
| 207 is_client); | 210 is_client); |
| 208 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); | 211 plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
| 209 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); | 212 PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
| 210 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 213 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
| 211 } | 214 } |
| 212 | 215 |
| 213 void PluginProxyTestHarness::TearDownHarness() { | 216 void PluginProxyTestHarness::TearDownHarness() { |
| 214 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 217 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
| 215 plugin_dispatcher_.reset(); | 218 plugin_dispatcher_.reset(); |
| 216 | 219 |
| 217 resource_tracker().DidDeleteInstance(pp_instance()); | 220 resource_tracker().DidDeleteInstance(pp_instance()); |
| 218 plugin_globals_.reset(); | 221 plugin_globals_.reset(); |
| 219 } | 222 } |
| 220 | 223 |
| 224 void PluginProxyTestHarness::CreatePluginGlobals() { |
| 225 if (globals_config_ == PER_THREAD_GLOBALS) { |
| 226 plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); |
| 227 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 228 } else { |
| 229 plugin_globals_.reset(new PluginGlobals()); |
| 230 } |
| 231 } |
| 232 |
| 221 base::MessageLoopProxy* | 233 base::MessageLoopProxy* |
| 222 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 234 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
| 223 return ipc_message_loop_; | 235 return ipc_message_loop_; |
| 224 } | 236 } |
| 225 | 237 |
| 226 base::WaitableEvent* | 238 base::WaitableEvent* |
| 227 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 239 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
| 228 return shutdown_event_; | 240 return shutdown_event_; |
| 229 } | 241 } |
| 230 | 242 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 void PluginProxyTestHarness::PluginDelegateMock::PreCacheFont( | 275 void PluginProxyTestHarness::PluginDelegateMock::PreCacheFont( |
| 264 const void* logfontw) { | 276 const void* logfontw) { |
| 265 } | 277 } |
| 266 | 278 |
| 267 void PluginProxyTestHarness::PluginDelegateMock::SetActiveURL( | 279 void PluginProxyTestHarness::PluginDelegateMock::SetActiveURL( |
| 268 const std::string& url) { | 280 const std::string& url) { |
| 269 } | 281 } |
| 270 | 282 |
| 271 // PluginProxyTest ------------------------------------------------------------- | 283 // PluginProxyTest ------------------------------------------------------------- |
| 272 | 284 |
| 273 PluginProxyTest::PluginProxyTest() { | 285 PluginProxyTest::PluginProxyTest() : PluginProxyTestHarness(SINGLETON_GLOBALS) { |
| 274 } | 286 } |
| 275 | 287 |
| 276 PluginProxyTest::~PluginProxyTest() { | 288 PluginProxyTest::~PluginProxyTest() { |
| 277 } | 289 } |
| 278 | 290 |
| 279 void PluginProxyTest::SetUp() { | 291 void PluginProxyTest::SetUp() { |
| 280 SetUpHarness(); | 292 SetUpHarness(); |
| 281 } | 293 } |
| 282 | 294 |
| 283 void PluginProxyTest::TearDown() { | 295 void PluginProxyTest::TearDown() { |
| 284 TearDownHarness(); | 296 TearDownHarness(); |
| 285 } | 297 } |
| 286 | 298 |
| 299 // PluginProxyMultiThreadTest -------------------------------------------------- |
| 300 |
| 301 PluginProxyMultiThreadTest::PluginProxyMultiThreadTest() { |
| 302 } |
| 303 |
| 304 PluginProxyMultiThreadTest::~PluginProxyMultiThreadTest() { |
| 305 } |
| 306 |
| 307 void PluginProxyMultiThreadTest::RunTest() { |
| 308 main_thread_message_loop_proxy_ = |
| 309 PpapiGlobals::Get()->GetMainThreadMessageLoop(); |
| 310 ASSERT_EQ(main_thread_message_loop_proxy_.get(), |
| 311 base::MessageLoopProxy::current()); |
| 312 nested_main_thread_message_loop_.reset(new base::RunLoop()); |
| 313 |
| 314 secondary_thread_.reset(new base::DelegateSimpleThread( |
| 315 this, "PluginProxyMultiThreadTest")); |
| 316 |
| 317 { |
| 318 ProxyAutoLock auto_lock; |
| 319 |
| 320 // MessageLoopResource assumes that the proxy lock has been acquired. |
| 321 secondary_thread_message_loop_ = new MessageLoopResource(pp_instance()); |
| 322 |
| 323 // TODO(yzshen): The comment of PPB_MessageLoop says that it would return |
| 324 // PP_OK_COMPLETIONPENDING. Either fix the comment or the implementation. |
| 325 ASSERT_EQ(PP_OK, |
| 326 secondary_thread_message_loop_->PostWork( |
| 327 PP_MakeCompletionCallback( |
| 328 &PluginProxyMultiThreadTest::InternalSetUpTestOnSecondaryThread, |
| 329 this), |
| 330 0)); |
| 331 } |
| 332 |
| 333 SetUpTestOnMainThread(); |
| 334 |
| 335 secondary_thread_->Start(); |
| 336 nested_main_thread_message_loop_->Run(); |
| 337 secondary_thread_->Join(); |
| 338 |
| 339 { |
| 340 ProxyAutoLock auto_lock; |
| 341 |
| 342 // The destruction requires a valid PpapiGlobals instance, so we should |
| 343 // explicitly release it. |
| 344 secondary_thread_message_loop_ = NULL; |
| 345 } |
| 346 |
| 347 secondary_thread_.reset(NULL); |
| 348 nested_main_thread_message_loop_.reset(NULL); |
| 349 main_thread_message_loop_proxy_ = NULL; |
| 350 } |
| 351 |
| 352 void PluginProxyMultiThreadTest::CheckOnValidThread(ThreadType thread_type) { |
| 353 ProxyAutoLock auto_lock; |
| 354 if (thread_type == MAIN_THREAD) { |
| 355 ASSERT_TRUE(MessageLoopResource::GetCurrent()->is_main_thread_loop()); |
| 356 } else { |
| 357 ASSERT_EQ(secondary_thread_message_loop_.get(), |
| 358 MessageLoopResource::GetCurrent()); |
| 359 } |
| 360 } |
| 361 |
| 362 void PluginProxyMultiThreadTest::PostQuitForMainThread() { |
| 363 main_thread_message_loop_proxy_->PostTask( |
| 364 FROM_HERE, |
| 365 base::Bind(&PluginProxyMultiThreadTest::QuitNestedLoop, |
| 366 base::Unretained(this))); |
| 367 } |
| 368 |
| 369 void PluginProxyMultiThreadTest::PostQuitForSecondaryThread() { |
| 370 ProxyAutoLock auto_lock; |
| 371 secondary_thread_message_loop_->PostQuit(PP_TRUE); |
| 372 } |
| 373 |
| 374 void PluginProxyMultiThreadTest::Run() { |
| 375 ProxyAutoLock auto_lock; |
| 376 ASSERT_EQ(PP_OK, secondary_thread_message_loop_->AttachToCurrentThread()); |
| 377 ASSERT_EQ(PP_OK, secondary_thread_message_loop_->Run()); |
| 378 } |
| 379 |
| 380 void PluginProxyMultiThreadTest::QuitNestedLoop() { |
| 381 nested_main_thread_message_loop_->Quit(); |
| 382 } |
| 383 |
| 384 // static |
| 385 void PluginProxyMultiThreadTest::InternalSetUpTestOnSecondaryThread( |
| 386 void* user_data, |
| 387 int32_t result) { |
| 388 EXPECT_EQ(PP_OK, result); |
| 389 PluginProxyMultiThreadTest* thiz = |
| 390 static_cast<PluginProxyMultiThreadTest*>(user_data); |
| 391 thiz->CheckOnValidThread(SECONDARY_THREAD); |
| 392 thiz->SetUpTestOnSecondaryThread(); |
| 393 } |
| 394 |
| 287 // HostProxyTestHarness -------------------------------------------------------- | 395 // HostProxyTestHarness -------------------------------------------------------- |
| 288 | 396 |
| 289 class HostProxyTestHarness::MockSyncMessageStatusReceiver | 397 class HostProxyTestHarness::MockSyncMessageStatusReceiver |
| 290 : public HostDispatcher::SyncMessageStatusReceiver { | 398 : public HostDispatcher::SyncMessageStatusReceiver { |
| 291 public: | 399 public: |
| 292 virtual void BeginBlockOnSyncMessage() OVERRIDE {} | 400 virtual void BeginBlockOnSyncMessage() OVERRIDE {} |
| 293 virtual void EndBlockOnSyncMessage() OVERRIDE {} | 401 virtual void EndBlockOnSyncMessage() OVERRIDE {} |
| 294 }; | 402 }; |
| 295 | 403 |
| 296 HostProxyTestHarness::HostProxyTestHarness() | 404 HostProxyTestHarness::HostProxyTestHarness(GlobalsConfiguration globals_config) |
| 297 : status_receiver_(new MockSyncMessageStatusReceiver) { | 405 : globals_config_(globals_config), |
| 406 status_receiver_(new MockSyncMessageStatusReceiver) { |
| 298 } | 407 } |
| 299 | 408 |
| 300 HostProxyTestHarness::~HostProxyTestHarness() { | 409 HostProxyTestHarness::~HostProxyTestHarness() { |
| 301 } | 410 } |
| 302 | 411 |
| 303 PpapiGlobals* HostProxyTestHarness::GetGlobals() { | 412 PpapiGlobals* HostProxyTestHarness::GetGlobals() { |
| 304 return host_globals_.get(); | 413 return host_globals_.get(); |
| 305 } | 414 } |
| 306 | 415 |
| 307 Dispatcher* HostProxyTestHarness::GetDispatcher() { | 416 Dispatcher* HostProxyTestHarness::GetDispatcher() { |
| 308 return host_dispatcher_.get(); | 417 return host_dispatcher_.get(); |
| 309 } | 418 } |
| 310 | 419 |
| 311 void HostProxyTestHarness::SetUpHarness() { | 420 void HostProxyTestHarness::SetUpHarness() { |
| 312 host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); | 421 // These must be first since the dispatcher set-up uses them. |
| 422 CreateHostGlobals(); |
| 313 | 423 |
| 314 // These must be first since the dispatcher set-up uses them. | |
| 315 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | |
| 316 host_dispatcher_.reset(new HostDispatcher( | 424 host_dispatcher_.reset(new HostDispatcher( |
| 317 pp_module(), | 425 pp_module(), |
| 318 &MockGetInterface, | 426 &MockGetInterface, |
| 319 status_receiver_.release(), | 427 status_receiver_.release(), |
| 320 PpapiPermissions::AllPermissions())); | 428 PpapiPermissions::AllPermissions())); |
| 321 host_dispatcher_->InitWithTestSink(&sink()); | 429 host_dispatcher_->InitWithTestSink(&sink()); |
| 322 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 430 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 323 } | 431 } |
| 324 | 432 |
| 325 void HostProxyTestHarness::SetUpHarnessWithChannel( | 433 void HostProxyTestHarness::SetUpHarnessWithChannel( |
| 326 const IPC::ChannelHandle& channel_handle, | 434 const IPC::ChannelHandle& channel_handle, |
| 327 base::MessageLoopProxy* ipc_message_loop, | 435 base::MessageLoopProxy* ipc_message_loop, |
| 328 base::WaitableEvent* shutdown_event, | 436 base::WaitableEvent* shutdown_event, |
| 329 bool is_client) { | 437 bool is_client) { |
| 330 host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); | 438 // These must be first since the dispatcher set-up uses them. |
| 439 CreateHostGlobals(); |
| 331 | 440 |
| 332 // These must be first since the dispatcher set-up uses them. | |
| 333 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); | |
| 334 delegate_mock_.Init(ipc_message_loop, shutdown_event); | 441 delegate_mock_.Init(ipc_message_loop, shutdown_event); |
| 335 | 442 |
| 336 host_dispatcher_.reset(new HostDispatcher( | 443 host_dispatcher_.reset(new HostDispatcher( |
| 337 pp_module(), | 444 pp_module(), |
| 338 &MockGetInterface, | 445 &MockGetInterface, |
| 339 status_receiver_.release(), | 446 status_receiver_.release(), |
| 340 PpapiPermissions::AllPermissions())); | 447 PpapiPermissions::AllPermissions())); |
| 341 ppapi::Preferences preferences; | 448 ppapi::Preferences preferences; |
| 342 host_dispatcher_->InitHostWithChannel(&delegate_mock_, | 449 host_dispatcher_->InitHostWithChannel(&delegate_mock_, |
| 343 base::kNullProcessId, channel_handle, | 450 base::kNullProcessId, channel_handle, |
| 344 is_client, preferences); | 451 is_client, preferences); |
| 345 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 452 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
| 346 } | 453 } |
| 347 | 454 |
| 348 void HostProxyTestHarness::TearDownHarness() { | 455 void HostProxyTestHarness::TearDownHarness() { |
| 349 HostDispatcher::RemoveForInstance(pp_instance()); | 456 HostDispatcher::RemoveForInstance(pp_instance()); |
| 350 host_dispatcher_.reset(); | 457 host_dispatcher_.reset(); |
| 351 host_globals_.reset(); | 458 host_globals_.reset(); |
| 352 } | 459 } |
| 353 | 460 |
| 461 void HostProxyTestHarness::CreateHostGlobals() { |
| 462 if (globals_config_ == PER_THREAD_GLOBALS) { |
| 463 host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); |
| 464 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); |
| 465 } else { |
| 466 host_globals_.reset(new TestGlobals()); |
| 467 } |
| 468 } |
| 469 |
| 354 base::MessageLoopProxy* | 470 base::MessageLoopProxy* |
| 355 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { | 471 HostProxyTestHarness::DelegateMock::GetIPCMessageLoop() { |
| 356 return ipc_message_loop_; | 472 return ipc_message_loop_; |
| 357 } | 473 } |
| 358 | 474 |
| 359 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { | 475 base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() { |
| 360 return shutdown_event_; | 476 return shutdown_event_; |
| 361 } | 477 } |
| 362 | 478 |
| 363 IPC::PlatformFileForTransit | 479 IPC::PlatformFileForTransit |
| 364 HostProxyTestHarness::DelegateMock::ShareHandleWithRemote( | 480 HostProxyTestHarness::DelegateMock::ShareHandleWithRemote( |
| 365 base::PlatformFile handle, | 481 base::PlatformFile handle, |
| 366 base::ProcessId /* remote_pid */, | 482 base::ProcessId /* remote_pid */, |
| 367 bool should_close_source) { | 483 bool should_close_source) { |
| 368 return IPC::GetFileHandleForProcess(handle, | 484 return IPC::GetFileHandleForProcess(handle, |
| 369 base::Process::Current().handle(), | 485 base::Process::Current().handle(), |
| 370 should_close_source); | 486 should_close_source); |
| 371 } | 487 } |
| 372 | 488 |
| 373 | 489 |
| 374 // HostProxyTest --------------------------------------------------------------- | 490 // HostProxyTest --------------------------------------------------------------- |
| 375 | 491 |
| 376 HostProxyTest::HostProxyTest() { | 492 HostProxyTest::HostProxyTest() : HostProxyTestHarness(SINGLETON_GLOBALS) { |
| 377 } | 493 } |
| 378 | 494 |
| 379 HostProxyTest::~HostProxyTest() { | 495 HostProxyTest::~HostProxyTest() { |
| 380 } | 496 } |
| 381 | 497 |
| 382 void HostProxyTest::SetUp() { | 498 void HostProxyTest::SetUp() { |
| 383 SetUpHarness(); | 499 SetUpHarness(); |
| 384 } | 500 } |
| 385 | 501 |
| 386 void HostProxyTest::TearDown() { | 502 void HostProxyTest::TearDown() { |
| 387 TearDownHarness(); | 503 TearDownHarness(); |
| 388 } | 504 } |
| 389 | 505 |
| 390 // TwoWayTest --------------------------------------------------------------- | 506 // TwoWayTest --------------------------------------------------------------- |
| 391 | 507 |
| 392 TwoWayTest::TwoWayTest(TwoWayTest::TwoWayTestMode test_mode) | 508 TwoWayTest::TwoWayTest(TwoWayTest::TwoWayTestMode test_mode) |
| 393 : test_mode_(test_mode), | 509 : test_mode_(test_mode), |
| 510 host_(ProxyTestHarnessBase::PER_THREAD_GLOBALS), |
| 511 plugin_(ProxyTestHarnessBase::PER_THREAD_GLOBALS), |
| 394 io_thread_("TwoWayTest_IOThread"), | 512 io_thread_("TwoWayTest_IOThread"), |
| 395 plugin_thread_("TwoWayTest_PluginThread"), | 513 plugin_thread_("TwoWayTest_PluginThread"), |
| 396 remote_harness_(NULL), | 514 remote_harness_(NULL), |
| 397 local_harness_(NULL), | 515 local_harness_(NULL), |
| 398 channel_created_(true, false), | 516 channel_created_(true, false), |
| 399 shutdown_event_(true, false) { | 517 shutdown_event_(true, false) { |
| 400 if (test_mode == TEST_PPP_INTERFACE) { | 518 if (test_mode == TEST_PPP_INTERFACE) { |
| 401 remote_harness_ = &plugin_; | 519 remote_harness_ = &plugin_; |
| 402 local_harness_ = &host_; | 520 local_harness_ = &host_; |
| 403 } else { | 521 } else { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 574 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
| 457 base::Bind(&RunTaskOnRemoteHarness, | 575 base::Bind(&RunTaskOnRemoteHarness, |
| 458 task, | 576 task, |
| 459 &task_complete)); | 577 &task_complete)); |
| 460 task_complete.Wait(); | 578 task_complete.Wait(); |
| 461 } | 579 } |
| 462 | 580 |
| 463 | 581 |
| 464 } // namespace proxy | 582 } // namespace proxy |
| 465 } // namespace ppapi | 583 } // namespace ppapi |
| OLD | NEW |