Skip to content

Commit

Permalink
Rename HandleConverter to NaClMessageScanner.
Browse files Browse the repository at this point in the history
Renames the class and its methods to reflect its role as a message
cracker, translator, and auditor.
Combines several out params into a single ScanOutput structure, to make it
easier to add other functions to the scan.

BUG=194304

Review URL: https://codereview.chromium.org/53123002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232603 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bbudge@chromium.org committed Nov 2, 2013
1 parent f193e4b commit 6276b49
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 363 deletions.
4 changes: 2 additions & 2 deletions components/nacl/loader/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ include_rules = [
"+native_client/src",
"+ppapi/c", # header files only

# For handle conversion in nacl_ipc_adapter.cc:
"+ppapi/proxy/handle_converter.h",
# For message scanning and handle conversion in nacl_ipc_adapter.cc:
"+ppapi/proxy/nacl_message_scanner.h",
"+ppapi/proxy/serialized_handle.h",

# For sending PpapiHostMsg_ChannelCreated in nacl_ipc_adapter.cc:
Expand Down
26 changes: 13 additions & 13 deletions components/nacl/loader/nacl_ipc_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,8 @@ bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {

typedef std::vector<ppapi::proxy::SerializedHandle> Handles;
Handles handles;
scoped_ptr<IPC::Message> new_msg_ptr;
bool success = locked_data_.handle_converter_.ConvertNativeHandlesToPosix(
msg, &handles, &new_msg_ptr);
if (!success)
scoped_ptr<IPC::Message> new_msg;
if (!locked_data_.nacl_msg_scanner_.ScanMessage(msg, &handles, &new_msg))
return false;

// Now add any descriptors we found to rewritten_msg. |handles| is usually
Expand Down Expand Up @@ -459,8 +457,8 @@ bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {
if (nacl_desc.get())
rewritten_msg->AddDescriptor(nacl_desc.release());
}
if (new_msg_ptr && !handles.empty())
SaveMessage(*new_msg_ptr, rewritten_msg.get());
if (new_msg)
SaveMessage(*new_msg, rewritten_msg.get());
else
SaveMessage(msg, rewritten_msg.get());
}
Expand Down Expand Up @@ -514,8 +512,7 @@ bool NaClIPCAdapter::SendCompleteMessage(const char* buffer,

// We actually discard the flags and only copy the ones we care about. This
// is just because message doesn't have a constructor that takes raw flags.
scoped_ptr<IPC::Message> msg(
new IPC::Message(header->routing, header->type));
scoped_ptr<IPC::Message> msg(new IPC::Message(header->routing, header->type));
if (header->flags & IPC::Message::SYNC_BIT)
msg->set_sync();
if (header->flags & IPC::Message::REPLY_BIT)
Expand All @@ -533,12 +530,15 @@ bool NaClIPCAdapter::SendCompleteMessage(const char* buffer,
// unlock for us. Holding the lock for the message construction, which is
// just some memcpys, shouldn't be a big deal.
lock_.AssertAcquired();
if (locked_data_.channel_closed_)
return false; // TODO(brettw) clean up handles here when we add support!

if (msg->is_sync()) {
locked_data_.handle_converter_.RegisterSyncMessageForReply(*msg);
if (locked_data_.channel_closed_) {
// If we ever pass handles from the plugin to the host, we should close them
// here before we drop the message.
return false;
}

if (msg->is_sync())
locked_data_.nacl_msg_scanner_.RegisterSyncMessageForReply(*msg);

// Actual send must be done on the I/O thread.
task_runner_->PostTask(FROM_HERE,
base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this,
Expand Down
4 changes: 2 additions & 2 deletions components/nacl/loader/nacl_ipc_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "base/task_runner.h"
#include "ipc/ipc_listener.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/proxy/handle_converter.h"
#include "ppapi/proxy/nacl_message_scanner.h"

struct NaClDesc;
struct NaClImcTypedMsgHdr;
Expand Down Expand Up @@ -127,7 +127,7 @@ class NaClIPCAdapter : public base::RefCountedThreadSafe<NaClIPCAdapter>,
// to be received by the plugin.
std::queue< scoped_refptr<RewrittenMessage> > to_be_received_;

ppapi::proxy::HandleConverter handle_converter_;
ppapi::proxy::NaClMessageScanner nacl_msg_scanner_;

// Data that we've queued from the plugin to send, but doesn't consist of a
// full message yet. The calling code can break apart the message into
Expand Down
4 changes: 2 additions & 2 deletions ppapi/ppapi_ipc.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# This part is shared between the targets defined below.
['ppapi_ipc_target==1', {
'sources': [
'proxy/handle_converter.cc',
'proxy/handle_converter.h',
'proxy/nacl_message_scanner.cc',
'proxy/nacl_message_scanner.h',
'proxy/ppapi_messages.cc',
'proxy/ppapi_messages.h',
'proxy/ppapi_param_traits.cc',
Expand Down
282 changes: 0 additions & 282 deletions ppapi/proxy/handle_converter.cc

This file was deleted.

Loading

0 comments on commit 6276b49

Please sign in to comment.