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

Side by Side Diff: components/nacl/loader/nacl_ipc_adapter.cc

Issue 472073003: Pepper: Make pending_sync_msgs_ local to IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.h ('k') | ppapi/proxy/nacl_message_scanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/loader/nacl_ipc_adapter.h" 5 #include "components/nacl/loader/nacl_ipc_adapter.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return MakeNaClDescCustom(this); 457 return MakeNaClDescCustom(this);
458 } 458 }
459 459
460 #if defined(OS_POSIX) 460 #if defined(OS_POSIX)
461 int NaClIPCAdapter::TakeClientFileDescriptor() { 461 int NaClIPCAdapter::TakeClientFileDescriptor() {
462 return io_thread_data_.channel_->TakeClientFileDescriptor(); 462 return io_thread_data_.channel_->TakeClientFileDescriptor();
463 } 463 }
464 #endif 464 #endif
465 465
466 bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) { 466 bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {
467 uint32_t type = msg.type();
468 if (type == IPC_REPLY_ID) {
469 int id = IPC::SyncMessage::GetMessageId(msg);
470 IOThreadData::PendingSyncMsgMap::iterator it =
471 io_thread_data_.pending_sync_msgs_.find(id);
472 DCHECK(it != io_thread_data_.pending_sync_msgs_.end());
473 if (it != io_thread_data_.pending_sync_msgs_.end()) {
474 type = it->second;
475 io_thread_data_.pending_sync_msgs_.erase(it);
476 }
477 }
478
467 { 479 {
468 base::AutoLock lock(lock_); 480 base::AutoLock lock(lock_);
469
470 scoped_refptr<RewrittenMessage> rewritten_msg(new RewrittenMessage); 481 scoped_refptr<RewrittenMessage> rewritten_msg(new RewrittenMessage);
471 482
472 typedef std::vector<ppapi::proxy::SerializedHandle> Handles; 483 typedef std::vector<ppapi::proxy::SerializedHandle> Handles;
473 Handles handles; 484 Handles handles;
474 scoped_ptr<IPC::Message> new_msg; 485 scoped_ptr<IPC::Message> new_msg;
475 if (!locked_data_.nacl_msg_scanner_.ScanMessage(msg, &handles, &new_msg)) 486
487 if (!locked_data_.nacl_msg_scanner_.ScanMessage(
488 msg, type, &handles, &new_msg))
476 return false; 489 return false;
477 490
478 // Now add any descriptors we found to rewritten_msg. |handles| is usually 491 // Now add any descriptors we found to rewritten_msg. |handles| is usually
479 // empty, unless we read a message containing a FD or handle. 492 // empty, unless we read a message containing a FD or handle.
480 for (Handles::const_iterator iter = handles.begin(); 493 for (Handles::const_iterator iter = handles.begin();
481 iter != handles.end(); 494 iter != handles.end();
482 ++iter) { 495 ++iter) {
483 scoped_ptr<NaClDescWrapper> nacl_desc; 496 scoped_ptr<NaClDescWrapper> nacl_desc;
484 switch (iter->type()) { 497 switch (iter->type()) {
485 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: { 498 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 void NaClIPCAdapter::ConnectChannelOnIOThread() { 652 void NaClIPCAdapter::ConnectChannelOnIOThread() {
640 if (!io_thread_data_.channel_->Connect()) 653 if (!io_thread_data_.channel_->Connect())
641 NOTREACHED(); 654 NOTREACHED();
642 } 655 }
643 656
644 void NaClIPCAdapter::CloseChannelOnIOThread() { 657 void NaClIPCAdapter::CloseChannelOnIOThread() {
645 io_thread_data_.channel_->Close(); 658 io_thread_data_.channel_->Close();
646 } 659 }
647 660
648 void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) { 661 void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) {
662 int id = IPC::SyncMessage::GetMessageId(*message.get());
663 DCHECK(io_thread_data_.pending_sync_msgs_.find(id) ==
664 io_thread_data_.pending_sync_msgs_.end());
665
666 if (message->is_sync())
667 io_thread_data_.pending_sync_msgs_[id] = message->type();
649 io_thread_data_.channel_->Send(message.release()); 668 io_thread_data_.channel_->Send(message.release());
650 } 669 }
651 670
652 void NaClIPCAdapter::SaveMessage(const IPC::Message& msg, 671 void NaClIPCAdapter::SaveMessage(const IPC::Message& msg,
653 RewrittenMessage* rewritten_msg) { 672 RewrittenMessage* rewritten_msg) {
654 lock_.AssertAcquired(); 673 lock_.AssertAcquired();
655 // There is some padding in this structure (the "padding" member is 16 674 // There is some padding in this structure (the "padding" member is 16
656 // bits but this then gets padded to 32 bits). We want to be sure not to 675 // bits but this then gets padded to 32 bits). We want to be sure not to
657 // leak data to the untrusted plugin, so zero everything out first. 676 // leak data to the untrusted plugin, so zero everything out first.
658 NaClMessageHeader header; 677 NaClMessageHeader header;
659 memset(&header, 0, sizeof(NaClMessageHeader)); 678 memset(&header, 0, sizeof(NaClMessageHeader));
660 679
661 header.payload_size = static_cast<uint32>(msg.payload_size()); 680 header.payload_size = static_cast<uint32>(msg.payload_size());
662 header.routing = msg.routing_id(); 681 header.routing = msg.routing_id();
663 header.type = msg.type(); 682 header.type = msg.type();
664 header.flags = msg.flags(); 683 header.flags = msg.flags();
665 header.num_fds = static_cast<int>(rewritten_msg->desc_count()); 684 header.num_fds = static_cast<int>(rewritten_msg->desc_count());
666 685
667 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); 686 rewritten_msg->SetData(header, msg.payload(), msg.payload_size());
668 locked_data_.to_be_received_.push(rewritten_msg); 687 locked_data_.to_be_received_.push(rewritten_msg);
669 } 688 }
670 689
671 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { 690 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) {
672 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); 691 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags);
673 } 692 }
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.h ('k') | ppapi/proxy/nacl_message_scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698