Chromium Code Reviews| Index: ppapi/proxy/nacl_message_scanner.cc |
| diff --git a/ppapi/proxy/nacl_message_scanner.cc b/ppapi/proxy/nacl_message_scanner.cc |
| index 769a03f2885ceb2cfbde6694c86506e09ce529a4..8874bbfb83026cf6f2b070680fd170c547dc7c4c 100644 |
| --- a/ppapi/proxy/nacl_message_scanner.cc |
| +++ b/ppapi/proxy/nacl_message_scanner.cc |
| @@ -138,6 +138,15 @@ void ScanParam(const IPC::Message& param, ScanningResults* results) { |
| IPC::WriteParam(results->new_msg.get(), param); |
| } |
| +template <class T> |
| +void ScanParam(const std::vector<T>& vec, ScanningResults* results) { |
| + if (results->new_msg) |
| + IPC::WriteParam(results->new_msg.get(), static_cast<int>(vec.size())); |
| + for (const T& element : vec) { |
| + ScanParam(element, results); |
| + } |
| +} |
| + |
| // Overload to match all other types. If we need to rewrite the message, write |
| // the parameter. |
| template <class T> |
| @@ -187,7 +196,22 @@ class MessageScannerImpl { |
| return true; |
| } |
| - bool ScanReply(ScanningResults* results) { |
| + bool ScanSyncMessage(ScanningResults* results) { |
|
bbudge
2015/12/16 20:30:06
David Michael has implemented this in a patch we h
Mark Seaborn
2015/12/17 06:09:56
Thanks for pointing that out! I was able to debug
bbudge
2015/12/17 19:10:21
Not at all. Thank you for figuring out the problem
|
| + typename base::TupleTypes<typename MessageType::Schema::SendParam> |
| + ::ValueTuple params; |
| + if (!MessageType::ReadSendParam(msg_, ¶ms)) |
| + return false; |
| + // If we need to rewrite the message, write the message id first. |
| + if (results->new_msg) { |
| + results->new_msg->set_sync(); |
| + int id = IPC::SyncMessage::GetMessageId(*msg_); |
| + results->new_msg->WriteInt(id); |
| + } |
| + ScanTuple(params, results); |
| + return true; |
| + } |
| + |
| + bool ScanSyncReply(ScanningResults* results) { |
|
bbudge
2015/12/16 20:30:06
ScanReply?
Mark Seaborn
2015/12/17 06:09:56
I renamed the existing ScanReply() to ScanSyncRepl
bbudge
2015/12/17 19:10:21
It makes the code in CASE_FOR_REPLY confusing thou
Mark Seaborn
2015/12/21 22:58:50
OK, I can just rename this back to ScanReply(). I
|
| typename base::TupleTypes<typename MessageType::Schema::ReplyParam> |
| ::ValueTuple params; |
| if (!MessageType::ReadReplyParam(msg_, ¶ms)) |
| @@ -201,8 +225,6 @@ class MessageScannerImpl { |
| ScanTuple(params, results); |
| return true; |
| } |
| - // TODO(dmichael): Add ScanSyncMessage for outgoing sync messages, if we ever |
| - // need to scan those. |
| private: |
| const MessageType* msg_; |
| @@ -221,6 +243,17 @@ class MessageScannerImpl { |
| return false; \ |
| break; \ |
| } |
| +#define CASE_FOR_SYNC_MESSAGE(MESSAGE_TYPE) \ |
| + case MESSAGE_TYPE::ID: { \ |
| + MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ |
| + if (rewrite_msg) \ |
| + results.new_msg.reset( \ |
| + new IPC::Message(msg.routing_id(), msg.type(), \ |
| + IPC::Message::PRIORITY_NORMAL)); \ |
| + if (!scanner.ScanSyncMessage(&results)) \ |
| + return false; \ |
| + break; \ |
| + } |
| #define CASE_FOR_REPLY(MESSAGE_TYPE) \ |
| case MESSAGE_TYPE::ID: { \ |
| MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ |
| @@ -228,7 +261,7 @@ class MessageScannerImpl { |
| results.new_msg.reset( \ |
| new IPC::Message(msg.routing_id(), msg.type(), \ |
| IPC::Message::PRIORITY_NORMAL)); \ |
| - if (!scanner.ScanReply(&results)) \ |
| + if (!scanner.ScanSyncReply(&results)) \ |
| return false; \ |
| break; \ |
| } |
| @@ -326,6 +359,7 @@ bool NaClMessageScanner::ScanMessage( |
| CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) |
| CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) |
| CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) |
| + CASE_FOR_SYNC_MESSAGE(PpapiMsg_PnaclTranslatorLink) |
| CASE_FOR_REPLY(PpapiHostMsg_OpenResource) |
| CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_Create) |
| CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) |