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" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "ipc/ipc_sync_channel.h" | 14 #include "ipc/ipc_sync_channel.h" |
15 #include "ipc/message_filter.h" | |
16 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
17 #include "ppapi/c/private/ppb_proxy_private.h" | 16 #include "ppapi/c/private/ppb_proxy_private.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/proxy/ppb_message_loop_proxy.h" | 18 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
20 #include "ppapi/shared_impl/proxy_lock.h" | 19 #include "ppapi/shared_impl/proxy_lock.h" |
21 | 20 |
22 namespace ppapi { | 21 namespace ppapi { |
23 namespace proxy { | 22 namespace proxy { |
24 | 23 |
25 namespace { | 24 namespace { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 int32_t result) { | 400 int32_t result) { |
402 EXPECT_EQ(PP_OK, result); | 401 EXPECT_EQ(PP_OK, result); |
403 PluginProxyMultiThreadTest* thiz = | 402 PluginProxyMultiThreadTest* thiz = |
404 static_cast<PluginProxyMultiThreadTest*>(user_data); | 403 static_cast<PluginProxyMultiThreadTest*>(user_data); |
405 thiz->CheckOnThread(SECONDARY_THREAD); | 404 thiz->CheckOnThread(SECONDARY_THREAD); |
406 thiz->SetUpTestOnSecondaryThread(); | 405 thiz->SetUpTestOnSecondaryThread(); |
407 } | 406 } |
408 | 407 |
409 // HostProxyTestHarness -------------------------------------------------------- | 408 // HostProxyTestHarness -------------------------------------------------------- |
410 | 409 |
| 410 class HostProxyTestHarness::MockSyncMessageStatusReceiver |
| 411 : public HostDispatcher::SyncMessageStatusReceiver { |
| 412 public: |
| 413 virtual void BeginBlockOnSyncMessage() OVERRIDE {} |
| 414 virtual void EndBlockOnSyncMessage() OVERRIDE {} |
| 415 }; |
| 416 |
411 HostProxyTestHarness::HostProxyTestHarness(GlobalsConfiguration globals_config) | 417 HostProxyTestHarness::HostProxyTestHarness(GlobalsConfiguration globals_config) |
412 : globals_config_(globals_config) { | 418 : globals_config_(globals_config), |
| 419 status_receiver_(new MockSyncMessageStatusReceiver) { |
413 } | 420 } |
414 | 421 |
415 HostProxyTestHarness::~HostProxyTestHarness() { | 422 HostProxyTestHarness::~HostProxyTestHarness() { |
416 } | 423 } |
417 | 424 |
418 PpapiGlobals* HostProxyTestHarness::GetGlobals() { | 425 PpapiGlobals* HostProxyTestHarness::GetGlobals() { |
419 return host_globals_.get(); | 426 return host_globals_.get(); |
420 } | 427 } |
421 | 428 |
422 Dispatcher* HostProxyTestHarness::GetDispatcher() { | 429 Dispatcher* HostProxyTestHarness::GetDispatcher() { |
423 return host_dispatcher_.get(); | 430 return host_dispatcher_.get(); |
424 } | 431 } |
425 | 432 |
426 void HostProxyTestHarness::SetUpHarness() { | 433 void HostProxyTestHarness::SetUpHarness() { |
427 // These must be first since the dispatcher set-up uses them. | 434 // These must be first since the dispatcher set-up uses them. |
428 CreateHostGlobals(); | 435 CreateHostGlobals(); |
429 | 436 |
430 host_dispatcher_.reset(new HostDispatcher( | 437 host_dispatcher_.reset(new HostDispatcher( |
431 pp_module(), | 438 pp_module(), |
432 &MockGetInterface, | 439 &MockGetInterface, |
| 440 status_receiver_.release(), |
433 PpapiPermissions::AllPermissions())); | 441 PpapiPermissions::AllPermissions())); |
434 host_dispatcher_->InitWithTestSink(&sink()); | 442 host_dispatcher_->InitWithTestSink(&sink()); |
435 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 443 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
436 } | 444 } |
437 | 445 |
438 void HostProxyTestHarness::SetUpHarnessWithChannel( | 446 void HostProxyTestHarness::SetUpHarnessWithChannel( |
439 const IPC::ChannelHandle& channel_handle, | 447 const IPC::ChannelHandle& channel_handle, |
440 base::MessageLoopProxy* ipc_message_loop, | 448 base::MessageLoopProxy* ipc_message_loop, |
441 base::WaitableEvent* shutdown_event, | 449 base::WaitableEvent* shutdown_event, |
442 bool is_client) { | 450 bool is_client) { |
443 // These must be first since the dispatcher set-up uses them. | 451 // These must be first since the dispatcher set-up uses them. |
444 CreateHostGlobals(); | 452 CreateHostGlobals(); |
445 | 453 |
446 delegate_mock_.Init(ipc_message_loop, shutdown_event); | 454 delegate_mock_.Init(ipc_message_loop, shutdown_event); |
447 | 455 |
448 host_dispatcher_.reset(new HostDispatcher( | 456 host_dispatcher_.reset(new HostDispatcher( |
449 pp_module(), | 457 pp_module(), |
450 &MockGetInterface, | 458 &MockGetInterface, |
| 459 status_receiver_.release(), |
451 PpapiPermissions::AllPermissions())); | 460 PpapiPermissions::AllPermissions())); |
452 ppapi::Preferences preferences; | 461 ppapi::Preferences preferences; |
453 host_dispatcher_->InitHostWithChannel(&delegate_mock_, | 462 host_dispatcher_->InitHostWithChannel(&delegate_mock_, |
454 base::kNullProcessId, channel_handle, | 463 base::kNullProcessId, channel_handle, |
455 is_client, preferences); | 464 is_client, preferences); |
456 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); | 465 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); |
457 } | 466 } |
458 | 467 |
459 void HostProxyTestHarness::TearDownHarness() { | 468 void HostProxyTestHarness::TearDownHarness() { |
460 HostDispatcher::RemoveForInstance(pp_instance()); | 469 HostDispatcher::RemoveForInstance(pp_instance()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, | 590 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
582 base::Bind(&RunTaskOnRemoteHarness, | 591 base::Bind(&RunTaskOnRemoteHarness, |
583 task, | 592 task, |
584 &task_complete)); | 593 &task_complete)); |
585 task_complete.Wait(); | 594 task_complete.Wait(); |
586 } | 595 } |
587 | 596 |
588 | 597 |
589 } // namespace proxy | 598 } // namespace proxy |
590 } // namespace ppapi | 599 } // namespace ppapi |
OLD | NEW |