OLD | NEW |
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 io_thread_data_.pending_sync_msgs_.find(id); | 478 io_thread_data_.pending_sync_msgs_.find(id); |
479 DCHECK(it != io_thread_data_.pending_sync_msgs_.end()); | 479 DCHECK(it != io_thread_data_.pending_sync_msgs_.end()); |
480 if (it != io_thread_data_.pending_sync_msgs_.end()) { | 480 if (it != io_thread_data_.pending_sync_msgs_.end()) { |
481 type = it->second; | 481 type = it->second; |
482 io_thread_data_.pending_sync_msgs_.erase(it); | 482 io_thread_data_.pending_sync_msgs_.erase(it); |
483 } | 483 } |
484 } | 484 } |
485 // Handle PpapiHostMsg_OpenResource outside the lock as it requires sending | 485 // Handle PpapiHostMsg_OpenResource outside the lock as it requires sending |
486 // IPC to handle properly. | 486 // IPC to handle properly. |
487 if (type == PpapiHostMsg_OpenResource::ID) { | 487 if (type == PpapiHostMsg_OpenResource::ID) { |
488 PickleIterator iter = IPC::SyncMessage::GetDataIterator(&msg); | 488 base::PickleIterator iter = IPC::SyncMessage::GetDataIterator(&msg); |
489 ppapi::proxy::SerializedHandle sh; | 489 ppapi::proxy::SerializedHandle sh; |
490 uint64_t token_lo; | 490 uint64_t token_lo; |
491 uint64_t token_hi; | 491 uint64_t token_hi; |
492 if (!IPC::ReadParam(&msg, &iter, &sh) || | 492 if (!IPC::ReadParam(&msg, &iter, &sh) || |
493 !IPC::ReadParam(&msg, &iter, &token_lo) || | 493 !IPC::ReadParam(&msg, &iter, &token_lo) || |
494 !IPC::ReadParam(&msg, &iter, &token_hi)) { | 494 !IPC::ReadParam(&msg, &iter, &token_hi)) { |
495 return false; | 495 return false; |
496 } | 496 } |
497 | 497 |
498 if (sh.IsHandleValid() && (token_lo != 0 || token_hi != 0)) { | 498 if (sh.IsHandleValid() && (token_lo != 0 || token_hi != 0)) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 void NaClIPCAdapter::SaveOpenResourceMessage( | 632 void NaClIPCAdapter::SaveOpenResourceMessage( |
633 const IPC::Message& orig_msg, | 633 const IPC::Message& orig_msg, |
634 IPC::PlatformFileForTransit ipc_fd, | 634 IPC::PlatformFileForTransit ipc_fd, |
635 base::FilePath file_path) { | 635 base::FilePath file_path) { |
636 // The path where an invalid ipc_fd is returned isn't currently | 636 // The path where an invalid ipc_fd is returned isn't currently |
637 // covered by any tests. | 637 // covered by any tests. |
638 if (ipc_fd == IPC::InvalidPlatformFileForTransit()) { | 638 if (ipc_fd == IPC::InvalidPlatformFileForTransit()) { |
639 // The file token didn't resolve successfully, so we give the | 639 // The file token didn't resolve successfully, so we give the |
640 // original FD to the client without making a validated NaClDesc. | 640 // original FD to the client without making a validated NaClDesc. |
641 // However, we must rewrite the message to clear the file tokens. | 641 // However, we must rewrite the message to clear the file tokens. |
642 PickleIterator iter = IPC::SyncMessage::GetDataIterator(&orig_msg); | 642 base::PickleIterator iter = IPC::SyncMessage::GetDataIterator(&orig_msg); |
643 ppapi::proxy::SerializedHandle sh; | 643 ppapi::proxy::SerializedHandle sh; |
644 | 644 |
645 // We know that this can be read safely; see the original read in | 645 // We know that this can be read safely; see the original read in |
646 // OnMessageReceived(). | 646 // OnMessageReceived(). |
647 CHECK(IPC::ReadParam(&orig_msg, &iter, &sh)); | 647 CHECK(IPC::ReadParam(&orig_msg, &iter, &sh)); |
648 scoped_ptr<IPC::Message> new_msg = CreateOpenResourceReply(orig_msg, sh); | 648 scoped_ptr<IPC::Message> new_msg = CreateOpenResourceReply(orig_msg, sh); |
649 | 649 |
650 scoped_ptr<NaClDescWrapper> desc_wrapper(new NaClDescWrapper( | 650 scoped_ptr<NaClDescWrapper> desc_wrapper(new NaClDescWrapper( |
651 NaClDescIoDescFromHandleAllocCtor( | 651 NaClDescIoDescFromHandleAllocCtor( |
652 #if defined(OS_WIN) | 652 #if defined(OS_WIN) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 header.flags = msg.flags(); | 830 header.flags = msg.flags(); |
831 header.num_fds = static_cast<uint16>(rewritten_msg->desc_count()); | 831 header.num_fds = static_cast<uint16>(rewritten_msg->desc_count()); |
832 | 832 |
833 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); | 833 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); |
834 locked_data_.to_be_received_.push(rewritten_msg); | 834 locked_data_.to_be_received_.push(rewritten_msg); |
835 } | 835 } |
836 | 836 |
837 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { | 837 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { |
838 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); | 838 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); |
839 } | 839 } |
OLD | NEW |