Chromium Code Reviews| 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 "ppapi/proxy/nacl_message_scanner.h" | 5 #include "ppapi/proxy/nacl_message_scanner.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 } | 180 } |
| 181 bool ScanMessage(ScanningResults* results) { | 181 bool ScanMessage(ScanningResults* results) { |
| 182 typename base::TupleTypes<typename MessageType::Schema::Param>::ValueTuple | 182 typename base::TupleTypes<typename MessageType::Schema::Param>::ValueTuple |
| 183 params; | 183 params; |
| 184 if (!MessageType::Read(msg_, ¶ms)) | 184 if (!MessageType::Read(msg_, ¶ms)) |
| 185 return false; | 185 return false; |
| 186 ScanTuple(params, results); | 186 ScanTuple(params, results); |
| 187 return true; | 187 return true; |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool ScanSyncMessage(ScanningResults* results) { | |
| 191 typename base::TupleTypes< | |
| 192 typename MessageType::Schema::SendParam>::ValueTuple params; | |
| 193 if (!MessageType::ReadSendParam(msg_, ¶ms)) | |
| 194 return false; | |
| 195 ScanTuple(params, results); | |
|
Mark Seaborn
2015/12/17 01:46:54
This needs to be:
bool ScanSyncMessage(Scanning
dmichael (off chromium)
2015/12/17 19:04:29
Done.
| |
| 196 return true; | |
| 197 } | |
| 198 | |
| 190 bool ScanReply(ScanningResults* results) { | 199 bool ScanReply(ScanningResults* results) { |
| 191 typename base::TupleTypes<typename MessageType::Schema::ReplyParam> | 200 typename base::TupleTypes<typename MessageType::Schema::ReplyParam> |
| 192 ::ValueTuple params; | 201 ::ValueTuple params; |
| 193 if (!MessageType::ReadReplyParam(msg_, ¶ms)) | 202 if (!MessageType::ReadReplyParam(msg_, ¶ms)) |
| 194 return false; | 203 return false; |
| 195 // If we need to rewrite the message, write the message id first. | 204 // If we need to rewrite the message, write the message id first. |
| 196 if (results->new_msg) { | 205 if (results->new_msg) { |
| 197 results->new_msg->set_reply(); | 206 results->new_msg->set_reply(); |
| 198 int id = IPC::SyncMessage::GetMessageId(*msg_); | 207 int id = IPC::SyncMessage::GetMessageId(*msg_); |
| 199 results->new_msg->WriteInt(id); | 208 results->new_msg->WriteInt(id); |
| 200 } | 209 } |
| 201 ScanTuple(params, results); | 210 ScanTuple(params, results); |
| 202 return true; | 211 return true; |
| 203 } | 212 } |
| 204 // TODO(dmichael): Add ScanSyncMessage for outgoing sync messages, if we ever | 213 // TODO(dmichael): Add ScanSyncMessage for outgoing sync messages, if we ever |
|
Mark Seaborn
2015/12/17 01:49:04
This TODO should be removed too.
dmichael (off chromium)
2015/12/17 19:04:29
Done.
| |
| 205 // need to scan those. | 214 // need to scan those. |
| 206 | 215 |
| 207 private: | 216 private: |
| 208 const MessageType* msg_; | 217 const MessageType* msg_; |
| 209 }; | 218 }; |
| 210 | 219 |
| 211 } // namespace | 220 } // namespace |
| 212 | 221 |
| 213 #define CASE_FOR_MESSAGE(MESSAGE_TYPE) \ | 222 #define CASE_FOR_MESSAGE(MESSAGE_TYPE) \ |
| 214 case MESSAGE_TYPE::ID: { \ | 223 case MESSAGE_TYPE::ID: { \ |
| 215 MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ | 224 MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ |
| 216 if (rewrite_msg) \ | 225 if (rewrite_msg) \ |
| 217 results.new_msg.reset( \ | 226 results.new_msg.reset( \ |
| 218 new IPC::Message(msg.routing_id(), msg.type(), \ | 227 new IPC::Message(msg.routing_id(), msg.type(), \ |
| 219 IPC::Message::PRIORITY_NORMAL)); \ | 228 IPC::Message::PRIORITY_NORMAL)); \ |
| 220 if (!scanner.ScanMessage(&results)) \ | 229 if (!scanner.ScanMessage(&results)) \ |
| 221 return false; \ | 230 return false; \ |
| 222 break; \ | 231 break; \ |
| 223 } | 232 } |
| 233 #define CASE_FOR_SYNC_MESSAGE(MESSAGE_TYPE) \ | |
| 234 case MESSAGE_TYPE::ID: { \ | |
|
Mark Seaborn
2015/12/17 01:46:54
Nit: can you make the indentation alignment match
dmichael (off chromium)
2015/12/17 19:04:29
Done (actually changed the others; not sure why I
| |
| 235 MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ | |
| 236 if (rewrite_msg) \ | |
| 237 results.new_msg.reset(new IPC::Message(msg.routing_id(), msg.type(), \ | |
| 238 IPC::Message::PRIORITY_NORMAL)); \ | |
| 239 if (!scanner.ScanSyncMessage(&results)) \ | |
| 240 return false; \ | |
| 241 break; \ | |
| 242 } | |
| 224 #define CASE_FOR_REPLY(MESSAGE_TYPE) \ | 243 #define CASE_FOR_REPLY(MESSAGE_TYPE) \ |
| 225 case MESSAGE_TYPE::ID: { \ | 244 case MESSAGE_TYPE::ID: { \ |
| 226 MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ | 245 MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \ |
| 227 if (rewrite_msg) \ | 246 if (rewrite_msg) \ |
| 228 results.new_msg.reset( \ | 247 results.new_msg.reset( \ |
| 229 new IPC::Message(msg.routing_id(), msg.type(), \ | 248 new IPC::Message(msg.routing_id(), msg.type(), \ |
| 230 IPC::Message::PRIORITY_NORMAL)); \ | 249 IPC::Message::PRIORITY_NORMAL)); \ |
| 231 if (!scanner.ScanReply(&results)) \ | 250 if (!scanner.ScanReply(&results)) \ |
| 232 return false; \ | 251 return false; \ |
| 233 break; \ | 252 break; \ |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 // that there are no handles, we can cancel the rewriting by clearing the | 338 // that there are no handles, we can cancel the rewriting by clearing the |
| 320 // results.new_msg pointer. | 339 // results.new_msg pointer. |
| 321 ScanningResults results; | 340 ScanningResults results; |
| 322 results.nested_msg_callback = | 341 results.nested_msg_callback = |
| 323 base::Bind(&NaClMessageScanner::AuditNestedMessage, | 342 base::Bind(&NaClMessageScanner::AuditNestedMessage, |
| 324 base::Unretained(this)); | 343 base::Unretained(this)); |
| 325 switch (type) { | 344 switch (type) { |
| 326 CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) | 345 CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) |
| 327 CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) | 346 CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) |
| 328 CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) | 347 CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply) |
| 348 CASE_FOR_SYNC_MESSAGE(PpapiMsg_PPPMessageHandler_HandleBlockingMessage) | |
| 329 CASE_FOR_REPLY(PpapiHostMsg_OpenResource) | 349 CASE_FOR_REPLY(PpapiHostMsg_OpenResource) |
| 330 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_Create) | 350 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_Create) |
| 331 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) | 351 CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer) |
| 332 CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) | 352 CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) |
| 333 CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) | 353 CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) |
| 334 CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) | 354 CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) |
| 335 default: | 355 default: |
| 336 // Do nothing for messages we don't know. | 356 // Do nothing for messages we don't know. |
| 337 break; | 357 break; |
| 338 } | 358 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 fio_it->second->SetMaxWrittenOffset(offset_it->second); | 539 fio_it->second->SetMaxWrittenOffset(offset_it->second); |
| 520 } | 540 } |
| 521 } | 541 } |
| 522 break; | 542 break; |
| 523 } | 543 } |
| 524 } | 544 } |
| 525 } | 545 } |
| 526 | 546 |
| 527 } // namespace proxy | 547 } // namespace proxy |
| 528 } // namespace ppapi | 548 } // namespace ppapi |
| OLD | NEW |