Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: ppapi/proxy/ppapi_proxy_test.cc

Issue 589213003: PPAPI: Never re-enter JavaScript for PostMessage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup/fixes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
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"
18 #include "ppapi/proxy/ppb_message_loop_proxy.h" 19 #include "ppapi/proxy/ppb_message_loop_proxy.h"
19 #include "ppapi/shared_impl/proxy_lock.h" 20 #include "ppapi/shared_impl/proxy_lock.h"
20 21
21 namespace ppapi { 22 namespace ppapi {
22 namespace proxy { 23 namespace proxy {
23 24
24 namespace { 25 namespace {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 int32_t result) { 401 int32_t result) {
401 EXPECT_EQ(PP_OK, result); 402 EXPECT_EQ(PP_OK, result);
402 PluginProxyMultiThreadTest* thiz = 403 PluginProxyMultiThreadTest* thiz =
403 static_cast<PluginProxyMultiThreadTest*>(user_data); 404 static_cast<PluginProxyMultiThreadTest*>(user_data);
404 thiz->CheckOnThread(SECONDARY_THREAD); 405 thiz->CheckOnThread(SECONDARY_THREAD);
405 thiz->SetUpTestOnSecondaryThread(); 406 thiz->SetUpTestOnSecondaryThread();
406 } 407 }
407 408
408 // HostProxyTestHarness -------------------------------------------------------- 409 // HostProxyTestHarness --------------------------------------------------------
409 410
410 class HostProxyTestHarness::MockSyncMessageStatusReceiver
411 : public HostDispatcher::SyncMessageStatusReceiver {
412 public:
413 virtual void BeginBlockOnSyncMessage() OVERRIDE {}
414 virtual void EndBlockOnSyncMessage() OVERRIDE {}
415 };
416
417 HostProxyTestHarness::HostProxyTestHarness(GlobalsConfiguration globals_config) 411 HostProxyTestHarness::HostProxyTestHarness(GlobalsConfiguration globals_config)
418 : globals_config_(globals_config), 412 : globals_config_(globals_config) {
419 status_receiver_(new MockSyncMessageStatusReceiver) {
420 } 413 }
421 414
422 HostProxyTestHarness::~HostProxyTestHarness() { 415 HostProxyTestHarness::~HostProxyTestHarness() {
423 } 416 }
424 417
425 PpapiGlobals* HostProxyTestHarness::GetGlobals() { 418 PpapiGlobals* HostProxyTestHarness::GetGlobals() {
426 return host_globals_.get(); 419 return host_globals_.get();
427 } 420 }
428 421
429 Dispatcher* HostProxyTestHarness::GetDispatcher() { 422 Dispatcher* HostProxyTestHarness::GetDispatcher() {
430 return host_dispatcher_.get(); 423 return host_dispatcher_.get();
431 } 424 }
432 425
433 void HostProxyTestHarness::SetUpHarness() { 426 void HostProxyTestHarness::SetUpHarness() {
434 // These must be first since the dispatcher set-up uses them. 427 // These must be first since the dispatcher set-up uses them.
435 CreateHostGlobals(); 428 CreateHostGlobals();
436 429
437 host_dispatcher_.reset(new HostDispatcher( 430 host_dispatcher_.reset(new HostDispatcher(
438 pp_module(), 431 pp_module(),
439 &MockGetInterface, 432 &MockGetInterface,
440 status_receiver_.release(), 433 scoped_refptr<IPC::MessageFilter>(new IPC::MessageFilter()),
441 PpapiPermissions::AllPermissions())); 434 PpapiPermissions::AllPermissions()));
442 host_dispatcher_->InitWithTestSink(&sink()); 435 host_dispatcher_->InitWithTestSink(&sink());
443 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); 436 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get());
444 } 437 }
445 438
446 void HostProxyTestHarness::SetUpHarnessWithChannel( 439 void HostProxyTestHarness::SetUpHarnessWithChannel(
447 const IPC::ChannelHandle& channel_handle, 440 const IPC::ChannelHandle& channel_handle,
448 base::MessageLoopProxy* ipc_message_loop, 441 base::MessageLoopProxy* ipc_message_loop,
449 base::WaitableEvent* shutdown_event, 442 base::WaitableEvent* shutdown_event,
450 bool is_client) { 443 bool is_client) {
451 // These must be first since the dispatcher set-up uses them. 444 // These must be first since the dispatcher set-up uses them.
452 CreateHostGlobals(); 445 CreateHostGlobals();
453 446
454 delegate_mock_.Init(ipc_message_loop, shutdown_event); 447 delegate_mock_.Init(ipc_message_loop, shutdown_event);
455 448
456 host_dispatcher_.reset(new HostDispatcher( 449 host_dispatcher_.reset(new HostDispatcher(
457 pp_module(), 450 pp_module(),
458 &MockGetInterface, 451 &MockGetInterface,
459 status_receiver_.release(), 452 scoped_refptr<IPC::MessageFilter>(new IPC::MessageFilter()),
460 PpapiPermissions::AllPermissions())); 453 PpapiPermissions::AllPermissions()));
461 ppapi::Preferences preferences; 454 ppapi::Preferences preferences;
462 host_dispatcher_->InitHostWithChannel(&delegate_mock_, 455 host_dispatcher_->InitHostWithChannel(&delegate_mock_,
463 base::kNullProcessId, channel_handle, 456 base::kNullProcessId, channel_handle,
464 is_client, preferences); 457 is_client, preferences);
465 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); 458 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get());
466 } 459 }
467 460
468 void HostProxyTestHarness::TearDownHarness() { 461 void HostProxyTestHarness::TearDownHarness() {
469 HostDispatcher::RemoveForInstance(pp_instance()); 462 HostDispatcher::RemoveForInstance(pp_instance());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, 583 plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE,
591 base::Bind(&RunTaskOnRemoteHarness, 584 base::Bind(&RunTaskOnRemoteHarness,
592 task, 585 task,
593 &task_complete)); 586 &task_complete));
594 task_complete.Wait(); 587 task_complete.Wait();
595 } 588 }
596 589
597 590
598 } // namespace proxy 591 } // namespace proxy
599 } // namespace ppapi 592 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698